John Cook on Literate Programming

John D. Cook has another post in his series of posts discussing the use of Org mode in his professional duties as a consulting mathematician. This time he discusses the pros and cons of literate programming.

He recounts the story of a blog post that had some errors that he believes might have been avoided if he’d used literate programming. He rewrote the post using literate programming and had a few observations.

First, he found that it was harder to compose the post using literate programming. There’s a lot of little markup details that you have to deal with that aren’t necessary when you just paste in a value from a separate computation. Still, that effort pays dividends if you have to update your post with new parameters and can help reduce errors.

I’ve reached the point where I do all my writing in Org-mode and always do any necessary computations in a code block. It’s a real win because if parameters change I just need to change it in one place and regenerate the document and I don’t need to worry about errors induced by pasting in values.

Take a look at Cook’s post for the point of view of someone who, although technical, is not really part of the developer community.

Posted in General | Tagged , | Leave a comment

RMS on the Development of Emacs

I know I’ve written about this before but someone posted a link to a transcript of RMS’s 2002 speech on Lisp and the development of Emacs. It’s an interesting read. Along the way RMS tells the heartbreaking story of the destruction of the MIT AI Lab and the resulting war between Symbolics and Lisp Machines Incorporated (LMI). He tells the now famous story of his independently reimplementing every change Symbolics introduced so that LMI would have them too.

RMS eventually tired of punishing Symbolics and realized that if he wanted to recreate the camaraderie of the AI Lab he was going to have to build a new, free (in the GNU sense) operating system. He was tempted by Lisp but realized that the hardware wasn’t available to support such an endeavor so GNU, as we know it today, was born.

The two parts of his talk that I liked the best are, first, his recounting of the early history of Emacs and its genesis in the TECO editor. The second part I liked was his explanation of why having an embedded Lisp interpreter in programs like Emacs is such a win. His dream of having Guile scheme being a target language for other languages’ compilers didn’t bear fruit and neither, mostly, did the idea of having Guile be a universal extension language. That’s too bad, especially considering what we got instead.

In any event, if you care at all about the history of Emacs and GNU, this presentation is worth reading.

Posted in General | Tagged | Leave a comment

Leslie Lamport on Deconstructing the Bakery Algorithm

The ACM has a short, delightful video featuring Leslie Lamport talking about his recent discovery of a surprising connection between two of his papers from the 1970s. Those papers, one usually called the Bakery algorithm and the other usually called the Time Clocks paper are well known within the distributed computing community and are still studied today.

The Bakery algorithm, that Irreal discussed previously, ensures that distributed processes execute a critical region one at a time. The Time Clocks paper discusses a distributed state machine algorithm. Lamport, in the process of writing a recent paper, discovered that the two algorithms are related and that each can be derived from the other.

Lamport explains this in a paper in the latest (September 2022) Communications of the ACM. The paper itself is here. The video is only 3 minutes 14 seconds long so it will be easy to find time for it.

Emacsers will enjoy discovering that Lamport is an Emacs user. Mechanical keyboard aficionados will appreciate his choice of an IBM Model M, which as everyone knows, is the worlds best keyboard. Finally, for those Math nerds who, like me, are lusting after his “You want proof?” T-shirt, you can get them from Cotton Expressions.

Posted in General | Tagged , | Leave a comment

Increasing the Max Open Files in Emacs on macOS

From time to time I see complaints about Emacs having too many open files on macOS. This is because Apple has set the default number of open files for a process at 1024. Sadly, you can’t fix this by upping the limit with ulimit.

There is, however, a fix although it’s a bit complicated. You have to make adjustments to both macOS and Emacs. Happily Jiacai Liu has a step-by-step procedure for upping the limit. The TL;DR is that you have to add a couple of files to your macOS installation and go through a fussy operation to get them installed. Then you have to recompile Emacs with defines for FD_SETSIZE and DARWIN_UNLIMITED_SELECT.

Apparently the problem manifests itself when you’re using Emacs with LSP so if you’re an LSP user, you may have go through the—admittedly painful—process. I haven’t run into this problem yet and part of the reason for this post is to help me remember what to do in case I do. If you’re an Emacs user on macOS, you may want to bookmark Liu’s post in case you run into the problem.

Posted in General | Tagged , | Leave a comment

Emacs Shortcuts

Just a quickie today.

Vernon Grant has compiled a list of Emacs shortcuts that he finds useful and uses everyday. Almost all of them are core Emacs shortcuts so they should be available to all Emacs users. It’s useful to read through to learn new bindings or recall ones you haven’t used for a while and have forgotten.

The list is in a GitHub repository so it’s easy to bookmark if you want to refer back to it. The list is in the README, which is a markdown file so it’s easy to capture and print if you want a cheat sheet. Here’s the file in markdown mode if you’re interested in making your own copy.

Posted in General | Tagged | Leave a comment

Red Meat Friday: Give Nothing, Expect Nothing

Joe Brockmeier over at Dissociated Press makes a point about free software that may make some folks uncomfortable but that I’ve long felt is true: Give nothing, expect nothing. The TL;DR is that if you are using a free service such as GitLab you really don’t have much standing to complain when those services are modified or even eliminated. The companies providing these services are for profit. How else are they going to pay for their infrastructure and engineers?

My longstanding policy is to pay for any service I find useful. That’s not because I’m an especially virtuous person but because if the service is useful to me, I want it to continue to be available. It’s fine to try out a service for free but as soon as it becomes vital to your company or workflow, you better start paying for it to ensure it will still be available tomorrow.

If you don’t pay, then you don’t get to whine when the service is restricted or eliminated. Even if you can’t contribute financially, you can help by providing code or documentation or otherwise supporting the product. Regardless, don’t be an entitled nitwit who thinks the companies providing these services owe you something. They don’t.

Posted in General | Tagged | Leave a comment

Chris Wellons on Hashing

The first data structure I learned and really internalized was the hash table. I’ve been using them my entire career and, given when I started, that meant implementing them myself. This was before I learned C and even C doesn’t have a built-in hash table so it’s always been a matter of build it or do without.

These days, it’s hard to find a (newer) language that doesn’t have a built-in hash table or dictionary data type. There’s a downside to that, however. For many younger engineers, hash tables are mysterious entities that seem like magic. There are, in fact, many strategies for implementing a hash table each with their own tradeoff and which is best depends on the particular application. The problem with a built-in type is that it’s one size fits all.

Chris Wellons writes mostly in C so he has implemented scores of hash tables. He’s settled on his own implementation method which is basically open addressing with double hashing. You can check his post for what exactly that means but it’s one of the main implementation methods. I’ve always preferred the chaining method, which is usually faster but takes more storage. Like Wellons, I’ve done scores of implementations.

Why do that? After all, most languages have a built-in type and even C probably has a library that implements hash tables. Lots of people think there IS no point but I disagree: if you know how things work, you know how to pick the best implementation strategy for your particular application.

Take a look at Wellons’ post for some of those details. Section 6.4 of Volume 3 of Knuth’s AOCP has all the details on the various methods and their tradeoffs. If you’re serious about software engineering, it will repay your attention.

Posted in General | Tagged | Leave a comment

More On Google’s False Accusation

I thought I was finished with the story of Google falsely accusing one of their users of child molestation but Ben Thompson of Stratechery has his own take on the matter that he describes in a long blog post on the controversy.

He’s ambivalent on the matter of whether or not Google should be scanning their users’ photos. He wonders if the harm that child pornography does to children justifies Google’s spying on people. He’s not sure. I am: nothing justifies the spying and the argument that child pornography does is too easily extended to other public safety issues and eventually to any reason at all.

Thompson is sure of one thing: Google should have restored the user’s account and files and he’s astounded that they haven’t. It’s hard to understand why not. Perhaps they’re afraid of admitting guilt in case there’s future legal action.

In every story like this the apologists always say that Google or whoever is, after all, a private company and they can do as they like as long as it’s not illegal. Google, Facebook, Twitter, Apple, and the other big players have worked hard to become essential utilities and they’ve largely succeeded. But if they want to be like the electric or telephone utilities then they should operate under the same sorts of rules. Yes, they are private companies but they have civic responsibilities. They shouldn’t be able, for example, to refuse service to someone because they don’t like what they say or do as long as it’s legal. It’s time to stop letting these companies have it both ways.

Posted in General | Tagged | Leave a comment

Mastering Eshell

Mickey has (re)posted his article on Eshell. I think he’s updated it a bit because he talks about Emacs 28 but regardless, it’s a great article and every Emacser should read it. The problem with Eshell is that there’s not much documentation so Mickey’s article is especially useful.

There’s too much information packed into the article to give a reasonable précis here but there are a couple of capabilities—one of which I use, and the other that I keep promising myself that I’ll learn and use—that are worth calling out. The first is the ability to cd to a directory on a remote machine when you’re in Eshell. It almost seems like magic and works completely transparently except, of course, that you have use the standard Tramp notation for describing a remote file/directory.

The second really great feature is that Eshell implements zsh’s argument predicates. The later Apple OSs now use zsh by default so there’s even less excuse for me not to become adept at their use. The idea is easy, it’s just a matter of learning what the modifiers and predicates are. Fortunately, there are a couple of Emacs commands, eshell-display-predicate-help and eshell-display-modifier-help that pops up a window with lists of the predicates and modifiers. The commands put focus in the window so it’s easy to quit out of it with q. This is especially handy for me because I run Eshell as a full-frame window. As Mickey says, if you use argument predicates a lot it’s probably worthwhile adding an alias for these commands.

There is much more information in the article so be sure to take a look.

Posted in General | Tagged | Leave a comment

Quick Capture of Project Notes

Ben Simon has a nice example of leveraging Emacs to solve a problem and reduce his workflow friction. During his video calls he would bring up a notepad file to capture his notes and share them with his the other callers as a sort of whiteboard. The problem was that he ended up with a mishmash of files with ambiguous names that made organizing his notes difficult.

Like me, one day he realized this process was silly and he decided to move the task to Emacs. He determined he should file his notes in a file hierarchy along the lines of notes/customer/project/date.md. Simon’s desired process is to invoke a single function that will bring up a in the desired hierarchy. That means he needs to determine

  1. His current customer
  2. That customer’s project
  3. Today’s date

Simon shows how he determines those parameters. The date, of course, is easy but the others are a little bit tricky, especially since he’s using both Git and Subversion to host his project files. Still, it takes just a little bit of Elisp to bring up the required file. His post is worth taking a look at just to see how he interacts with his file hierarchy to get the information needed to accomplish the task.

Update [2022-08-30 Tue 16:57]: Added link to Simon’s post.

Posted in General | Tagged | Leave a comment