The Five Minute Lisp Environment
Do you want to try Lisp? Do you have a Mac? Do you have $10? Then this is the post for you!
(Ok, you don’t need $10 to try Lisp, but this approach is bloody convenient. And it shows off some really cool tools—and no, sadly I’m not making money on any of them.)
- First we’re going to install the fantastic Homebrew, which is an easy way to install UNIX tools on your Mac. To install Homebrew, open Terminal.app and paste in the following command :
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"Now simply hit return and follow the prompts on screen (additional details on installing Homebrew).
- Next we’ll install Steel Bank Common Lisp (SBCL), a popular Lisp compiler / interpreter. Now that we have Homebrew it’s as easy as running
brew install sbclat the terminal.
- Install CodeRunner from the Mac App Store. This step will cost you your hard-earned $10 but it’ll leave you with a fantastic little tool for quickly experimenting with snippets of code in a variety of different programming languages. Highly recommended.
- Once CodeRunner is finished installing, open it and hit ⌘, to open the Preferences window. Switch to the Languages tab, add a new entry for Common Lisp, and configure it as shown:
- Go! After closing the Preferences window, change the Language in the top left of the CodeRunner window to Common Lisp. Then enter some Lisp code into the editor pane (try copying in the sample file below!) and hit ⌘R to run the code!
;;; sample.lisp - tell me the secrets of your lispiness ; Remember this is not a REPL so the return value will not print by default! (setf *random-state* (make-random-state t)) (format t "~@(~r~) bottle~:p of beer on the wall..." (random 99))
And now you’re set up to play around with Lisp! If you’re just starting to learn the language I highly recommend reading Practical Common Lisp. Happy hacking!