Why I love Common Lisp and hate Java

“Common what?” is a common reply I get when I mention Common Lisp.
Perhaps rightly so, since Common Lisp is not all that common these days.

Developed in the sixties, it is one of the oldest programming
languages out there. In its heydays it was used mostly for Artificial
Intelligence research at MIT, Stanford, Carnegie Mellon and the
like, and therefore has a lingering association with AI. People not in
AI shy away from Lisp. Common Lisp is a powerful and versatile
programming language that can and should be used more often in other
paradigms. It saddens me to see that Common Lisp does not even make the Top 25 most popular languages on Github.

A year and a half ago, a dear friend of mine send me this link.
It changed the course of my life, although I shouldn’t extrapolate too
far into the future. That was the first time I ever heard of Lisp and it
hasn’t stopped enthralling me. After reading a couple of Paul Graham’s greatessays,
my curiosity forced me to spend the last year full-time learning and
hacking away in Common Lisp. Aren’t those claims kind of bold? I had to
find out. I am still new to Common Lisp but I love it enough to blog
about it.

At university I was spoon-fed Java. Nobody likes to be spoon-fed. My
degree (Computer Science & Economics) was about applying IT to
business problems and I guess ubiquity was their guiding star. Not
unwise to prepare not independent-thinking students for a job as a
software engineer in a large corporation, but since the program was
designed for students with an interest in applying IT applications to
solve business problems, teaching Java killed it.. quite literally. Of
course basic programming skills are essential to the curriculum, but why
Java? It’s stressful!

About a half of my classmates dropped out after one year, because
they said they didn’t like the programming part. That number rose in the
subsequent years and they cancelled the program completely when I
graduated. A sad ending for what I thought was a great program (except
for the Java part).

Lispers like to pick on Java. It makes sense, because Common Lisp has
everything that Java lacks. Common Lisp makes programming fun again. I
can’t make direct comparisons with other languages, since I don’t know
them well enough. But as far as I know, Lisp’s strengths are unique. You
should look into it if you tend to spend 70% of your time in the
test-debug-test cycle, 20% of your time writing unnecessary code and
remain only 10% productive.

People say Common Lisp is difficult to learn, but I had more trouble
learning Java. My first few spoons of Java were to memorize “public
static void main(String args[])”, before I could start playing with some
code. Oh and I forgot, you have to declare your class first. What is a
class, and why so many lines, just to produce a simple “Hello World”?
Programming sucks!

That’s right. Just type that in the REPL and Common Lisp will return
“Hello World”. As simple as it should be. REPL is the Read-Eval-Print
loop that Java is missing. The REPL allows for interactive programming
in a way that will keep you “wired in” as you hack and debug. You are in
a constant conversation with your software. Compare talking on the
phone versus texting when you’re trying to tell your friend about Common
Lisp.

Beside the REPL, another impressive feat of Common Lisp is
meta-programming. You can write software to write software. Say what?
Yeah, that was my initial reaction too, but Common Lisp’s macro system
allows you to write functions that return code snippets. It completely
redefines the word. Or more accurately, re-redefines, since Lisp is much
older than MS Office, which is what most people associate macros with,
sadly.

Claims like these have been made all over the Internet. But for a
skeptic like myself — who spent 4 months intensively practicing Tai-Chi
in Beijing, just to confirm the existence of “qi”
— I just had to try it for myself. “I cannot tell you what qi feels
like, just like I cannot tell you what something tastes like. You have
to try it for yourself,” my master told me.

When I was writing my thesis on a topic related to the Vehicle Routing Problem,
I was forced to use Java. I was never given any choice — or the
illusion of it. I spent 80% of my time on anything but developing my
ideas into prototype software. I recently re-wrote the library in Common
Lisp and released it open-source.
I’ve been working on it just over a month, and I did so with a big
smile. I couldn’t bother counting the number of lines, but to give you
an idea, my Java source code was 500.4 kb versus 78.8 kb in Common Lisp. The Java source code is not disclosed — it’s too embarrassing.

For people in the Operations Research industry — broadly trained
mathematicians with a knack for applying their skills in practice, who
lack the training, patience and passion for the nitty-gritty of Computer
Science — Common Lisp is the answer. Prototyping to test an idea or
algorithm — to get quick results for your publication if you will —
would not and should not have to incur the overhead of “researching”.
Common Lisp allows you to focus on what OR people do best; designing
that algorithm.

Just like I thought the all-you-can-eat sushi in Rotterdam was good; a complete paradigm shift when I got to Hong Kong.