Little Languages

Last month, I wrote about one of John Bentley’s Programming Pearls columns in the Communication of the ACM. Someone has posted another column, this one on Little Languages. I remember reading the column in More Programming Pearls; it instilled in me a way of looking at certain problems that I’ve used throughout my career.

It’s surprising how often a problem can be easily solved by writing a little language to transform the data you have into a form suitable for some other existing program that can do all the heavy lifting. Bentley gives the example of chem, a small awk program that took the description of some chemical as input and output a pic program that could be used as input to troff to typeset the standard graphical representation of the chemical. Thus he (and Brian Kernighan) chained together two little languages to produce a useful input to troff to do something that I’m sure Joseph Ossanna never envisioned when he wrote troff.

Early in my career, I did something similar. I was part of a small remote team working on Unix systems. My personal computer was running FreeBSD, which at that time did not have anything like OpenOffice. The HR trolls demanded time sheets that were printed from an Excel spreadsheet. Since I couldn’t do that, I wrote an awk program to take my task times as input and output tbl (another troff little language preprocessor) commands that troff then typeset as a reasonable facsimile of the Excel spreadsheet. I’ve used the same trick over and over: write a simple program to produce input to some larger program to produce the needed output.

Take a look at Bentley’s column1. Perhaps you’ll learn a new way or working too.

Footnotes:

1

The PDF of the ACM article is a little confusing. Pages 714 and 715 are a sidebar meant to be read separately but it comes right in the middle of the main text and it’s easy to get lost.

Posted in General | Tagged , | Leave a comment

Org Capture

I’ve seen some questions lately asking if it’s worthwhile to learn Org mode. Regular readers will have no doubt as to my answer but I stumbled across a nice post from Charles Cave on how he uses Org capture, templates, and agendas to organize his day and log relevant information. The post is (probably) from a few years ago but its content is still up to date.

Like me, Cave records a lot of information that has an associated timestamp so he makes extensive use of datetrees in his capture templates. That’s really handy because Org-capture will file each entry in a 4-level hierarchy with the first three levels being year, month, day and the fourth level being the actual item. That makes it easy to see, for example, all the entries recorded in June of 2016. Being an Org file, all the headings are foldable so it’s easy to hide everything except the information you’re interested in.

You can also add one or more tags to each entry so if you want to see all the entries associated with, say, your dentist, it’s easy to pull them up by the “dentist” tag. One of the nice features of Org capture is that you can have the template prompt you for a tag. That makes it harder to forget to add them.

There’s much more so if you’re not familiar with Org capture and templates, take a look at Cave’s post to see what’s possible.

Posted in General | Tagged , | Leave a comment

Sorry for the Bad Formatting

I just noticed that Wednesday’s post on the Emacs/ImageMagick interface was formatted with embedded newlines. That means a certain amount of pain for those of you trying to read the post on your phones or other small-screened mobile devices. Sorry.

The problem was that I wrote the post in the wrong directory (~/org instead of ~/org/blog) so auto-fill was enabled. When I realized I was in the wrong directory, I moved the post but auto-fill had already done its work and I didn’t notice.

Again, sorry to those of you who read it on a mobile device. I’ll try to do better.

Posted in Administrivia | Leave a comment

Beorg Review

One of the frustrations for Org mode users is getting access to their data on mobile devices. The situation is a little better in the Android world, where one can run Emacs on their phones but on iOS the choices are limited. One choice available to us living in the Apple world is beorg. It’s a fairly recent entry to the Org/iOS world and appears to have the potential to be an essential application for iOS users.

I’ve been following beorg development and wondering if I should install it as an way of getting access to my Org files from my mobile devices. I was, therefore, happy to see Chris Rosser’s review of beorg. At first, I was disappointed. It’s pretty clear from the review that Rosser doesn’t really understand Emacs or Org. He appears to think that Org is fundamentally a task manager but that was never its primary purpose even though many use it for that. His review is informed by that notion and is, therefore, not as useful as it might otherwise be for people like me.

After reconsideration, I realized that Rosser’s review is useful for folks who don’t know Emacs and Org and are merely looking for a way of accessing their calendar or task list from their mobile device. If you’re one of those people, take a look at Rosser’s review. If, like me, you’re wondering if beorg might be the answer to moving your Org data to your mobile devices, this review probably isn’t what you’re looking for.

Posted in General | Tagged , , | Leave a comment

Emacs ImageMagick Interface

If you’re in the intersection of Emacs and ImageMagick users, Blimp
may interest you. It’s an Emacs interface to the ImageMagick commands.
Take a look at the README on GitHub to see how it works and what it
can do.

I haven’t used ImageMagick in a long time so I haven’t tried Blimp. If
you do work with ImageMagick, this is a chance to integrate one more
workflow into Emacs. It almost makes me wish I had a need for ImageMagick.

Posted in General | Tagged | Leave a comment

Norvig’s Paradigms of Artificial Intelligence Programming Open Sourced

If you have any Lisp experience at all, you almost certainly know about Peter Norvig’s classic Paradigms of Artificial Intelligence Programming (PAIP). It’s an excellent introduction to Lisp and, of course, Artificial Intelligence. Via Rainer Joswig we learn that PAIP has been open sourced.

The GitHub repository contains the book in PDF, Text, epub, and Markdown source. The example lisp code is also included. If you have any interest at all in Lisp—and in particular in Common Lisp—you should definitely take a look at this book. The markdown files are by chapter so it’s easy to sample them directly in GitHub, which will render the Markdown in a reasonable way. If you find that interesting, you can download the PDF or epub files for local reading.

Posted in General | Tagged , | Leave a comment

Displaying Alerts from Eshell

Jürgen Hötzel has a nice post on solving a problem many of us have. Suppose you start a long running process—a make, say—from Eshell and then go on to do other work. It’s easy to lose track of the process because the original buffer may be buried and nothing might happen for a long time. Hötzel wants to be notified when the process completes or if it terminates abnormally.

It turns out to be absurdly easy to do that by leveraging John Wiegley’s alert package. Hötzel has the alert set up to show in the minibuffer but the alert package supports many different styles of alerts. For example, if you’re a Mac user and have Growl installed, you can send the alert to Growl. Another nice feature of the alert package is that you can add rules to filter the alerts. For example, Hötzel added a rule to not display the alert if the original buffer is visible. That helps cut down on noise.

Hötzel triggers his alerts by hooking into the eshell-kill-hook but it’s easy to see how you could generate many other types of alerts either by using other hooks. Take a look at Hötzel’s code; it’s very minimal and simple and mostly decides whether the alert should have “normal” status (when the process terminate normally) or “urgent” status (when the process terminates abnormally).

Posted in General | Tagged | Leave a comment

Happy Birthday DMR

Today is Dennis Ritchie’s birthday. Take a moment to remember the man who, along with Ken Thompson, invented Unix and changed our world. Those of us in computer related fields would be working in a completely different environment were it not for him and Ken.

Sadly, Ritchie died in 2011. When he was still alive, I used to check in with his home page everyday to see what new splendor he had revealed. Most of the public have no idea who he was or what he did but his work touches their life everyday in a multitude of ways. If you’re doing anything with a computer—using a cell phone, browsing the Web, using a word processor, or whatever—the chances are you are using some of Ritchie’s work.

Geeks everywhere miss him and are grateful for his contributions. This is a good day to remember him and those contributions.

Posted in General | Tagged , | Leave a comment

Firefox’s Plans for Fighting Tracking

The Firefox developers at Mozilla are no longer going to tolerate the miscreants in the Adtech business. On their blog, they lay out their plans for dealing with tracking. Among other things, they will be stripping cookies from tracking sites and not allowing them the use of local storage. Take a look at the post for what they’re doing and why they’re doing it. The Safari browser is also addressing the problem in similar but slightly different ways.

I wish the other browser vendors would also get serious about tracking. What I’d really like to see is fine grained control over cookies. As it stands, I have to manually delete cookies several times a day. Why can’t I specify something like, “Except for sites A, B, and C, delete all cookies at the end of each session or when I push a button.” That would enable innocuous sites like weather or TV Guide to store their configuration between sessions while still getting rid of the riffraff.

Safari makes it particularly difficult to deal with cookies because they store them in a database. When they’re just text files, it’s easy to write shell scripts to get that fine grained control. Still, Firefox’s initiative is welcome and I hope that they and the other vendors will give us still more control over our browsers. There’s no reason that the browser vendors should be enabling the reprehensible behavior of Adtech.

Posted in General | Tagged , | Leave a comment

Emacs → VSCode → Emacs

Bryan Willson Berry over at Hotair.tech recently moved into JavaScript development. Although he is a longtime Emacs user, he didn’t like the JavaScript support in Emacs so he moved to VSCode. VSCode is the new editor hotness, of course, so I was interested in what he had to say. I know a lot n00bs are drawn to VSCode but I wanted the opinion of someone who had experience with a serious editor.

Berry found that VSCode is an excellent editor and that it was especially good for JavaScript programming. He also found that although VSCode was better than Emacs for JavaScript, Emacs was better at almost everything else. That and the fact that he used Emacs key bindings in all his applications and therefore had serious muscle memory issues—See? I’m not the only one—caused him to move back to Emacs.

Happily, he was able to find some tools that helped with his JavaScript programming so the story has a happy ending. He still believes that VSCode is a superior for editing JavaScript but that Emacs is better in so many other ways that it makes sense to stick with it.

It’s always pleasant to have one’s biases confirmed, of course, so we Emacers probably shouldn’t read too much into Berry’s experience. Still, that experience does confirm my preconceived notion that while other editors may do this or that better, all-in-all, you can’t beat Emacs. But then, I would say that, wouldn’t I?

Posted in General | Tagged | Leave a comment