More Lisp—For Free

by Christopher Roach

In my last post, I covered learning to program with a dialect of Lisp, called Scheme, from resources freely available on the internet from the SICP course at MIT. In this post, I plan to continue this theme by going over a few reasons that I have found for learning Lisp and to offer a few more resources for those of you out there who would like to add Lisp, or Scheme, to their programming repertoire. I want to begin this post by going over some of the advantages Lisp holds for the majority of the programming population—i.e., those of us who will probably never use Lisp professionally.



To start off with, Lisp is a functional programming language (well, ok, not purely functional, but pretty darn close). Now, while there are several reasons for wanting to learn a functional programming language, I'm going to cover just one. The reason for learning a functional language (such as Lisp) that I want to talk about here is the one that I have seen make the most difference to me personally—namely, it makes testing (and, as a side-effect, creating more secure code) easier. I basically picked up Lisp for an AI class I was taking this past Summer, and I immediately fell in love with it. While it can be frustrating to learn, and at times downright impossible, it does eventually reward those who persevere and finally learn to program in Lisp. So, after a couple of failed attempts before this summer, I was pleasantly surprised when I finally found myself starting to grasp the concepts and I was actually able to start writing programs in Lisp. And, to my surprise, in a very short period of time, I was able to write programs faster and more bug-free than in other languages with which I was much more acquainted (e.g., C/C++, C#, and Java).



Now, I've never used Lisp in my professional life, however, I began to notice that some of the habits I picked up while programming in Lisp were creeping into my daily programming and were actually helping me out quite bit. In functional languages, side-effects are "generally" avoided. (I say "generally" here since, to my knowledge at least, some side-effects seem to be unavoidable—such as I/O operations, for instance). For anyone new to the term, a side-effect occurs when the state of your program is changed from within a function (procedure, method...whatever). This happens quite often in normal procedural and OO programming, but in functional programming it is avoided as much as possible. After programming in Lisp for a month or two, I noticed that in my daily life I had begun to avoid side-effects in my programs whenever I found it possible to do so. This allowed me to create programs that were much easier to unit test, since all I had to do was check the function's output to know that it worked correctly. Also, since no undesired changes occurred inside of my functions, my software immediately showed a vast reduction in bugs, not too mention that purely functional code is also immediately thread safe. Being able to test each function as I wrote it, and prove that it worked correctly without exception, meant that my programs would work almost the first time I integrated everything and ran it.



All of sudden everything was working within a try or two (and, sometimes, even on the first try), rather than with several attempts and debug sessions. It was easier to follow the logic of my programs and it became much easier for me to guarantee that changes to my programs in one place would not produce undesired outcomes in others. Suddenly, my learning Lisp was paying off in the real world, and what seemed like just a fun excuse to learn a new language was actually making me more effective in my professional life.



Don't believe me? Perhaps you need more assurance from more creditable sources. Well then, let's take a look at some endorsements from some much more lauded hackers. Eric Raymond, author of "The Cathedral and the Bazaar" and former president of the Open Source Initiative, probably put it best in his essay, "How to Become a Hacker", when he made the following statement:




Lisp is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days, even if you never actually use Lisp itself a lot.




Richard Stallman—creator of GNU Emacs and the GNU C compiler and the founder of the Free Software Foundation and the GNU Project—felt so strongly about the language that he embedded a version of Lisp, called Elisp, into his Emacs text editor making the editor infinitely extensible and is one of the main reasons why a text editor written nearly 30 years ago still enjoys such a large following today.



Finally, Paul Graham, author of "Hackers and Painters" (and one of my own personal role models) is constantly writing on the importance of Lisp as more than just an exercise in acedemia. He believed in the efficacy of the language so much that he has spent several of the past few years creating a much awaited new dialect of the language called Arc. He also bet his very own financial future on the language by using it in his own startup—viaweb. In fact, he goes so far as to attribute much of the success of his startup to his use of Lisp.



So, with the backing of such important people in the programming community, the question is no longer why would you want to learn Lisp, so much as why wouldn't you. Yeah, sure, your boss most likely will not let you use it in your day-to-day tasks, and actually finding a job that does use Lisp (especially one that uses it on a regular basis) is next to impossible, but I think once you get a good grasp of the Lisp language, you'll be happy you decided to learn it. You'll see the benefits in no time in the way your programming evolves and becomes much more bug-free, reliable, maintainable, and fast (both in testing and in creation).



In closing, I hope I've gotten some of you interested in learning Lisp. Before I go though, I wanted to share with you all a few more resources for learning Lisp just in case you should happen to feel so inclined to do so. All of the links to online resources I've included below are free (as in speech). The first two, are actually full texts available free on the internet for download. "On Lisp" is considered to be one of the best texts for learning Lisp, although it is geared more towards programmers already familiar with Lisp (Paul Graham's other book—"ANSI Common Lisp"—targets Lisp newbies, so it may be better to read it first). "Practical Common Lisp" is a great book for introducing you to using Lisp in common programming situations. It's largely a giant tutorial, by the end of which you will have created CD and MP3 databases, a spam filter, and many other fun and useful applications. This is a very good read for anyone wanting to use Lisp as a general purpose everyday language. DrScheme is a fully featured programming environment (including an IDE, debugger, GUI library, and more) for the Scheme dialect of Lisp. It was created at Brown University and is freely available for download on nearly any OS. A nice feature, on OS X, it is an extremely simple install. Finally, the last item in the list is a link to my last post. The reason I've include this one is simply because I'm lazy. In my last post, I included several links to free resources for taking an online class from MIT on programming in Scheme, and I just couldn't be bothered repeating them all here (plus, I'm absolutely shameless, and I'm trying to develop a nice following of repeat readers). In the last post, I included links to an online book, class lectures (both regular downloads and iPod compatible versions), and sample questions and other course materials. If you're truly interested in learning Lisp, check out this post, you'll be happy you did.



Sources on the internet for learning Lisp:





Well, we've finally come to the very end. I hope, after reading this post, that each of you will find yourself with an insatiable desire to learn Lisp. This post, and the one just before it, have concentrated on instilling this desire within you—the reader—and in showcasing some good resources on the internet for satisfying this desire. I've introduced just about all of the resources that I know of for teaching you Lisp for free. Any new posts that I make on Lisp following this one will try to concentrate on actually learning or using the Lisp language rather than just linking to other online resources. So, enjoy the links, have fun learning Lisp, and come back again very soon for some interesting tutorials on programming in Lisp.



Oh, and by the way, if any of you out there are using Lisp in your daily life, personal projects, professional projects, whatever, please, post a comment below giving us some of the juicy details. Feel free to talk about how hard it was, what advantages/disadvantages it provided, and/or provide links to websites about your project (especially those containing interesting source code). I know I would love to find out more about how others are putting the language to use.

See you next time.




Please, feel free to post comments on how you've used Lisp in the past or are currently using Lisp right now.


9 Comments

erikenge
2005-11-29 18:47:50
Common Lisp source code.
If you are looking for source code you'll want to visit both and .


The most recent Common Lisp code I wrote was cl-xmmp (see ) which implements the XMPP protocol and has been tested with jabberd, ejabberd and Google Talk.

eac
2005-11-29 19:40:23
On Lisp not for faint of heart
I would recommend that On Lisp is not only for programmers already familiar with Lisp, it's for programmers who've done at least one largish (n x 10^3 lines, 1 <= n <= 9) project in it. Especially chapters 11-25, and most especially chapters 18-25.
In fact, it recently occurred to me that one excellent way to learn Lisp would be to:
1) Go through SICP.
2) Write some small programs in Common Lisp to learn the differences.
3) Go through chapters 1-6 of On Lisp.
4) Do a large project in Common Lisp with the stuff you learned in chapters 1-6, and with reference help from ANSI Common Lisp.
5) Go through chapters 7-10 of On Lisp.
6) Write some noddy macros.
7) Go through chapters 11-17 of On Lisp, and 18 if you're really gung-ho.
8) Do a large project in Common Lisp, preferably a hard, large project, this time using macros.
9) Go through chapters 18-25 of On Lisp, and feel enlightened.
10) Do another large project in Common Lisp, a hard one, this time using an embedded language specific to your domain.


I didn't do it in quite that order, but I plan to now that I thought of it. I'm more or less on step 7, but can't continue right now because CMU CS is stupid and doesn't use Lisp.

Reedo
2005-11-30 11:21:32
Perl users should check out Higher-Order Perl
Higher-Order Perl is a book about how to do LISPy techniques in Perl. It provides lots of example Perl code that accomplishes real tasks. I don't know that it would be any substitute for learning true LISP or Scheme, but it does throw fuel on the fire for people like Graham who insist that mainstream languages are edging toward where LISP has been all along...
christopher_roach
2005-12-01 07:28:35
More Lisp resources and research links
I received an email containing some really great links for some more online Lisp resources from Pascal Costanza who is currently using Lisp in his research on context-oriented programming at the Vrije Universiteit Brussel, Programming Technology Lab. If you're interested, he's written an article on his experiences with Lisp, which, by the way, also contains a pretty comprehensive list of links to even more Lisp resources. That article can be found here:


Pascal Costanza's Highly Opinionated Guide to Lisp (http://p-cos.net/lisp/guide.html)


He's also been kind enough to share with us a link to his current research where you can download a copy of the software he has been working on (a CLOS extension for context-oriented programming) and try it out for yourself. You can find his main research page here:


Closer Project (http://common-lisp.net/project/closer/contextl.html)

christopher_roach
2005-12-01 07:42:50
Perl users should check out Higher-Order Perl
I definitely agree with your last comment about Graham. I'm finding that, as I learn more about Lisp (a language that has hardly changed in the past 20 years), I notice that many of the features that I love about languages such as Python and Ruby have always been there in Lisp. I am definitely seeing a convergence of most modern languages on Lisp and I believe this trend will continue with future versions of the languages I love as well as with the next generation of programming languages.


By the way, thanks for pointing out the book, I looked it up on the web and it looks pretty interesting--perhaps some reading for me after I finish the SICP classes. If anyone else is interested in the Higer-Order Perl book, the link below will take you to its website:


Higher-Order Perl (http://hop.perl.plover.com/)


Thanks for the comment.

asommer
2005-12-06 06:11:50
Learning LISP
I just want to say great article…it does make me want to go out and learn LISP. Unfortunetly I'm a network admin with almost no programming experience.


I'm currently trying to learn Ruby and using some VBScript to do Windows admin tasks, but I'm wondering if LISP is a good language to try learning first?

christopher_roach
2005-12-06 16:05:04
Learning LISP
Hey, thanks a bunch for the compliment, I'm glad you enjoyed the post.


Now, as for your question--as much as I would love to recommend Lisp as your first language, I just can't bring myself to do so. For one, it is a difficult language to grasp. As I stated in my post, I had made several attempts to learn it before it finally clicked. And, in all honesty, what made it click for me was learning Ruby and Python first. Once I had these two languages under my belt, I was able to more easily grasp many of the concepts found in Lisp.


Another reason to start with a language such as Ruby, Python, or Perl is because you'll find a larger community of support in any of these languages. If you need help or need a library for a particular task, you'll have more success finding it in either of the three languages I just mentioned.


Finally, since you're a network administrator, you're probably looking for a language that's going to help you more in your day-to-day tasks. While Lisp is a very powerful programming language and is much faster than either Python, Ruby, or Perl for most tasks, for common-place scripting tasks, I still turn to Python most of the time. I am also assuming that you're probably interested in working on the web as well? If so, then you can't go wrong with any of the languages I just suggested. Perl has owned the net for years, and with the introduction of frameworks such as Rails (http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html) and TurboGears (http://www.macdevcenter.com/pub/a/mac/2005/11/08/turbogears.html) , Ruby and Python are quickly becoming the go-to languages for web application development.


In conclusion, I think you're on the correct path right now. Ruby is powerful, easy to learn (and use), and has many applications for day-to-day use as well as web development and just about anything else you can throw at it (In other words, Ruby's great as both a general purpose programming language and as an everyday scripting language). Also, if you're looking for a language as powerful as Lisp, Ruby comes pretty close--both Eric Kidd (http://randomhacks.net/articles/2005/12/03/why-ruby-is-an-acceptable-lisp) and Paul Graham (http://www.paulgraham.com/lispfaq1.html) have mentioned this fact in their writings. My advice--learn Ruby first, you'll immediately get a lot of use out of it, then go back and learn Lisp to become a better programmer.


Good luck with all your programming endeavors and thanks for the complimentary comment.


Christopher


P.S.: If you haven't checked them out yet, you may want to take a look at the Pickaxe book (http://www.ruby-doc.org/docs/ProgrammingRuby/) and a few articles I wrote (http://www.oreillynet.com/pub/au/1904) on using Ruby.


newLISPer
2006-02-09 06:23:42
I do most of my day to day scripting in newLISP, a fast, compact, powerful, versatile, easy to learn and enjoyable language with rich libraries and good support. Use it when you would otherwise think of Perl or Python or Ruby. On MacOS X it supports Unicode, is easy to install (on a DMG!), and is, of course, free and open source...
Aron Knifström
2006-06-15 12:55:03
At the university I read some courses with Common Lisp, today I'm testing Scheme and newLisp. I'm collecting my knowledge on my website so check it out.