Evolving lisp

Paul Graham notes that, “A popular recipe for new programming languages in the past 20 years has been to take the C model of computing and add to it, piecemeal, parts taken from the Lisp model, like runtime typing and garbage collection.” This is what has made Python such a wonderful, elegant, and concise language. Why say with iteration what can be done in one easily readable line with a list comprehension?

This has also kept many imperative languages moving forward. Python may be the most lispy, but there is also Ruby, which conceptually borrows heavily from languages like lisp and Smalltalk. Even Javascript has lambda functions (although in JS they are called function literals), which has made possible powerful libraries such as Prototype.

Few lisps have ever borrowed from imperative languages, though, as if the borrowers have absolutely nothing to offer themselves. A few concepts have made it in. OOP, via CLOS, although OOP is often just extra weight in lisp. Storing functions as data makes much of OOP needless in lisp.

newLisp, a dialect of lisp that uses s-expressions in a high level, interpreted language, has borrowed from imperative languages, and has done an excellent job of maintaining its lispy character despite it. Regex is built into the interpreter and is used in many functions:

(regexp {brown fox$} "the quick brown fox")
(replace {brown fox$} "the quick brown fox" (upper-case $1))

Iterative control structures are built into the interpreter, rather than be implemented through macros. Common Lisp’s LOOP is very powerful but not very idiomatic of lisp and not very elegant to use (in fact, many of those involved in the original development of the language did not like LOOP, feeling that it was not lispy enough). In newLisp, iterators definitely have a lispy feel to them:

(dotimes (i 10) (println i))
(dolist (n '(foo bar baz bat)) (println n))

Other similar looping functions in newLisp are dolist, doargs, and dotree. There are also while, until, unless, and do functions, which all work about as you would imagine in a lisp.

No language will survive in a pure form. Concepts may – s-expressions and lists – but lisp must be willing to evolve on a larger scale. Lisp was built to evolve, so it’s a shame that so few of the people who continue to plough ahead in the language want it to.

Leave a comment | Trackback
Jun 7th, 2007 | Posted in Soap box
Tags: ,
No comments yet.