# HG changeset patch # User Steve Losh # Date 1533414042 25200 # Node ID 15d99aa7fd90474d1568cc72e031b54104857dd7 # Parent 09fe133e6c33a9ddd94ac5497862948a1ddc9225 Finally diff -r 09fe133e6c33 -r 15d99aa7fd90 content/blog/2018/08/a-road-to-common-lisp.markdown --- a/content/blog/2018/08/a-road-to-common-lisp.markdown Sat Aug 04 12:57:08 2018 -0700 +++ b/content/blog/2018/08/a-road-to-common-lisp.markdown Sat Aug 04 13:20:42 2018 -0700 @@ -1,7 +1,7 @@ +++ title = "A Road to Common Lisp" snip = "One way to learn this old, deep language." -date = 2018-07-03T16:00:00Z +date = 2018-08-01T16:00:00Z draft = false +++ @@ -304,7 +304,8 @@ multiple implementations of it, which gives you choices. There are a bunch of options, but I'll make it simple for you: -* If you're comfortable with the command line, installing packages with a package manager, and already have a text editor you like, choose [SBCL][]. +* If you're comfortable with the command line, installing packages with + a package manager, and already have a text editor you like, choose [SBCL][]. * Otherwise, choose [ClozureCL][CCL] (often called "CCL"). That's Clozure with a Z. Clojure is something entirely different that just @@ -610,8 +611,58 @@ ### Learning Paradigms +At this point you should have a pretty good handle on the basics of Common Lisp, +and have set up one of the more powerful development environments. Your next +goals should be to learn how to write idiomatic Common Lisp and to get some +practice using your fancy new environment. + +I think the perfect book for both of these is [Paradigms of Artificial +Intelligence Programming][TODO], often abbreviated as PAIP. The book was +recently made available for free as a PDF, or you can buy a paper copy from +if you prefer. + +This book was written in 199 TODO so it's not about the hyped up AI fields +you've been hearing about in the news like machine learning or deep learning +— instead it's a tour of [Good Old-Fashioned AI][gofai]. Even if you're not +particularly interested (yet?) in this kind of AI, the book is a great example +of how to write Common Lisp code. + +One thing I really love about this book is that almost all the functions in it +have docstrings. If you look at most other programming books they omit the +documentation strings, presumably for space reasons and because they feel the +surrounding text is documentation enough. But writing helpful docstrings is an +art in and of itself, and I think books that omit them train users that "good +code omits docstrings", which is a bad habit to get into. + +The book contains *plenty* of exercises, conveniently categorized by how +difficult or involved they are: + +* `S` for "seconds". +* `M` for "minutes". +* `H` for "hours". +* `D` for "days". + +This is a very good idea which more books should steal. Do all of the `S` and +`M` exercises, and try your hand at at least a few of the `H` ones. If a `D` +sounds particularly interesting don't be afraid to spend some time on it +— really digging into a problem is exactly what you need at this point in your +Lisp journey. + +[gofai]: TODO + ### Recipes for Success +The final book I'll recommend to every aspiring Lisp programmer is [Common Lisp +Recipes][TODO] (abbreviated as CLR). Unlike most of the other books I've +recommended so far this one is relatively recent: it was published in 2015 TODO. +It's not free, but I think it's well worth the money it costs. + +The book is written by the author of several very heavily used Common Lisp +libraries. It's a bit of a grab bag of topics (which is why I think you need +a decent amount of Lisp under your belt before you tackle it) but it's a very +well-written grab bag that will teach you a lot of things you won't find in +other books. + ## Where to Go From Here If you made it through all the books and activities in the previous section: @@ -763,9 +814,9 @@ “package”) to mean different things than people mean today. Things get easier once you internalize what Common Lisp means by the terms. -NOTE: I posted a quick-and-dirty version of this section as a [comment][] on Lobste.rs -while I was waiting for a plane — this section of the post is an expanded -version of that comment. +NOTE: I posted a quick-and-dirty version of this section as a [comment][] on +Lobste.rs while I was waiting for a plane — this section of the post is an +expanded version of that comment. [comment]: https://lobste.rs/s/fwhuz5/my_lisp_journey_1_getting_started_with#c_ebhvzq @@ -940,14 +991,15 @@ #### Recap Here's a quick recap of the different layers of project structure you'll -encounter in Common Lisp: +encounter in Common Lisp. Jot these down on a post it note you can refer to as +you're learning. * **Files** are files on your hard drive. * **Packages** are containers of symbols. They are orthogonal to files. -* **Systems** are collections of code, instructions on how to load this code, +* **Systems** are collections of code, instructions on how to load that code, dependency lists, and metadata. They are orthogonal to packages. * **Projects** are high-level collections of... "stuff" such as code, - documentation, maybe some image assets, etc. They are (mostly) orthogonal to + documentation, maybe some image assets, etc. They are (mostly) orthogonal to systems (are you seeing a trend here?). * Common Lisp itself knows about files and packages. * ASDF adds systems. @@ -975,7 +1027,8 @@ more than one library tries to claim the same two-letter name it causes problems. An example of this is Bordeaux Threads which has a package called `bt`. It's too late to change this now, but try to avoid such easily-clashing -names when making new packages. +names when making new packages. I'd even try to avoid three or four letter +names, but I'll admit I've broken this rule myself a couple of times. Another question that comes up is: "I see a lot of projects called `cl-whatever` — should I name my projects with the `cl-` prefix?". Some Common Lispers hate @@ -1014,12 +1067,12 @@ Common Lisp doesn't have a *large* of a community as some newer languages, but it still has a lot of libraries because it's had a community for a longer time. -The stability of the core language means that libraries that were written in -portable Common Lisp ten or twenty years ago can still run just fine. +The stability of the core language means that many libraries that were written +in portable Common Lisp ten or twenty years ago can still run just fine. In this section I'll give you a quick overview of some of the more popular libraries you might run into as you learn the language. You don't have to use -all of them, of course, but it's helpful to have some idea of what's available. +all of them, but it's helpful to have some idea of what's available. #### Alexandria