Lisp... well, Scheme

9 AM August 23, 2005

After playing around with Logo for a week or so, I decided to jump in and learn Lisp. Logo, with its lists and its functional style, reminded me of Lisp, so I wasn't surprised to learn that "Logo ... is a dialect of Lisp."

Over the past two years I've been increasingly fascinated by the high praise heaped upon Lisp by many leading programmers, and have watched with interest as others dip their toes in the Lisp pond. All in all, it just seemed like a good time to see what the fuss is about.

Pick a Lisp

A bit of Googling and clicking later, I decided that Scheme, rather than Common Lisp, is the better option for someone whose main aim is to learn Lisp. The next step was to pick a Scheme implementation, and I downloaded DrScheme, because it had an IDE, and came with an online book called "Teach Yourself Scheme in Fixnum Days".

Parentheses

My main memory of university Lisp is counting parentheses. I had to spend hours counting each and every one - back and forth, up and down - to make sure they matched, and matched in the way the program needed them to. I was very happy to find that the DrScheme IDE counted parentheses for me, highlighting the matching parenthesis and everything in between, each time I cursor over one. It has a helpful code indenter too. After just a few hours, I'm not so worried by the little curvy things any more.1

Opening the box

The main DrScheme IDE window has a file edit area at the top, and a REPL area at the bottom. You type your program in the top window, click the "run" button and watch the results come out the bottom. Pretty easy. You can call up a help window to access some pretty comprehensive documentation, including two books - "Teach Yourself Scheme", mentioned above, and "How to Design Programs", a basic computing science text.

Primarily built as a teaching environment, DrScheme comes with plenty of fun bits. On discovering the included turtle graphics library, I immediately set about recreating every Logo program I have ever written. It brought a smile to my face.

Scheme is not object oriented in the sense that Smalltalk or Java is object oriented; the Scheme specification does not mandate OO constructs like class or method definitions. DrScheme, on the other hand, comes with two implementations of objects and classes, one of which is a standard library while the other is part of an extension library called "Swindle", and claims some compatability with CLOS. The Teach Yourself Scheme book suggests a third way. I'm currently using the standard libary OO, and it's working just fine.

DrScheme also includes an OpenGL API that is interesting to tinker with, even if it is a little buggy.

The only gripe I have with DrScheme is that some implementation specific features are too poorly documented for me to use them properly. The upcoming book "How to use Scheme" might remedy the situation.

Choice is the Lisp mantra

To this programmer, the striking thing about Lisp is the wide range of choices at almost every step along the way. The only things that aren't optional are parentheses.^2^ While choice has its downsides, from a learning perspective I greatly appreciate seeing multiple implementations of the same basic ideas.

In my next Lisp post, I'll explain how I'm using Lisp to clean up my lounge room.


1My experience with parentheses in Scheme is similar to my experience with indenting in Python, in that I initially I found it hard to follow the code structure, but learned quickly enough.

2Although, if Logo really is a dialect of Lisp, then parentheses are optional too.

By alang | # | Comments (1)
(Posted to Software Development and javablogs)

Comments

At 12:55, 23 Aug 2005 Brian McCallister wrote:

I like PLT a lot, but have found I much prefer the command line mzscheme repl to the gui one. The option for readline support (via rlwrap in my case) makes working much much easier =)

Bonne chance!

http://www.scheme.com/tspl3/

-Brian

(#)

Add Comment




(Not displayed)






(Leave blank line between paragraphs. URLs converted to links. HTML stripped. Indented source code will be formatted with <pre> tags.)




© 2003-2006 Alan Green