To us, here and now, it appears thus.

rants, ramblings and other things that make life worth living…

Why Lisp?

with 9 comments

Warning : This is a rant, so if you are in here for erudition, then you must be looking somewhere else…

I have been mucking around python for sometime (2 years to be precise) and I am almost confident in saying that I am a pretty good python programmer. I took one look at lisp (scheme rather) a couple of years back, and chose python then. I do not regret that choice.

In the past two years, I’ve looked at a lot of languages (including ruby) and nothing took my fascination as much as python did. As every C/C++ programmer I am annoyed by the indendation rules. I know those rules make my code look more readable, infact I indent any of my code like that with a new level for every block. I did that with C more than 6 years before I was doing that with python. With python its been more of a landmark-coupon effect with me. Its like, I know I will spend this 1000 bucks at my nearest landmark, but I just hate it when people give me a landmark-coupon for the same 1000 bucks as prize money. Its a bit irrational, but thats how I am. Anyhow, as I said no other language took my fascination, untill I came across Lisp. Lisp was a mind-blowing piece of computer science. If you are in CS, and haven’t taken a look at lisp yet, stop reading this right now and go here.

A few months back, I was commisioned to do a project for a lab in bangalore. After extensive internal discussions with the people involved we finally settled on python. We had debated about lisp then, and since the lead din’t feel lisp implementations were either not “free enough” or not “mature enough”, I had to give up, and now, this where the actual rant starts. Every moment I was running into some thing that python din’t allow me to do in a easy way, I was thinking of “now, if it were lisp…..”. Every time, my list comprehensions grew to more than one line, and started looking plain ugly I wished I had “loop” there. But these were minor annoyances, I got most of the power of loop with generators + side effects in python for all my needs. And I went on hacking and completed the project. The lead was impressed. However, she also asked me any good reasons where I could have used lisp here. I had plenty, but nothing impressive enough then.

But, now in retrospect, I realised the biggest need where lisp would have fit in. True Multi-Methods and a bit of macro-magic. The project invovled extensibility of classes at runtime, i.e I needed to create dispatch handlers at run-time. In python I ended up creating my sweet own version of multiple-dispatch, based on string messages and “function objects” (thats what Guido calls closures). I’m no expert on design patterns, but I guess they have a quirkily named pattern for that too. Maybe I built lets say 25% of the functionality of CLOS. Now, if I had lisp, I could have done with 25% less code. Infact, add a bit of macro-magic to what I did, and probably I could have done with 50% less code. (and probably, since its 50% less work for them, I would never have been hired).

Now, about the macro-magic I was talking about. It would have also helped the users of my code. Since it is a framework, rather than an end product in itself, and hence users are mainly programmers, but from more mathematical and scientific backgrounds, who care less about “design patterns” and more about getting “my experiment over with”. Also, it would have helped me save millions of cuts/paste and arduous editing, which would be way better done with a macro. Many people seem to think that using lisp macro’s are a maintainabilty issue. The basic thing here to understand is that, as your abstractions get better, your ability to look at the code and understand it just like that decreases, but the benifit there being, working with a code is such a breeze. So, there is slight maintainability issue there, but thats no different from highly OO code. The most common complaint you see with anyone doing java is the complexity of the frameworks. With a million classes, each having a million functions, doing very similar things. Ruby solves the problem with a compromise of a solution – mixins, but its just a compromise. Interestingly ruby also solved my previous problem with keeping classes open. That shows, that I should probably take another look at ruby, but now I am hooked to lisp.

And, now the downside to lisp? No, there is nothing wrong with Lisp, the language, its pretty asymptotic to the “prefect” line. My gripe is with the community. I have a typical newbie problem with python, I can probably find more newbies having the same problem and a google search gives me the solution. Python is batteries included, Lisp is not. When I want to handle a http-get in python I simply think of urllib, and in Lisp? Its not like there aren’t libraries out there, but just lots of them, and not all are really well maintained. and probably wouldn’t work on every implementation. And c.l.l is one of the easiest places to get labelled a “troll”.

And in fact, I have a hypothesis why that happens. The problem with complete newbies is that they start from a C/C++ background, and come to lisp. And then they ask really really stupid questions. (even I had some of those, but just that I was smart enough to ask it too google). And c.l.l has one of the highest density of smart people around. They might be small in number, but they are possibily one of the smartest groups online, and smart people can’t stand stupid questions, whereas newbies can’t do without them. The “be good to the noob” mindset is comming more often these days into c.l.l, but it needs to improve a lot.

And, then there is the classic chicken and egg peer issue. There aren’t that many lisp programmers around and I really can’t work on lisp, except for my own stuff. Its easier to find python programmers, heck even ruby programmers seem to be more in number than lispers. So, if I do end up writing lisp code, Its hard for me to get it peer reviewed, and even worse get a team member to work on with it.

Hmm, thats with the rant I guess, till later..
Signing Off,
Vishnu Vyas


Written by vishnuvyas

December 4, 2005 at 7:29 pm

9 Responses

Subscribe to comments with RSS.

  1. i just chked out the link on the page… am a novice regarding LISP..n looks like a real good intro…(i am not done with the reading yet though…)will post in a coment once i am done..
    gr8t goin!!!

    vamsee jasti

    December 4, 2005 at 8:50 pm

  2. First of all, thanks 4 dinging! I considered sitemeter. Will add some more fundo plugins later, but “dinging” is still necessary coz i can know who is reading and don’t have to count my own hits! Anyway thanks for the suggestion.


    December 5, 2005 at 3:03 pm

  3. vamsee.. there is a whole bunch of resources to learn common lisp online. PCL is just a starter.

    Vishnu Vyas

    December 5, 2005 at 4:45 pm

  4. Interestingly ruby also solved my previous problem with keeping classes open. That shows, that I should probably take another look at ruby, but now I am hooked to lisp.

    Maybe. If you like Lisp, I’m not sure what Ruby might offer. It seems that when people advocate Ruby over some other language, they often end up describing features that are borrowed from Lisp. (I don’t think I’ve ever read a discussion arguing the merits of Ruby over Lisp; usually it’s Ruby vs [Perl|Java|Python|PHP])

    But I’d be interested in reading a comparison of Lisp and Ruby if you decide to give Ruby a whirl.


    January 2, 2006 at 10:13 pm

  5. Here’s a reason for Ruby: it’s more concise. Look at reading a file and doing something with it line by line in Common Lisp versus Ruby.

    The main thing that turns me on about Lisp is macros. Ruby blocks can get you some of the way there.

    The free Common Lisp implementations are missing functionality unless you are running Linux and choose SBCL, although there is work being done on the Windows port of SBCL.

    You also mention the community. Some folks in the Common Lisp community have a major case of head-in-the-sand syndrome and an extra helping of arrogance. You have to realize that a lot of these guys think they have found THE answer and all of their explanations are falling on deaf ears.

    Don’t just limit yourself to Common Lisp. Common Lisp is one of the uglier Lisps out there. Don’t foget about Scheme (specifically PLT–they’ve got their stuff together), and Haskell.


    January 2, 2006 at 11:14 pm

  6. Steve .

    I am fortunate enough to use sbcl and linux, so i have almost everything I need from a lisp implementation. however, I still can’t use lisp anywhere in production code, just because of a simple maintainability issue, “not enough lisp programmers”…

    And about the community, there is an ongoing effort to make lisp newbie friendly called cl-gardners project.

    And regarding scheme, I like what the guys at plt guys have done, however I am using more of guile, or libguile rather, for any scheming that i am involved in (part of a pet project actually..).


    January 3, 2006 at 3:50 pm

  7. […] 3 January 2006 … and smart people can’t stand stupid questions, whereas newbies can’t do without them. Vishnu Vyas: Why Lisp? […]

    BrittaBlog »

    January 3, 2006 at 10:20 pm

  8. Hi, Vishnu!

    Are you aware of our Yahoo! Group?
    It’s here:

    I am going to invite Lispers to my flat to talk about Lisp sometime in May.


    Thomas Elam

    May 3, 2006 at 7:13 am

  9. Thomas,

    Yes, I’ve seen that somewhere before, but unfortunately I am in chennai! guess I can’t make it to that talk after all.

    May be you should start thinking about podcasts.


    May 3, 2006 at 7:52 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: