posted on 2017-12-11 8:30:00 PM
Welcome to the first of hopefully many posts on providing a basic overview of the wonder language that is Common Lisp. Many folks over the years have provided many different versions of this talk (I will provide a few tutorials and book suggestions at the end of this post). However, one thing that is often ignored is how to actually setup a Common Lisp Development Environment. While the approach I have personally documented here may not be what others have suggested, since over time development environment and practices have changed amongst other reasons, it is the fastest way to get up and running so that we can concentrate on learning and writing actual CL code versus quitting after finding it difficult to get setup to begin learning.
One question that is often brought up when learning Common Lisp is the reason why we set up a development environment ahead of time? Why not first learn the language and then start writing code directly in the REPL? When I first started learning Lisp back in 2006 (and I was a bit naive back then and was unaware of SLIME), I took this approach while reading Practical Common Lisp (one of my first suggestions to learn Lisp, more on this later). However, I quickly realized, a few things: - As one does more scripting, at some point it becomes very useful to just pop up an editor and actually save your work to a file. - Most REPLs don't have readline commands built-in (at least the REPLs I've used never had read-line built-in).
For those of you aren't familiar, Readline is a library that gives nice emacs-style keybindings to applications. One of the features which I have often have used that is with this library is history (a nice way to look up commands and code previously executed).
There are other reasons, of course, why you should use a dev environment, but these are just from learning perspective.
Common Lisp was one of the first languages to have what we now called an Integrated Development Environment or IDE. Many of the features that were provided by the Lisp machines and dev environments like Interlisp-D were incorporated into modern IDEs for other programming languages like C++, Java, and so on. However, the introspection facilities of these IDEs still leave something to be desired, but I am getting ahead of myself since this is an introductory talk :-) So let's begin.
There are many barriers a newcomer to Common Lisp hits as he is first setting up and getting up to speed. Things like:
The list goes on... The solution to these needs has been released as a recent development, and that solution is Roswell. Roswell, as the site goes provides a nice tool to help manage different Common Lisp implementations, as well as unified way to test, build and distribute CL applications. There are many features in Roswell, and I will expand on Roswell in later posts, but first I would like to show how simple it is to get up and running with Common Lisp and SLIME with Roswell.
First we must download and install a few pre-requisites before we begin:
When you first install Roswell, all one has to do is run the command:
? ros setup
and Roswell will download SBCL (Steel Bank Common Lisp) and set it up with Quicklisp. To test this all works, all you have to do is run:
? ros run
and you'll see a SBCL prompt indicating it has been installed. run
(quit) and the shell to exit. Next we will install SLIME by running:
? ros emacs
This command will simply install SLIME using quicklisp (if it isn't already downloaded) and then it will actually open up emacs with a SLIME buffer available so you can get started writing lisp code. However, if this is your first installing SLIME with Roswell, you may end up having to first exit Emacs and add the following line (which is Of course can exit the SLIME buffer by type
M-x slime-quit-lisp if you want, and then exit Emacs using
C-x C-c. At this point, though, you are all setup to begin your lisp journey.
At this point, you are ready to begin your Common Lisp journey. A couple of suggestions on books that you can read to get you up and running include:
The books mentioned here cover the language fairly well and introduces all the basic aspects to day-to-day development in the program. Advanced topics like CLOS, Macros, and the Metaobject Protocol are introduced and covered in books like:
On top of the above book suggestions, I would also recommend Bagger's Little Bits of Lisp series located on Youtube. It is a small series of introductory Common Lisp videos and covers various topics, but not everything that are covered in the books. I would suggest to consider more as supplementary material to watch as you go on your journey to learning the language.
That's all for now. In the next installment, I will speak more about Roswell's features as well as using it to write shell scripts in Common Lisp as well as create executables.