“Lisp is worth learning for the profound enlightenment experience you will have when you finally get it.” — Eric S. Raymond
Welcome. Today you’ll learn a language from one of programming’s oldest and most unusual families. A language where code is data, where parentheses are pure structure, and where programs can write programs. By the end of this tutorial, you’ll have written your own syntax.
Lisp was born in1958, invented by John McCarthy at MIT. For context: it’s thesecond-oldest high-level language still in use(only Fortran, from 1957, beats it by a year). Python arrived in 1991. JavaScript in 1995. Lisp predates them by more than 30 years and several ideas we now consider “modern” were born there:
For decades, Lisp wasthelanguage of artificial intelligence. In the 70s and 80s there were physical computers designed to run Lisp directly: theLisp Machinesbuilt by Symbolics and LMI. Then came the “AI winter,” funding dried up, and Lisp went from star to cult language.
But interesting ideas don’t die they mutate, that’s part of the beauty of the lisps.
In 1975, Gerald Sussman and Guy Steele createdScheme: a minimalist, elegant, almost mathematical Lisp. Scheme became academia’s favorite language forteachingprogramming (the legendary bookSICPStructure and Interpretation of Computer Programs is written in Scheme).
In 1995, Matthias Felleisen’s group createdPLT Scheme, a Scheme designed for education and programming language research. In 2010 it was renamedRacket, and today it’s much more than a Scheme: it’s alanguage for building languages. Its unofficial motto islanguage-oriented programming: if your problem needs its own language, Racket lets you build one in an afternoon.
InThe Amazing Digital Circus(episode 8, “hjsakldfhl”), when Kinger opens the terminal to try to reset Caine, you can see that Caine (a creative AI built in 1996) is programmed in Lisp. The file is literally namedCaine-core.lisp.
DrRacket has two areas: at the top you write yourdefinitions(your program), and at the bottom you have theREPLfor live experimentation. On the first line of the definitions area, write:
That line tells Racket which language you’re using (remember: Racket is a language factory, so you have to pick one).
If you prefer the terminal: theracketcommand gives you a REPL, andracois the package manager and tooling command.
Everything is(operator argument1 argument2 …). Always. No exceptions.