More Lisp—For Free

   Print.Print
Email.Email weblog link
Blog this.Blog this

Christopher Roach
Nov. 29, 2005 09:28 AM
Permalink

Atom feed for this author. RSS 1.0 feed for this author. RSS 2.0 feed for this author.

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.

Christopher Roach recently graduated with a master's in computer science and currently works in Florida as a software engineer at a government communications corporation.