Progress Report

I’ve almost completely recovered from the debacle with my old computer. At least recovered enough to resume posting to Irreal. I now have a brand new 13“ MacBook Pro complete with touch strip and bad keyboard. My old machine was 6 or 7 years old and I’d been thinking of replacing it but I was waiting for Apple to admit they made a mistake with the new keyboards and go back to the old style across their product line.
The 16” does have the new keyboard and wasn’t that much more expensive but I really like the 13“ form factor. And there’s no getting away from the touch strip so I’m just sucking that up.

I learned a lot from all this. First and most important, a robust backup regime is vital. I use Backblaze, which I really like. It’s not too expensive and takes care of backing up everything automatically. I was hoping to never have to use the restore function but my old machine was completely dead so I couldn’t migrate my environment to the new machine automatically. The Backblaze restore has several options but the easiest and fastest for me was to download a zip file. Backblaze even provides a downloader that they say is faster and safer than using the browser and it did work well. At one point there was a network problem but the downloader was able to restart where it left off.

I made the mistake of unpacking the zip file from my desktop. That was a mistake because the desktop is shadowed on the iCloud and it filled up my iCloud space as it started to expand the zip file. I aborted that and moved the zip file another area that wasn’t shadowed. After that, everything went pretty well except that some permissions and ownerships were changed and I had to fix those. Fortunately the -R option to chown made that mostly painless.

So the second lesson is that it pays to have a local backup of your important files. I’ll probably get a solid state hard drive (like this one) and maybe tie it to Apple’s Time Machine mechanism. If I’d done that before it would have been easier and faster to recover my environment.

Perhaps the most important thing I learned was that my smug assurances that I could recover in a day if Apple suddenly disappeared were wildly overoptimistic. Starting with a new machine and no old machine to help migrate your important files turns out to be harder and more finicky than I supposed. Still, my main point holds: All my data is text and I could just as easily restored it onto, say, a Linux machine if I’d needed to. It just wasn’t as easy as I thought it would be.

This is a long post but the TL;DR is that if, like me, you’re living a digital life and have important data on your computer it’s vital that you keep it backed up.

Posted in Blogging | Leave a comment

Red Alert

Last night, I managed to spill my beverage of choice onto my laptop. As McCoy would say, “It’s dead Jim.” Until I can replace it (probably tomorrow) and download my backups (who knows how long that will take) Irreal will be taking a forced vacation. See you on the other side.

Posted in Blogging | Leave a comment

Regular Expressions in 30 Lines of C

I recently saw a pointer to a nice article by Brian Kernighan that describes some beautiful code written by Rob Pike for their book The Practice of Programming. As an example of the power of notation, they wanted to show a simple implementation of regular expression matching. They couldn’t use one of the existing implementations because they were too long so Pike sat down for an hour or two and whipped out a 30-line version in C.

In the article, A Regular Expression Matcher, Kernighan explains why he thinks Pike’s creation is “beautiful code.” It’s compact, clear, elegant and implements a simple example of a real tool. If you know C or can read it, you should definitely take a look at Kernighan’s article.

If, after reading the article, you’d like to know a bit more about how regular expressions are implemented, you should take a look at Russ Cox’s posts on the subject. The first two posts, in particular discuss some of the theory and show how to implement efficient algorithms. Efficiency can be important in certain edge cases where the implementations in Perl and many other popular languages can take exponential time. Compare that with Ken Thompson’s original implementation for the QED editor from the 60s. Thompson’s version is literally a million times faster than Perl’s for one pathological regular expression and even faster for others. You can read all about that and why Thompson’s version performs so much better in Cox’s first post. The second post has a virtual machine implementation that more or less duplicates Thompson’s QED algorithm that generated native code on the fly for the matcher.

Posted in General | Tagged , | Leave a comment

Dark-Mode vs. Light-Mode Again

You’d think this would be dead horse by now but we always have fun with it when I post on the issue so here’s another episode. Via Kontra we have an article by Raluca Budiu on whether light-mode or dark-mode is better. The article is a review of the pertinent research, which turns out to be more extensive than you might think.

The really short TL;DR is that it depends. The slightly longer TL;DR is that for people with normal vision or who are corrected to normal vision, light-mode is easier to read and read accurately than dark mode. If, on the other hand, you’re a person with a visual impairment, dark-mode might be easier on your eyes.

But wait. There’s more. It turns out that reading a large amount of text in light-mode over a long period of time may lead to myopia. That’s not too surprising since myopia has historically been associated with those with more education and with prolific readers. Thus, while dark-mode may be harder to read, over time light-mode may lead to vision problems. On the other hand, for most Irreal readers I’d wager it doesn’t make much difference because they’re probably prolific readers on and off the computer screen.

So far as I can tell, the answer is the same as it was before. Use whatever is most comfortable for you to read or whatever you think is cool. It probably doesn’t make any real difference. Read Budiu’s article and decide for yourself.

Posted in General | Tagged | Leave a comment

Emacs Variables

Emacs variables are at once both easier and more difficult than in other languages. On the one hand, Emacs variables are typeless so you can put whatever you like in them and even use the same variable to hold different types at different times. Whether this is a good or bad idea is a religious issue and one I don’t want to litigate here.

On the other hand, Emacs variables can have differing scoping rules that can seem arcane and confusing, especially if you’re used to “normal” languages. The situation is more complicated than in other Lisps because Elisp also has buffer-local-variables and custom-variables with their own scopes and setting rules.

Over at (with-emacs, Clemens Radermacher has a post that gives a nice introduction to Elisp variables. It’s the first in a series that Radermacher is planning on Elisp fundamentals that he is aiming at beginners. One of the hardest things for Lisp n00bs to grasp is the difference between lexical and dynamic scoping. Dynamic variables are (much) more than just global variables and can have some surprising behaviors. As Radermacher says, the situation is exacerbated with Elisp because, for historical reasons, dynamic variables are the default and it’s only recently that lexical variables have been added. Even with their official introduction, lexical variables require some special handling. Radermacher does a pretty job of explaining all this so if you’re new to Elisp, the post is worth reading to help get you started.

Update [2020-02-16 Sun 13:25]: Fixed link to Radermacher’s post.

Posted in General | Tagged | Leave a comment

When Will They Ever Learn?

Jacob Eisenstein is wondering at the madness that has overtaken the academic world. He wonders why in the world they are depending on someone else’s computer and SaaS to do one of their most important jobs: writing and publishing papers.

For context, the ICML is the International Conference on Machine Learning and the “ICML deadline” refers to last date for submitting papers to the 2020 conference. Eisenstein’s question is well taken. These are computer scientists and using tools like Emacs and Git is certainly within their skill set. Instead they chose to depend on someone else’s computer and software, which inconveniently became inaccessible just prior to the submission date of one of their major conferences.

Most disturbing, though, is the response. I’m sure it’s true that Overleaf is great for collaboration and at least they’re writing in LaTeX—instead of the monstrosity that must not be named—but (1) we’re not talking about social and political scientists here; we’re talking about computer scientists and (2) it’s simply not true that people in the “soft” sciences can’t learn Emacs and Git. Irreal often publishes stories about people in the liberal arts and social sciences doing exactly that.

None of this is to say that computer scientists, let alone social or political scientists, must write in Emacs or collaborate through Git. The point is what it always is when I’m on this particular rant: if you’re committing writing that you care about to a third party for processing and safekeeping, you’re asking for trouble. In this case, the trouble probably wasn’t too severe but as I’ve argued elsewhere, it could have been. The answer is also the same as it always is: use open-source/open-standards software on a computer you control. Anything else is reckless.

Posted in General | Tagged , | Leave a comment

Org 9.3.6

Bastien lets us know that Org 9.3.6 has been released:

It’s another bug release but the Org 9.4 with new features is coming soon.

Posted in General | Tagged , | Leave a comment

How To Start a Common Lisp Project

As I mentioned the other day, I haven’t been using Common Lisp much lately so I was a little rusty when I wrote my A Palindrome Predicate Coda post. It’s not that I forgot the Lisp itself, that’s sufficiently like Elisp, which I use all the time, that it’s easy to move between them. The problem is all the machinery you need to start a Common Lisp project: inscrutable things like ASDF and all that goes with it. It’s not that it’s hard, it’s just fussy and easy to forget the details if you don’t use it all the time.

As far as ASDF and dealing with libraries goes, Zach Beane’s Quicklisp goes a long way towards hiding all the complexity. If you’re writing in Common Lisp and not using Quicklisp, you’re working too hard. Beane has another package, Quickproject, that takes care of getting a Lisp project started by providing a template for the project. It’s also very nice and I use it whenever I’m starting a new CL project.

Baggers (Chris Bagley) has an excellent short video on using Quickproject to start a new project. The video is from 2013 but it’s still accurate and useful. Baggers walks you through loading Quickproject—with Quicklisp, of course—if you don’t already have it loaded and then making a trivial project. He also shows one of his real projects so you can see a more complex example.

The video is only 6 minutes, 37 seconds so it’s easy to find time for it. If, like me, you haven’t been using Common Lisp regularly and need a refresher on getting started, it’s 6 and a half minutes well spent.

Posted in General | Tagged , | Leave a comment

Emacs As a Terminal IDE

Palmer Cluff has an interesting post that makes the case for Emacs as a terminal-based IDE. We usually think of IDEs as having a GUI, lots of buttons and menus and of being mouse intensive. Cluff says it doesn’t have to be that way and that Emacs—even in terminal mode—can be a perfectly fine IDE.

His post discusses some of the packages that you’ll need to realize this and at the end he warns us to be ready to spend some time configuring our Emacs to make it the way we want it. Some people are put off by that, I guess, but I think of it as an enjoyable exercise in getting things just the way I want them. The key is that it’s an ongoing process not something that requires you to stop what you’re doing and devote a large block of time to configuring Emacs. I’ve been using Emacs for about 12 years and I’m still tweaking my environment regularly.

Cluff doesn’t make—or try to make—the case that you should prefer terminal Emacs over the GUI version. He merely says that sometimes—when you’re logged into a remote machine, say—it makes sense to use the lighter weight terminal version. Those of us who work with fast and reliable networks are incline to say, “Bah! Just use tramp.” but sometimes we’re using a slow network and the GUI version is just too painful. In those cases, it makes sense to SSH into the remote host and use a terminal Emacs, especially for small tweaks to a large file.

In any event, you’ll probably enjoy reading how Cluff gets his terminal Emacs as close as possible to an IDE.

Posted in General | Tagged | Leave a comment

Bastien’s Org-mode Tricks

If you follow the Emacs scene, you’ve probably seen some references to Bastien Guerry’s post on Org-mode Features You May Not Know. There’s been several tweets about it and, of course, Sacha covered it in her Weekly Emacs News. If you haven’t already seen it and you’re an Org user you should definitely take a look. There are a lot of useful tips that, as Guerry says, you may not know.

It doesn’t make any sense for me to repeat his list of tips but I do want to mention three that I found especially useful. Two of them I didn’t know before so I found them especially helpful. The first is that if you have speed keys enabled (setq org-use-speed-commands t), and the cursor is at the beginning of a headline, you can narrow to the headline’s subtree by typing s. I’ve already used this a couple of times and it really is useful, especially when you’re dealing with headlines that have nearly identical data.

The second tip I didn’t know about was applying filters to the agenda. If you have the an agenda up and want to look at only certain entries—say to save them to another file—you can type = and a regular expression to see only those entries that satisfy the regex. Another = or a | clears the filter.

Finally, there’s timestamped lists. I first learned about this in one of Rainer König’s videos in his OrgMode tutorial series. The idea is that you can make a list with each entry having a relative timestamp. That’s perfect for taking notes about a lecture or video where you want to refer to specific parts of the lecture or video. You start the list with Ctrl+c Ctrl+x - and new entries with the usual Meta+Return.

There are several other use tips in Guerry’s post so be sure to check it out if you’re an Org user. Some you may have no use for, some you may already know, but others may be both new and useful to you. Definitely recommended.

Posted in General | Tagged , | Leave a comment