Programming Languages 14 Nov 2006 12:59 pm

defmacro – Writing A Lisp Interpreter In Haskell

defmacro – Writing A Lisp Interpreter In Haskell: “Yet another Haskell one-liner turned into sixteen lines of Java code. In isolation such examples mean little but once you run into them again and again and again you can see an interesting picture start to emerge.”

I love it when people do language comparisons 🙂

(Via Lambda the Ultimate.)

2 Responses to “defmacro – Writing A Lisp Interpreter In Haskell”

  1. on 16 Nov 2006 at 10:02 am 1.Aaron Rhodes said …

    I fail to see why it matters. People make these language comparisons and all, that is wonderful but why does it matter how many lines it took to do something. It may be 1 vs. 16 lines, but I am pretty sure it wasn’t 1 minute vs 16 minutes to write.

  2. on 16 Nov 2006 at 10:27 am 2.Bob said …

    Good question.

    I think it matters for a couple of reasons, but you of course have to put them into perspective. There is no silver bullet.

    First, it’s funny. Whenever people say it took me this many lines to do x in language y, it really depends on whether language y is the best language for activity x. Functional languages are known for how much nicer they are for writing tools like compilers. Particularly, languages like ML and Haskell which were practically invented for such things. Whereas Java is a general purpose programming language and not as nice for writing compilers.

    Second, as someone who is into writing compilers, I want it to be as easy a job to do as possible, both the first time, and every time I have to go back and maintain that code. It’s like sawing logs with a hammer. You can do it, but you will not get as clean or as usable a cut.

    Third, that easiness does convert into time spent writing code, and it may be an order of magnitude or more time difference – depending on the task. I can write the same program in Ruby way faster than in Java. Which is surprising to me given my experience level in each language: I have been writing Java professionally for almost 10 years, and Ruby only on and off for a total of less than a year. Not sure what you would compare this to, perhaps writing math equations in math symbols or in English prose.

    Mostly, I just find it amusing, because as soon as you say it on a blog or out loud, a storm of controversy will swirl into view, obliterating whatever time you saved.

Subscribe to the comments through RSS Feed

Leave a Reply