Does Elisp Suck?

One of the links from the CategoryCode page that I wrote about yesterday is the Why Does Elisp Suck page. The idea is to give people a place to be grumpy about Elisp. My first thought was that, really, Elisp doesn’t suck—it’s a pretty nice language. I’d like to explore this question a bit more.

The answers to the “Why does Elisp suck?” question fall into two classes: the silly and the substantive. The silly answers are “because it’s not Scheme”, or “because it’s not Common Lisp”, or “because it’s not X” for your favorite language X. Are there better Lisps than Elisp? Of course. I’d argue that Scheme and Common Lisp are both better Lisps but that doesn’t mean Elisp sucks. If your X is something like Python or Ruby I’d wager that you aren’t really comfortable in Lisp but you’re certainly entitled to your opinion. On the other hand, preferring Python or Ruby or whatever also doesn’t mean Elisp sucks. In short, the fact that you’d rather code in a language other than Elisp doesn’t have very much to say about Elisp.

Of the substantive answers, only 3 are really of any concern to me. First and foremost is the lack of lexical scoping. That’s fixed (for certain values of fixed) in Emacs 24. The second problem is the lack of tail call elimination. Technically, Common Lisp doesn’t have this either—in the sense that it’s not in the standard—but as a practical matter all serious implementations of CL do eliminate tail calls. This matters to me because it enables a style of iteration that I prefer: see my rpl function for instance. Finally, there is no threading or concurrency. This bothers me less than the first two but it does mean that packages like gnus can slow things down.

Some of the other substantive problems with Elisp are no object system (a feature not a bug in my opinion), no module system (a pain because of name collisions but I can live with it), clumsy regular expressions (especially if what you really want are Perl regexps), and the API sucks.

Someone also noted that the Elisp implementation is slow. That’s true, I guess, but doesn’t really speak to whether or not Elisp sucks. It would be nice if things were snappier but on modern machines it seems fast enough to me. I’d guess that font locking and things like that have more to do with performance problems than the Lisp engine.

All-in-all, I find Elisp to be a comfortable language to write in. Not as powerful as Common Lisp and not as well designed as Scheme but still nice. What does everyone else think? Is Elisp something you put up with or do you like the language? I’d be surprised if very many people said it was their favorite language but I’d also be surprised if many Elisp users really do think the language sucks.

Posted in Programming | Tagged , | 12 Comments

Learning Elisp Idioms

I’ve said before that Emacs Lisp is pretty much like any other Lisp except for its library, which is specialized for editing tasks. One of the things I like about Xah Lee’s Emacs Lisp Tutorial is that it doesn’t concern itself too much with Lisp itself but presents Elisp use cases and idioms. If you already know a little of any Lisp, then Xah’s tutorial is a good place to go to come up to speed with Elisp.

Today, I found another good resource: The CategoryCode page on the Emacs Wiki. They’ve got a long list of articles that show you how to do various tasks in Emacs Lisp. One page, the Elisp Cookbook, is particularly helpful. It contains a collection of code snippets for many common chores. Other articles are more specialized; they have, for example, an article on a Password Generator. Some of the articles are quite detailed while others merely describe a library that’s good for doing some task or another.

If you’re new to Elisp but have a basic knowledge of Lisp, I’d start with Xah Lee’s tutorial and then try some of the articles on the CategoryCode page. Of course, the definitive source is the GNU Emacs Lisp Reference Manual, which is also available in the built-in documentation. If you need to know the particulars about some function or slightly broader area, that’s the place to look but I don’t find it particularly useful for learning the ins and outs of Elisp. The other outstanding resource you have for that is Emacs itself. You might try reading simple.el, for example, to see how some of the simple editing functions are implemented. It will give you a good feel for Elisp idioms.

Posted in Programming | Tagged , | Leave a comment

TSA: So Incompetent It Surprises Even Me

We here at Irreal, like almost everyone else in the world, are not fans of the Transportation Security Administration. Their ability to combine heavy-handedness with incompetence exceeds even that of the typical DMV office. Still, the sheer assclownery of their latest exploits is so astounding that even I wouldn’t have believed it possible.

I couldn’t begin to give this story justice so head on over to Schneier on Security for the sorry tale. As Schneier says, “I don’t even know where to begin.” The link at the top of Schneier’s post goes to a CNN report that gives a few more details.

Posted in General | Tagged | Leave a comment

Digital Lysenkoism

Cory Doctorow has a splendid article in Publishers Weekly about the futility of DRM in the publishing industry. In it he compares the industry’s belief in DRM to the disastrous beliefs of Trofim Lysenko, the Stalin-era Russian pseudo-geneticist, that led to mass starvation in the Soviet Union. In some sense, there’s not much point in telling this to Irreal readers: they all know the arguments and despise DRM already. Still it’s a good article and points out some interesting facts.

Most of the line staff at the publishers know, like Stalin-era geneticists knew about Lysenkoism, that DRM won’t work and that it’s really hurting the publishing industry while failing to do anything to stop illegal copying. The problem is that their leaders, like Stalin, do believe in it and refuse to consider the possibility that their faith in DRM might be misplaced.

Doctorow tells the story of how one publisher is planning on sending all its ARCs out as encrypted PDFs. ARCs are the Advanced Reader Copies that publishers send to reviewers before the book is actually published in the hopes of getting a good review. As Doctorow remarks, most reviewers get far more requests for a review than they can honor (Doctorow says 100-to-1 in his case) and that the idea a reviewer would put up with the annoyance of dealing with a “book” that couldn’t be loaded into whatever e-reader he happens to use or couldn’t be conveniently read on a plane, say, is wishful thinking. Instead, those crippled PDFs will be ignored and the publisher and author will miss out on advanced publicity.

Again, there’s nothing in the article that we don’t all know but it’s a good take on the problem with some interesting inside information. Well worth a read.

Posted in General | Leave a comment

Fontifying Code Buffers In Emacs Org Mode

I just learned a nice trick from the Org Mode Mailing List. By default code blocks in Org-mode buffers are colored gray and don’t show the fontification the way it does in a normal programming buffer. But if you add

(setq org-src-fontify-natively t)

to your .emacs or init.el file you get normal fontification for whatever language you’re using. This is especially nice when you open an editing buffer with【Ctrl+c '】 to insert code into the #+begin_src ... #+end_src area.

Posted in General | Tagged , | Leave a comment

TechCrunch: Amazon Is Out To Kill Publishers

Regular Irreal readers know that publishing and its travails are an enduring interest of mine. As I’ve said many times, I like publishers and wish them well but at the same time I recognize that they are making the same tragic mistakes that the music industry did. Unfortunately, they are less well positioned to survive them.

Case in point: TechCrunch has an article claiming that Amazon is purposely killing off rival publishers by giving authors huge advances and very favorable deals with the intention of driving the traditional publishers into bankruptcy. Although it’s not well known, Amazon is into publishing in a big way and has several of its own imprints. TechCrunch goes on to say that Amazon enjoys a number of benefits such as inexpensive print-on-demand facilities and, of course, the Kindle installed base.

All-in-all, the TechCrunch article is pretty depressing not only for the publishers but for those of us who think it a good thing for there to be more than one publishing outlet. It is, I think, dangerous to have only one source of published works but that’s the direction we’re headed in. I hope the traditional publishers can adjust to the times and improve their prospects but I have to say that I am less hopeful than ever.

Posted in General | Leave a comment

Journal Article On Org Mode

The Journal of Statistical Software has a nice paper by Carsten Dominik (the creator of Org mode), Eric Schulte, Dan Davison, and Thomas Dye about Org Mode and its use in Literate Programming and Reproducible Research.

I really like the idea of reproducible research and this paper is an excellent example of it. The authors make available, as supplementary material, everything you need to reproduce the paper, it diagrams, and examples. They also have another example in the paper of reproducible research that makes use of large external sources of data.

Although the paper is published in an academic journal (and one concerning statistics, at that) it is very approachable and anyone interested in learning some of the power of Org mode should give it a read. They cover using Babel to make calculations whose results appear in the paper automatically. So although the code blocks do not (necessarily) appear in the finished paper they are part of the “source code” of the paper and available for anyone interested in verifying the results. Not all of us are generating papers that others might want to verify but the facility is still useful to us. For example, all the diagrams and calculations that appear in my blog posts were generated with Babel and are part of the Org file for the post so I can reproduce them at will. The only exceptions to this are the occasional screen shots that I sometimes include in a post.

I’ve never been able to warm up to Literate Programming but for those who have, the paper shows how Org mode implements it using the Noweb notation. That’s very nice because it’s language agnostic—you can use it with any language. You can discuss your program by presenting code fragments in any convenient (to your exposition) order and then have Org mode export the reassembled code ready for a compiler.

There’s a lot of power in Org mode and I’m always learning new things about it (much like Emacs itself). This paper is a good introduction to some of its features and because the original Org file and supplementary files are available it serves as a laboratory for experimenting with it.

Posted in General | Tagged , | Leave a comment

Emacs Rocks Episode 9 Is Up

Magnar Sveen has another episode of his excellent Emacs Rocks up. In this video he talks about expand-region, an Emacs package that he wrote to help with marking text in an intelligent way. The video is less than 3 minutes so there’s no excuse not to take a look. As with all the Emacs Rocks videos, you won’t be sorry.

Watch the video and if you like what you see, get the code on github.

Posted in General | Tagged | 1 Comment

What Makes Emacs So Great?

Over at The Setup they are featuring Phil Hagelberg who has an especially nice take on what makes Emacs so great. He says that Emacs is as close as you can get on modern systems to the fully dynamic environment of the Lisp Machines of the 80’s. Almost any part of the environment can be changed at runtime without recompiling or restarting.

I think that’s exactly right. There are, I suppose, Emacs users who don’t change anything from the default setup but as Irreal readers know, I have all sorts of customizations to my Emacs and I am not in the least unique in this. One of the nice things about this is that I wrote those customizations using the same mechanisms as the authors of Emacs itself. Hagelberg says, “It’s hard to overstate the benefits of this setup.” It’s something that you get “for free” because when we make extensions to Emacs we’re writing in Lisp and as Doug Hoyte says in Let Over Lambda, “…lisp gives you the same tools available to the people who created your programming environment.”

Hagelberg goes on to say that this reduces the friction of tweaking your environment to such a low level that you’re more willing to experiment and improve things than you would be in a more standard environment. For example, I use OS X and really love it but it’s too hard to make anything other than fairly simple changes to the default behavior and most of those are changes that the system implementors anticipated and provided some way of effecting. I would guess that this ability to customize things is the reason that many Emacs users try to avoid leaving Emacs at all, choosing to read and send mail, use IRC and IM, listen to music, and many other things all from Emacs. Why not? You can pretty much have it anyway you want it.

Posted in General | Tagged , | Leave a comment

Demand Curves By Age

H S Dent has a set of endlessly fascinating demand curves that show the demand for various kinds of consumer goods by the age of the consumer. Many of these are pretty much what you’d expect: demand for bicycles, for example, grows until about age 40 and then drops off to nothing a little after age 80. Still, there’s a lot of surprises.

Children’s clothing (of all sorts) drops off with increasing age as you’d expect but then rises again at a little after age 80. You see this again and again in everything from boys’ underwear to girls uniforms. I have no idea why this is. Oddly, adult clothing doesn’t follow the same pattern: you generally see the expected drop off with increasing age. Not all the curves show an increase to some age and then a decrease. Some rise and fall repeatedly throughout the age span—college tuition is an example of this. Some, like safe deposit box rental and prescription drugs shows a steady increase throughout the age span.

I doubt any of this is of particular importance to the typical Irreal reader but I find the graphs entertaining and in some cases puzzling. It well worth a look—you may be surprised at how interesting they can be.

Posted in General | Leave a comment