The alleged verbosity of Lisp

This is a (lightly reformatted) Usenet article I posted to comp.lang.lisp ages ago. Those who don't like Common Lisp often say the language is terribly verbose. I understand why they say that, but it's not actually true...


Bob Shafer wrote:

One of the things I find frustrating, being as I usually program into C or Java, is that expressions are so long-winded. Opening a file for writing seems to take forever, typing-wise.

That's an illusion.

Lisp (with-open-file (f "foo.txt" :direction :output)
)
49 bytes
C FILE * f = fopen("foo.txt", "w");
fclose(f);
45 bytes
Java FileWriter f = new FileWriter("foo.txt");
f.close();
53 bytes

And the Lisp version sticks f in a local scope, and closes the file for you if a non-local exit from that block happens. Adding a level of scope will add another 4 bytes to the C and Java versions. Dealing with non-local exits in C ... hmmmmm. In Java, you need to add a try/finally block.

It's true that the Lisp seems verbose. But in looking at that nasty long function name, you're missing the absence of pointless syntactic nastiness, explicit type declarations, and code to do the Right Thing instead of the Easiest Thing.

As has been pointed out, if you find typing WITH-OPEN-FILE too arduous then a good text editor or development environment (or, in the case of emacs, both at once) can save lots of the typing.