It’s been nearly two weeks since I started learning Lisp. I must say that before you start doing something, you need to know where to start. As my old friend Confucius told me, “A journey of a thousand miles, begins with a single step.” So there, I’ll be posting here how to get started with Lisp by setting up your own working environment.
I am running Ubuntu 9.04 Jaunty on top of my Windows 7 via Sun VirtualBox. You can download Sun Virtual box here and setup your virtual machine. If you’re already on Ubuntu then that’s fine, leave it as is. After all is being done already, just type the following:
- Type ’sudo apt-get install sbcl’ (or alternatively ’sudo apt-get install cmucl’)
- Type ’sbcl’ in the terminal. (or alternatively type ‘cmucl’)
- You will see an asterisk (*) if you have successfully installed it.
- You can also test it by typing, ‘(print “Hello World!”)’ in the terminal.
[email protected]:~$ sudo apt-get install sbcl (you will see some installation messages here, just continue installing) ... ... .... ... ... [email protected]:~$ sbcl This is SBCL 1.0.18.debian, an implementation of ANSI Common Lisp. More information about SBCL is available at <http://www.sbcl.org/>. SBCL is free software, provided as is, with absolutely no warranty. It is mostly in the public domain; some portions are provided under BSD-style licenses. See the CREDITS and COPYING files in the distribution for more information. * (print "Hello World!") "Hello World!" "Hello World!" *
You can actually choose which interpreter to use, either sbcl and cmucl. The two have pros and cons actually.
For the SBCL (Steel Bank Common Lisp), the advantage is you can make use of the ‘trace’ function properly. The drawback is that some I/O functions don’t seem to behave the way they should be.
* (load "f-to-c.lisp") T * (f-to-c) 200 Please enter Fahrenheit temperature: 200 degrees Fahrenheit is 93.333336 degrees Celsius 280/3 *
* (load "power.lisp") T * (trace power) (POWER) * (power 2 3) 0: (POWER 2 3) 1: (POWER 2 2) 2: (POWER 2 1) 2: POWER returned 2 1: POWER returned 4 0: POWER returned 8 8 *
For the CMUCL (Carnegie Mellon University Common Lisp), the advantage is that the I/O functions are behaving well whilst the ‘trace’ function does not. Even if your code is not tail-recursive, it does not show the step-by-step process of the recursive call.
* (load "f-to-c.lisp") ; Loading #p"/home/ridvan/Projects/lisp/f-to-c.lisp". T * (f-to-c) Please enter Fahrenheit temperature: 200 200 degrees Fahrenheit is 93.333336 degrees Celsius 280/3 *
* (load "power.lisp") ; Loading #p"/home/ridvan/Projects/lisp/power.lisp". T * (trace power) (POWER) * (power 2 3) 0: (POWER 2 3) 0: POWER returned 8 8 *
Now that you’ve seen some of my observations on both interpreters, it really depends to you which one you should use. But if you’re going to ask me, I’d say it depends. It depends on what you wanted to achieve. If you want to trace your recursions, go use sbcl. If you want to have clean and neat inputting, go use cmucl. Personally, I use SBCL more often since I trace my codes more often.
So there, setting up lisp on your working environment is very easy. Enjoy Lisp! 🙂