Unlearning Lisp




Most people have managed to uninstall Lisp but many are still having trouble
unlearning it. This story is well known from programming language folklore
where it is said that "BASIC (and Lisp) pollute your mind and make you a
worse programmer".

There are many interesting examples of this on the web:

http://cs.hubfs.net/forums/thread/2421.aspx
"What am I missing about types?" by DoomChild

In this thread, DoomChild presents the following F# code:

let checkType thing =
match thing with
| bool -> "a bool"
| _::_ -> "a list";;

This is clearly because he grew up in the dynamically-typed Lisp ghetto. He
is trying to do run-time type dispatch but ends up with a function that
always returns "a bool" and can only be applied to lists.

http://curiousprogrammer.wordpress.com/2006/12/22/speed-comparison-plt-scheme-ocaml-and-c/
"Speed comparison: PLT Scheme, Ocaml and C++" by Ian O

Interestingly, Ian is having the opposite problem. His OCaml implementation
of the n-queens problem boxes too much and introduces the unnecessary
run-time checks so typical of Lisp:

let valid_board b =
match b with
Some (Board (_, _)) -> true
| _ -> false;;

Nice to see the pattern matching getting in there though.

http://groups.google.co.uk/group/fa.caml/msg/62b92ec6db3a46dd
"Continuations and consing" by Thomas Fischbacher

In this case, Thomas is a much better versed programmer of statically-typed
languages but he still makes the classic mistake of assuming that a Lisp
optimization carries through to OCaml (we've all done it). Even worse, he
wants to address the non-existent inefficiency using macros (as Juho
Snellman did in my ray tracer benchmark).

Specifically, he asks the reader to choose from these two implementations:

let sum_nums n =
let rec work sum todo =
if todo=0 then sum
else work (sum+todo) (todo-1)
in work 0 n

let sum_nums2 n =
let rec work (sum,todo) =
if todo=0 then sum
else work ((sum+todo),(todo-1))
in work (0,n)

when, in fact, they produce the same code.

A common theme is that these people didn't realise the cost of the
abstractions that Lisp was imposing upon them with regard to performance
and correctness. Did you?

--
Dr Jon D Harrop, Flying Frog Consultancy
The OCaml Journal
http://www.ffconsultancy.com/products/ocaml_journal/?usenet
.



Relevant Pages

  • Re: Unlearning Lisp
    ... This story is well known from programming language folklore ... This is clearly because he grew up in the dynamically-typed Lisp ghetto. ... Thomas is a much better versed programmer of statically-typed ... let rec work sum todo = ...
    (comp.lang.functional)
  • Re: Need more info...
    ... Wispy Lisp:= A Lispy Web-framework ... programmer would code in a unified meta-syntax that subsumes ... This data schema determines the legal ... ;; Client action ...
    (comp.lang.lisp)
  • Re: Lisp or Smalltalk for Specific Suicide Mission (er...Project)?
    ... have never had the GOAL of failure or of being a mediocre programmer. ... Please understand that I have not "condemned the community," nor do I ... follow my long meandering posts. ... When I experienced some aspects of the " Lisp culture" that most would ...
    (comp.lang.lisp)
  • Re: [OT] PostLisp, a language experiment
    ... >>latter method in Lisp, and C and many other languages so that the code ... >>the complexity and number of stack items for each definition. ... I do the same thing with my assembly language code, my Java code, my C++ ... >>useless to any experienced Lisp programmer. ...
    (comp.lang.lisp)
  • Re: "Readable" library for Common Lisp now available!
    ... I've just released a Common Lisp library called "readable". ... Though I'm just a hobbyist Lisp programmer, ... though I have to admit I personally *like* s-expressions. ... to require a good working knowledge of s-expression syntax in Lisp. ...
    (comp.lang.lisp)