Every good Javascripter needs to Lisp a little

Today I found this very good discussion of the Lisp programming language. Everyone who writes, or aims to write, any fair amount of Javascript ought to learn at least the basics of Lisp. One could say that Lisp’s syntax is perhaps too simplified (the parentheses make me crazy) but the conceptual lessons to be learned from Lisp are of inestimable value to anyone who hopes to use Javascript to its fullest.

As Crockford says, Javascript is “Lisp in C’s Clothing.” Observe:

(function(foo,tags) {
  var fn=function(tagName) {
    return function() { alert(foo.tagName+" "+tagName); };
  };
  var a=foo.getElementsByTagName(tags)[0];
  if(a) a.onclick=fn(a.tagName);
})(document.body,"a");

If you find that code structures like this (or the concept of how to do private member variables in Javascript) are hard for you to get wrap your brain around, then you need to learn some Lisp. Think of it like a boxer running a few laps.

One Response to “Every good Javascripter needs to Lisp a little”

  1. On February 4th, 2007 at 19:03:26, The Unfraggable Bulk : Common Lisp Said:

    [...] The last piece of the puzzle came because of javascript. I *love* fooling around with javascript. One thing I especially like is the lambda-style function calls that you can do in it. After reading this post on Isaac Schlueter’s blog I knew I needed to find some way to learn it. [...]

Leave a Reply

Comments are moderated like crazy using a variety of plugins. There is a very high likelihood that your comment won't show up right away, especially if you have never commented here before, but it was not deleted.

Please be patient, and do not post your comment more than once. It will show up once it is approved.

You must be logged in to post a comment.