26 ms·
Practical Common Lisp (2005)
- Qwertystop 10y agoTried to use this to learn Lisp (previous experience: one semester of Racket). Couldn't really motivate to keep going. Might just be me, though.
- tosh 10y agoI'm currently going through the advent of code challenges (http://adventofcode.com http://adventofcode.com) with Clojure and watch a few talks (https://www.youtube.com/user/ClojureTV https://www.youtube.com/user/ClojureTV) next to it. The cool thing about the challenges is that they are language agnostic so you can try whatever you're interested in (CL, Scheme, Racket, Clojure, …). A bit like Project Euler (https://projecteuler.net https://projecteuler.net) but more fun.
- qwertyuiop924 10y agoHey tosh! Funny seeing you here (especially mere hours after I replied to you on Reddit) AoC is great. I've been doing it in Scheme. Except today's challenge, which I did in AWK, because it was perfectly suited for the task (although I could have also used the AWK scheme macro). Plus, in Scheme, you don't wind up with code like this {if(($1+$2>$3)&&($1+$3>$2)&&($2+$3>$1)) count++;} END {print count} Aren't one-liners fun?
- throwaway7645 10y agoI was the same way. The MP3 database example was odd. I was thinking it could be implemented in any language as a dictionary...no big deal.
- rpeden 10y agoI found the interesting part of that chapter was creating a macro to ingest search clauses and generate 'where' functions to search the MP3 database.
- DigitalJack 10y agoFeedback is very helpful in learning. It's why so many of us get such satisfaction out of building physical things or making art. It's because the feedback is immediate, among other things. It's more abstract with programming, but programming a website gives pretty good and immediate feedback. Plus you can show it off. So even though I'm not a web dev, I still think learning to build a dynamic website or web tool or service is a really great way to get introduced to a language. It will give you a rooting that you start branching out from. Clojure in particular is pretty good at the web dev thing. I'd just stick to server stuff to start with personally.
- _ph_ 10y agoOver 10 years old, but still the best modern Common Lisp book. It helps, that it has been written by someone who had a lot of experience with other languages (Java), so less captured in a Lisp ivory tower, showing a truly practical approach. Highly recommended!
- lispm 10y agoThere is one important thing not covered in the book: https://www.quicklisp.org/ https://www.quicklisp.org/ Quicklisp was first published in 2010 and is a library manager for Common Lisp.
- kgwgk 10y agoYou probably meant 2010.
- lispm 10y agocorrected, thanks!
- armitron 10y agoQuicklisp is not panacea, even though it simplifies matters to a substantial degree for people new to Common Lisp. On the other hand Quicklisp has serious issues: + Minimal if any documentation of internals. + A substantial chunk of the codebase can only be described as spaghetti code. To make matters even worse, most functions lack documentation strings. A sad state of affairs given the interactive and self-documenting nature of CL. + Is vulnerable to man-in-the-middle attacks since it verifies neither certificates nor checksums. This means that using Quicklisp can get you owned. Unacceptable these days. + Operates over a 'curated repository' model that Xach is managing. The repository has been found to be vulnerable to man-in-the-middle attacks in the past since packages were fetched over plain HTTP or git://. Even if that wasn't the case, it's yet another element in the chain of things to trust. + Few if any people besides Xach are working on quicklisp-client to mitigate these issues. Lack of documentation and spaghetti code is not helping to attract new talent. + Xach is employed by Clozure Associates. I understand that they've allotted him some time to work on Quicklisp while on the job, but it's still a side-project. Look at the number of open issues at Github. Many have been there for years. For these reasons, I don't use Quicklisp myself. I also advocate against it to friends and colleagues who share my views on software distribution mechanisms.
- fovc 10y agoI've been working in JS full time for a couple of months now, except for a short break to build a JSX parser for Emacs. Switching to lisp was such a breath of fresh air. The code was denser, and every line took longer to write, so not sure about overall productivity, but man was it more enjoyable to write! I wish there were an update to this book. I seriously looked into giving up on JS and using Parenscript and Wookie or Hunchentoont but it seemed like I'd be taking on a lot of yak hair. Does anyone here use any lisp for Web Development? What's the modern lisp (CL or otherwise) stack?
- Arcanum-XIII 10y agoYou have lot of good libraries in clojure, as well as clojurescript for the front end with nice js interop. For Common Lisp there's some nice stuff too, that build over hunchentoot but can't remember the name. The book Common Lisp Recipes has a lot to say about those topics too, the perfect complement to Practical Common Lisp in fact :)
- LyndsySimon 10y ago> You have lot of good libraries in clojure, as well as clojurescript for the front end with nice js interop. I've been writing Clojure for about a month now, and I love it. My background is mostly in Python, and I picked up Ruby about a month before Clojure. My rampup in Ruby was really about a week, given that much of it is so similar to Python - it was mostly about learning conventions and what the community considers to be "idiomatic Ruby". Clojure was much more difficult to learn, and much more fulfilling/enjoyable. It's definitely changed the way I think about my code in all languages and that's a good thing. One thing I will say though is that the majority of the time I've spent struggling with Clojure has actually been struggling with Java. For example, I wrote a collection of forms that decrypt and validate an auth token sent by a third-party legacy application. This required using java.crypto, which was a nightmare. I was porting code from Ruby, which was using OpenSSL. At one point I had references for Clojure, Java, Ruby, OpenSSL, and C all open at once, trying to figure out what was going on. In the end that particular problem was because Ruby's OpenSSL wrapper magically use an IV of eight null bytes if you don't supply one while java.crypto didn't use one at all - but it was one of the more difficult issues I've had to debug in recent memory. I guess what I'm trying to say is that I would absolutely recommend Clojure as a first Lisp to learn, but I would also suggest that the person doing so either already have some experience in Java or have a way to reach out to someone who does. I'm planning on picking up CL at some point soon as well, but from what I've experienced and gleaned from the experience of others Clojure is probably the better choice is your area of interest is mostly the web, because of the dev community and access to Java libraries.
- qwertyuiop924 10y agoPCL is still one of the best books for learning Lisp. Although I actually got my start with Conrad Barski's The Land of Lisp, which is also excellent.
- nabla9 10y agoPractical Common Lisp is intro + recipes. I think Paul Grahams ANSI Common Lisp is the best if you are learning Common Lisp and Lisp. The language reference in the end is the extremely handy compact reference for CL. http://www.paulgraham.com/acl.html http://www.paulgraham.com/acl.html Common Lisp Recipes is better as a pure recipe book. http://weitz.de/cl-recipes/ http://weitz.de/cl-recipes/
- hylisper 10y agoSlightly disagree with this....pg's work is the manual, though peter's examples and explanation of the concepts in lisp are practical to the core. To the point that you re-use your own code developed in the earlier chapters into the later chapters. That was the deal breaker, at least for me. Learning a new programming language is often bland, though engaging the reader practically isn't actually easy as it may seem.
- throwanem 10y agoAnother, more easily accessible, quick reference: http://clqr.boundp.org http://clqr.boundp.org I made a paper copy a while back, as is recommended by the authors. It's come in a lot of handy.
- harperlee 10y agoFor me, during the university ANSI Common Lisp was the Kernighan & Ritchie of Lisp - a standalone physical source of everything that I needed to start doing interesting things. Since then I haven't found another "canonical book" for another language that I jumped on, instead relying basically on internet. On that line, I loved "The haskell school of expression", though!
- bsder 10y ago> I think Paul Grahams ANSI Common Lisp is the best if you are learning Common Lisp and Lisp. I disagree, and here's why: Practical Common Lisp is the SINGLE Lisp reference I have ever found that talks about how to use real data structures instead of stupid cons pairs. That's really, really huge. And it's probably why so many people actively dislike Lisp. And it's probably why Clojure achieved such popularity.
- Koshkin 10y agoA wonderful book, well worth studying. If only in order to gain a wider perspective on programming languages, and perhaps forget, at least for a while, about the language wars and the ongoing "C bashing." It may be not obvious to those who may only have had a limited experience with it, Common Lisp, in itself, is an extremely expressive and powerful programming language. Also, there are compilers, such as SBCL, that generate a very efficient machine code; others, such as ECL ("embeddable Common Lisp"), make it very easy to combine lisp code with code written in C, thereby providing the ability to seamlessly integrate high-level and easy-to-use constructs with low-level, performance-critical pieces of code.
- qwertyuiop924 10y agoIndeed. As much as I dislike CL's quirky inelegance (I prefer the scheme side of the Lisp family tree), it's a tremendously powerful and effective language, and one of the best choices for Getting Stuff Done Right Now using Lisp. In fact, probably the best choice.
- Koshkin 10y ago> quirky inelegance On the other hand, quoting Einstein's quote found in the famous book by Sussman and Wisdom who use Scheme to teach Classical Mechanics, "I adhered scrupulously to the precept of that brilliant theoretical physicist L. Boltzmann, according to whom matters of elegance ought be left to the tailor and to the cobbler.”
- dleslie 10y agoTailors and cobblers do practical tasks day in and day out; whereas physicists stretch their imagination to dream of the yet-known. Somehow I think the analogy falls apart on close consideration. ;)
- taeric 10y agoAll analogies fall apart on close consideration. In this case, though, I think it still works. It says nothing of the work they do, but more to the goal of their work. Tailors/coblers (fashion, in general) are tasked with making elegant attire. It is true that some are tasked with making practical attire. Physicists, however, are never tasked with making elegant physics. It is rewarded. But it is not directly their task.
- znpy 10y agoThe biggest problem in spreading lisp nowadays is the fragmentation of the documentation. "Lisp" means so little when you're writing real code. Each implementation has its own quirks and even venerable books fall when confronted with real world code at learning. For example: I was reading the SICP and using racket that looks like an interesting runtime nowadays. Turns out that a while a go the dev team made cons immutable and that's okay I guess but it broke (at least for me) the experience of reading SICP because I now have to pause and learn this quirk of this specific lisp implementation. And don't even get me started on common lisp. There are at least 5 or 6 major common lisp runtimes, each of them incompatible somehow (try and read some of the StumpWM "makefiles" and you'll have a taste of what I'm talking about). Also, common things (threads, for example) are still not provided in a uniform way across all of the implementations, and are often more or less quick hacks. Scheme? Cool! Srfi! What part of scheme does your scheme actually implements? Would you use a C compiler without structures? And write code so that it can be compiled with another C compiler that has structures but doesn't have foot loops (only while loops are provided). Lisps are awesome languages, but for me, no wonder they remain niche languages. And before you downvote, please keep in mind that I am now booing Lisp, I would just love it to be more "sane" minded and less schizophrenic as a language/runtime, and more real-world-usable.
- kbp 10y agoThere are at least 5 or 6 major Lisp implementations that follow the standard very closely. They might have the odd quirk, and they all have extensions, but ANSI CL also provides a standardised way to handle implementation-specific parts. The situation there isn't any different from C. Edit: Not to mention, C only got threads in the most recent revision of the standard, and I can't say anything about their implementation because I've yet to encounter a project that uses C11.
- lispm 10y agoFor portable thread APIs in Common Lisp see: https://github.com/sionescu/bordeaux-threads https://github.com/sionescu/bordeaux-threads and https://github.com/binghe/portable-threads https://github.com/binghe/portable-threads
- aidenn0 10y agoIf anyone is using windows and wants to go through PCL, I believe the lisp box linked to is way out of date. I've generated a portable zips that are more up to date: https://github.com/jasom/lispstick-automate/releases/download/0.1/lispstick-sbcl-1.3.9-emacs-24.5.7z https://github.com/jasom/lispstick-automate/releases/downloa... https://github.com/jasom/lispstick-automate/releases/download/0.1/lispstick-sbcl-1.3.9-emacs-24.5.zip https://github.com/jasom/lispstick-automate/releases/downloa...
- lukego 10y agoThe Lisp world is really lucky that Peter came along and wrote this book. It was amazing to watch him tease out, soak up, and internalize Lisp culture from all the available sources and then write such a canonical book to share it all with the rest of us. I wish that he would write some more books :).
- gigamonkey 10y agoI plan to. Some day.
- smnplk 10y agoMaybe a Clojure version with similar approach ?
- tsm 10y agoHow useful would that really be? PCL has Peter's take on Lisp, and the Joy of Clojure occupies a similar niche if you just want to learn specifically-Clojure. At one point he mentioned writing a book to the effect of Statistics for Programmers, which sounds intriguing to me. AFAIK it hasn't happened yet, though.
- nextos 10y ago> Statistics for Programmers Why intriguing? The most general family of distributions can only be expressed with a programming language, so there are certainly many connections between both fields. Incidentally, that's one of my major complaints about Lisp these days. Lisp-Stat started dying in the early 2000s and completely faded away long ago. I read PCL when it was published a decade ago and I fondly remember how enthusiastic I became about Lisp. I have used Clojure extensively, but the ecosystem for doing math and statistics is quite reduced. The same applies to CL and Scheme. I wish I could use one Lisp for most tasks.
- JadeNB 10y ago
- int_19h 10y agoWhat is the current state of affairs with regard to Common Lisp on Windows? I remember that when I was last trying to explore it, that was the single biggest hurdle - all the recommended freely available "industrial strength" implementations (SBCL, CMUCL) were either unavailable on Windows outright, or considered experimental and highly unstable there. The stuff that was available was either proprietary (and costly), or its performance was not deemed sufficient for production use (e.g. CLisp). But that was several years ago. Did anything change?
- jsjolen 10y agoHi! It is a lot better, I don't think SBCL gets the "kitty of doom" start up message anymore. I'd love it if you'd try and let us know :-) (or you could just ask on #lisp). I know for a fact that Clozure CL works well on Windows.
- frobbo 10y agoI use CCL on Windows, and at times SBCL. SBCL does have a large warning about lack of maintenance and potential instability or something like that, but I haven't used it heavily enough to expose such behavior. CCL has no interpreter, so any code you write gets compiled to native code. People worry too much about performance too prematurely in my opinion. I hate windows in general and try to avoid using it and targeting it whenever I can, but for the past year I did use windows+ccl+emacs to successfully get work done, which I was able to easily transition back over to macos+ccl+emacs just recently. I would say that at the very least, the hurdles you ran into in the past are gone. Binaries for sbcl on windows are supplied, and I'm pretty sure that threading is enabled in recent builds so no need to recompile yourself (I remember wasting so much time on this a few years ago and moved to ccl). I recently ran into a workflow that ccl easily accommodated that sbcl didn't, which was specifically such that when you ran out of heap, ccl automatically allocated more, whereas with sbcl it seems to be fixed upon startup and requires more than a command line flag to fix (I couldn't figure it out in the hour or so I spent working on it)
- int_19h 10y agoClozure looks very interesting, thank you! Got it up and running in a few minutes, and the docs look promising. I think it wasn't around last time I tried to seriously explore CL. Good to see more options!
- lisper 10y agoI started working on this a while back: https://github.com/rongarret/BWFP https://github.com/rongarret/BWFP Currently very low on my priority list but it would not take a lot of encouragement for me to pick it back up again.
- mablap 10y agoIn chapter 1 you mention that Petzold's book is underrated. If that's any consolation, I have bought the book when it came out and have talked about it to many of my friends since. I wouldn't say it's underrated, but just not well known. Great book!
- lisper 10y agoMaybe I'll change that to "under-appreciated"
- mablap 10y agoI forgot to say that I'm reading your text now :) I had a compiler class with Marc Feeley, author of Gambit-C, and I've been sold on Lisps ever since. I really love the simplicity of Scheme, but I found that it's much easier to get going (i.e. not having to re-write even basic things such as for-loops) in CL than Scheme. I can write/read some basic macros but my end goal is being able to write a read-macro for a DSL. I can't really envision doing this as easily without a Lisp.
- blue1 10y agoFWIW, please accept my bit of encouragement. I would really like a book like yours.
- lisper 10y agoThanks!
- splesjaz 10y agoRecently bought ; Land of Lisp and it should arrive next week. Heard it's a pretty good book to do some fun with Common Liso
- Shorel 10y agoI'm sorry but I never liked PCL that much. It certainly shows some impressive Lisp techniques, and surely it will impress anyone who reads it about Lisp capabilities. The PCL made me feel awe about what Lisp can do. But not about what I could do with Lisp myself. PCL doesn't really help the reader to really understand how all that code works to the point where the reader could write it without the writer's help. I found this book: Lisp, An Interactive Approach https://www.cse.buffalo.edu/~shapiro/Commonlisp/ https://www.cse.buffalo.edu/~shapiro/Commonlisp/ a better pedagogical tool to learn Lisp, and it guides the reader all the way, tests him, and makes him write all the needed code before going to the next chapter. It's not a showcase like the PCL book, but it imparts the reader with the ability to write a similar showcase himself. The 'An Interactive Approach' book made me grok the power of Lisp in a way no other book could. It made me feel powerful and confident about what I could do with Lisp.
- wyclif 10y agoWhat's the current best CL implementation on macOS/OS X? Is it still SBCL or something else?
- kbp 10y agoSBCL is very good and what most of the open source community uses. Clozure CL is also very good, reasonably popular, and has good Cocoa support. LispWorks is excellent, but proprietary; the paid versions are very expensive but there is a free 'Personal' edition as well. I would recommend SBCL unless you want to do GUI stuff.
- z0ltan 10y agoI use SBCL on macOS. Very satisfied! ;-)
- chris_wot 10y agoIs it just me, or is there a typo in the following? CL-USER> (remove-if-not #'(lambda (cd) (equal (getf cd :artist) "Dixie Chicks")) *db*) ((:TITLE "Home" :ARTIST "Dixie Chicks" :RATING 9 :RIPPED T) (:TITLE "Fly" :ARTIST "Dixie Chicks" :RATING 8 :RIPPED T)) It seems to be missing a single quote... shouldn't it be: CL-USER> (remove-if-not #'(lambda (cd) (equal (getf cd :artist) "Dixie Chicks"))' *db*) ((:TITLE "Home" :ARTIST "Dixie Chicks" :RATING 9 :RIPPED T) (:TITLE "Fly" :ARTIST "Dixie Chicks" :RATING 8 :RIPPED T)) If this is a typo, it merely shows how incredibly well written this is, because I have literally never read lisp code in any seriousness in my life!
- martinflack 10y agoIn your example, the LAMBDA form is preceded by a sharpquote. So #'FORM is syntactic sugar for (FUNCTION FORM). This is a way to reference a value in the function namespace instead of the variable namespace (Common Lisp is a "Lisp-2"... actually more than that, but that's the common terminology.) Usually this sharpquote would precede names of functions when they are passed as a value. (Interestingly, they are optional on the LAMBDA form.) Generally, preceding single quotes in Common Lisp e.g. 'FORM are syntactic sugar for (QUOTE FORM) which has the meaning of reading in the form without evaluating it. You'll see lots of single quotes used for that purpose as well.
- chris_wot 10y agoOh, I see. In that case, I was a little confused by the following: CL-USER> (remove-if-not #'evenp '(1 2 3 4 5 6 7 8 9 10)) (2 4 6 8 10) The author explained what #'evenp did (FUNCTION '(1 2 3 4 5 6 7 8 9 10)) but not that '(1 2 3 4 5 6 7 8 9 10) is just (1 2 3 4 5 6 7 8 9 10). In other words, the above evaluates to: (FUNCTION evenp (1 2 3 4 5 6 7 8 9 10)) Or didn't explain it unless, of course, I missed a bit :-)
- bluefox 10y agoYou can see how an expression is read this way: (defun how-is-it-read? (string) (write-to-string (read-from-string string) :pretty nil)) ==> HOW-IS-IT-READ? (how-is-it-read? "#'foo") ==> "(FUNCTION FOO)" (how-is-it-read? "(remove-if-not #'evenp '(1 2 3 4 5 6 7 8 9 10))") ==> "(REMOVE-IF-NOT (FUNCTION EVENP) (QUOTE (1 2 3 4 5 6 7 8 9 10)))" You can see that this does not match your expectation. Are you actually trying to type that code and evaluate it at a Lisp listener? If not, you should. Now, FUNCTION is a special operator that in this case returns the function named EVENP. QUOTE is a special operator that just returns the object it is passed. So REMOVE-IF-NOT will get called with two arguments: the function named EVENP, and a list of integers from 1 to 10.
- wtbob 10y agoPractical Common Lisp, along with pg's essays on Lisp, can be credited with inspiring the Lisp renaissance of the mid-2000s. It's an incredibly good book, showing Lisp (unlike Scheme) is a practical programming language, with the ability to go from low-level bit-twiddling all the way up to very high levels of abstraction. Reading it was eye-opening. I had no idea up until that point that Lisp is a real, industrial-grade language (as opposed to a very interesting didactic tool). Even if you don't have an intention of programming in Lisp, you should read PCL for an idea of how much better the language you're programming in could be. Hopefully, it'll inspire you to write some Lisp, but even if it doesn't you'll be a better programmer for it. You'll be able to understand why static languages like Java have such arcane ecosystems; you'll be able to see how very little new there is under the sun.
- quicklist 10y ago"quicklisp makes lisp insecure due to their use of double rot-13 for encryption."
- saurabhjha 10y agoThis book looks good from a cursory glance. Can anyone please tell me if I should read this one or Paul Graham's ANSI common lisp. I have some background in scheme due to SICP. Thanks!
- z0ltan 10y agoDefinitely this book. I would recommend keeping Graham's books for later. Practical Common Lisp + Land of Lisp + Common Lisp recipes + the Lisp Hyperspec = Profit! Additional readings: Successful Lisp (Lamkins - very underrated), Paul Graham's books, and Hoyte's Let Over Lambda (advanced).
- blue1 10y agoGraham is very clear, concise and readable. Though I liked it, I think it expresses a rather personal view of CL, deliberately excluding parts of the language. Overall PCL is more idiomatic. It's probably better to read them both.
- z0ltan 10y agoIt's a good book in parts, but very dry and almost reference-like in others. All in all, pretty decent. I much preferred Land of Lisp by Barsky for the basics and Edi Wietz' Common Lisp recipes for specific use cases.
- Annatar 10y agoIs there any material exploring the possibility of using LISP as a systems programming language?
- rini17 10y agoMostly dead projects: http://web.archive.org/web/20000418011820/http://www.hex.net/~cbbrowne/lisposes.html http://web.archive.org/web/20000418011820/http://www.hex.net... Some ideas: https://github.com/robert-strandh/LispOS https://github.com/robert-strandh/LispOS
- lispm 10y agohttps://github.com/froggey/Mezzano https://github.com/froggey/Mezzano
- gaurav-gupta 10y agoThis is an awesome book. I read it online back in 2006 (one of the few books I followed from start to end). Even though I mostly programmed in other languages, the approach and techniques in this book enormously improved me as a programmer. Thank you for writing this book and sharing it with the world!
- sealedmail 10y agoIf I may suggest, please add 'next' and 'previous' links within the chapters of the online book. It's a little annoying to have to navigate back and then click on the next chapter to read on.
- spdegabrielle 10y agoA great(fun!) book. I wonder if it can take any credit for the resurgence of lisps! (especially Clojure) It certainly was an influence on the student writen 'Realm of Racket'.