by pmohun on 4/19/20, 5:24 AM with 96 comments
What is the best way to learn Lisp in 2020? I tend to learn best when I have a project to work on that plays to the strength of the language.
Some questions: - Should I start with Common Lisp, or some popular dialect (Clojure?) - What are the big patterns that I should be aware of? What is easier to do Lisp than is missing from functional languages like Python? - What are some big projects built in Lisp (other than this site)? - If it's so good, why isn't it more popular?
by twalla on 4/19/20, 7:30 AM
I feel like most people seem to gravitate towards Clojure afterwards for "real" projects - it definitely has the most real world adoption. The Java interop and JVM runtime feel like simultaneously Clojure's biggest strength and biggest weakness.
Here are some resources for both:
[Racket]
https://docs.racket-lang.org/guide/intro.html
[Clojure]
https://www.braveclojure.com/clojure-for-the-brave-and-true/
by _ph_ on 4/19/20, 8:24 AM
But if you want me to narrow down my recommendation to a single answer, it would be Common Lisp. It has one single comprehensive standard and there is a lot of real-world development done in Common Lisp. Scheme has a smaller standard, so while that is easier to pick up quickly, most Scheme implementations have a lot of extensions for all the stuff not in the small standard :p. So with Common Lisp, you have a much larger overlap between implementations.
For development, SBCL is great, as it is a free and open source implementation of Common Lisp which also has one of the best compilers to native code around, with well written code, you can get amazingly fast speed.
Practicall Common Lisp is a great resource for learning. It is very comprehensive, covering the important parts of the language and has some real-world examples. Land of Lisp is very nice, a bit more playful.
by knbknb on 4/19/20, 8:47 AM
"How to Code: Simple Data" on edX, by Gregor Gregor Kiczales from the University of British Columbia.
https://courses.edx.org/courses/course-v1:UBCx+HtC1x+2T2017/...
The course teaches the Racket language, but proceeds at a rapid pace. It follows the "How to Design Programs" methodology developed in the 1990s (?) at MIT (and elsewhere). This is a test-driven-design method, AFAICT. (I think the MOOC author co-developed it while at MIT).
Someone has ported all the SICP exercises to Racket, so you can follow along with that book, too.
https://en.wikipedia.org/wiki/Structure_and_Interpretation_o...
There is a follow-up course, "How to Code: Complex data" but I didn't take it.
by momo-reina on 4/19/20, 6:37 AM
https://leanpub.com/progalgs/read#leanpub-auto-data-structur...
Or a book like Barski’s Land of Lisp
https://www.amazon.com/Land-Lisp-Learn-Program-Game/dp/15932...
I would start with Common Lisp.
by distantaidenn on 4/19/20, 8:40 AM
If you keep wondering what's the best implementation, then you will suffer from analysis paralysis -- you'll end up spinning your wheels and doing nothing.
Flip a coin, pick something, and start building.
by krat0sprakhar on 4/19/20, 6:10 AM
by retonom on 4/19/20, 7:19 AM
by fmakunbound on 4/19/20, 6:18 AM
Don’t know what you mean you mean by patterns. Meta programming is way easier with Lisps. Python would not normally be classified as functional btw.
by typon on 4/19/20, 7:08 AM
by avmich on 4/19/20, 5:42 PM
For some important ideas Lisp brings to the table, I'd recommend the following approach.
1) Read this - https://stevelosh.com/blog/2013/03/list-out-of-lambda/ . If you're not familiar with lambda calculus - and if you do, you wouldn't likely ask this question - this article has a good chance to make you pause and re-evaluate importance and versatility of functions.
The benefit of this article is that the code is in a more traditional JavaScript, and it talks about just some ideas - not the whole landscape, so it's relatively short.
2) Then read this - http://www.michaelnielsen.org/ddi/lisp-as-the-maxwells-equat... . It's quite a project to read this an make all tacitly suggested exercises.
The big point is that you can have an expression, which evaluates other expressions - in a chunk one can hope to bite. After this you can aim to write your own interpreters.
3) Go to Norvig's JScheme - which adds mechanisms from more real Scheme, like tail recursion optimization. By this time you'll have some practical ideas about how closures are built; Michael Nielsen uses Python's functions for that.
4) Read about continuations. Look at "Structure and interpretation of Computer Programs" for solid foundations. Look at "On Lisp" for e.g. treating of macros - both of these books are on the Internet to read. I'd also recommend checking "Paradigms of Artificial Intelligence Programming" - another book (by Norvig) available on the Internet to read - which teaches Lisp while providing plenty of examples of its use for interesting problems.
"The Little Schemer" book (an awesome series) talks about patterns for how to apply Lisp for problems; look at them.
You will probably get most out of pp.1 and 2, but the others will expand your horizons. You'd see why Lisp is at times called "a big ball of mud", and how this old language somehow manages to become inspiration for new languages, while absorbing new ideas from modern language research.
by xsys on 4/19/20, 6:53 AM
by tester89 on 4/19/20, 2:12 PM
* Practical Common Lisp by Peter Sibel. An award-winning book that serves as a serious introduction to the language with many practical projects. [Available to read for free online.](http://www.gigamonkeys.com/book/)
* Land of Lisp By Conrad Barski. A fun introduction involving writing silly retro games in Lisp. The author based his book of a short introduction he wrote called [Casting SPELs in Lisp](http://www.lisperati.com/casting.html)
As an IDE if you’re comfortable with Emacs use Sly, Vim use SLIMV. For Atom there’s SLIMA, a port of Sly should become available for Sublime Text in a month’s time (or whenever ST4 is announced).
The reason I recommend Common Lisp is because it’s multi-paradigm, unlike Clojure and Scheme which force you down the functional rabbit-hole (not a bad thing but you won’t learn as much). Another reason is with the tools above it’s very-easy to setup a live coding environment.
I would recommend against learning Clojure because the error messages often tie too closely to the JVM, which might be annoying.
In terms of big projects, there’s of course HN, also
* Emacs
* Google Flights
* Grammarly
* Some quantum computing stuff
One of the things which is easier in Lisp is the creation of a Domain-Specific-Languages
Look at how [messy and hacky HTML DSL in Python is](https://github.com/duyixian1234/html_dsl), implementing this in Lisp would’ve been far easier and less hacky than that.
But really the main thing is macros (which enable the above), macros allow for easy customisation of the language syntax to better suit the problem at hand.
by omilu on 4/19/20, 2:42 PM
by linguae on 4/20/20, 6:55 AM
I use SBCL on macOS as my Common Lisp compiler. Regarding developer environments, although I'm a longtime vi user, I'm starting to get into Emacs and SLIME, which is an approximation to commercial Lisp environments. Common Lisp is best experienced in an environment like SLIME that has a live Lisp environment (kind of like Python's REPL on steroids). I'm pining for the days of Symbolics Genera, the operating system for Symbolics LISP machines, but sadly it's not open source and it's extremely difficult to obtain a legal copy these days.
Regarding resources, the best introduction I've found is the 1990 book "Common Lisp: A Gentle Introduction to Symbolic Computation," which is available online at https://www.cs.cmu.edu/~dst/LispBook/. This does not cover the entire language, but it covers the basics of the language, including macros. I went through this text and enjoyed its gentle introduction to the language.
I plan to purchase the following books to continue my Common Lisp education: "Common Lisp Recipes" (2016) by Edmund Weitz (http://weitz.de/cl-recipes/) and "The Art of the Metaobject Protocol" (1991) by Gregor Kiczales et al (https://mitpress.mit.edu/books/art-metaobject-protocol)
For general references to the language, Guy Steele's "Common Lisp the Language, 2nd Edition" is available online at https://www.cs.cmu.edu/Groups/AI/html/cltl/cltl2.html, and the Common Lisp HyperSpec is located at https://www.cs.cmu.edu/Groups/AI/html/hyperspec/HyperSpec/Fr....
Good luck and have fun!
by pjmlp on 4/19/20, 6:28 AM
https://franz.com/downloads/clp/survey
http://www.lispworks.com/products/lispworks.html#personal
They are the surviving experience from what Interlisp-D/Lisp Machines were thought to be.
Or in case you go Clojure, get yourself a copy of Cursive,
by akater on 4/20/20, 12:15 AM
Thus, one option to consider (esp. if you're not fond of learning by the book) is to just start learning Emacs since you will need it anyway, use Emacs Lisp to configure it and learn the basics hands-on way. That will likely feel “different” enough already to change the way you think about programming, if that's one of the goals.
No need for books, no need to setup anything, you're simply dropped into a huge introspection-enabled sandbox that is about to become your main tool.
by jmeister on 4/19/20, 4:23 PM
https://mitpress.mit.edu/sites/default/files/sicp/full-text/...
A classic time-tested route that will teach you the “spirit” of Lisp.
Has made countless students across generations fall in love with Lisp/programming/computer science
by hestefisk on 4/19/20, 7:06 AM
by y-y on 4/19/20, 6:13 AM
by zenlot on 4/19/20, 6:35 AM
[1] https://htdp.org
by wikibob on 4/19/20, 6:00 AM
by herdrick on 4/19/20, 6:58 AM
by j-pb on 4/19/20, 2:48 PM
by didibus on 4/19/20, 7:47 AM
Clojure is not a dialect of Common Lisp. That would be like saying that C#, Go, Kotlin or Scala are dialects of Java. They are both Lisps, but neither is a dialect of one another.
I use Clojure at work and recreationally, and I learned Lisps first from it, so I am a bit biased, but I do think Clojure is a good Lisp to learn in 2020. I'd say Racket is a close second.
So my rec would be to learn Clojure, and this is my curriculum of choice:
1. Read through: https://kimh.github.io/clojure-by-example/#about 2. Then read through: https://aphyr.com/posts/301-clojure-from-the-ground-up-welco... 3. Then read through: https://clojure.org/reference/reader 4. Now start referring to the Cheatsheet: https://clojure.org/api/cheatsheet and https://clojuredocs.org and https://cljdoc.org. Bookmark them. 5. Finally, read through guides here: https://clojure.org/guides/getting_started 6. Now go to: https://4clojure.org and go through the exercises, start with elementary and easy. Even better, get the Android app, so you can practice on the go, the bus, the bathroom. Also for some reason the order of exercise in the Android app is the best, so I'd try and follow that. You don't need to go through them all, you can probably stop after easy or medium. 7. Once that's done, get Clojure Cookbook and go through the recipes. 8. Oh and, always go to the Clojure slack beginner channel and don't hesitate to ask questions and for help. Maybe always have it open in a tab: https://clojurians.slack.com/?redir=%2Fmessages%2Fbeginners%... 9. Now try to build something from scratch, like try to write a tic-tac-toe game, or write a search engine, or whatever you prefer.
> What is easier to do Lisp than is missing from functional languages like Python?
There are two kinds of Functional language. There are those who rely on first-class functions as their unit of abstraction. In those, functions close over their environment, and can be passed around as values. Python has support for this type of functional programming, but it is somewhat mediocre compared to most Lisps. Python still relies a lot on Classes and Objects, and there are some constraints with the way its functions are first-class especially around anonymous functions and partial application. Scheme and Racket are pros at this when it comes to Lisps.
And then there are those where data is immutable, and most functions are pure. In those, everything will be an expression that returns a value, instead of a statement which returns nothing. Recursion will be used for looping, because data can't mutate, so it must be passed along. Records will be value based, instead of identity based, because they are immutable. Clojure is the king here when it comes to Lisps.
Nothing will be easier to do, especially to you, someone unfamiliar with Lisps, and learning it. But it should be more fun and more rewarding. The development process is more interactive, Lisp languages tend to have every feature under the sun for you to learn and mess around with. Performance should be better than Python, especially if you go for Clojure, Chez Scheme, or SBCL. Also expressiveness is really high, that means anything a little boilerplate, or requiring too much typing or contortioning can be factored out by a Macro. And structural editing is quite productive once you learn how to use it properly.
And once you know a Lisp, you can start exploring Emacs, and understanding how Emacs work, and how to modify it to your liking, which is a very fun new world of possibilities.
> What are some big projects built in Lisp (other than this site)?
There's Emacs. I know that Walmart was(still is?) using Clojure for their backend listings I think. I use it at my work for secret stuff ;), but it's handling backend micro-services processing thousands of requests per second. Circle CI pretty sure have a mostly Clojure based stack. Consumer Reports online is apparently built in Clojure. Apparently Atlassian have some Clojure backends. Boeing apparently runs some Clojure based in-flight diagnostic. ITA apparently uses CL for searching for airfares. And AutoCad uses CL it seems. NuBank is entirely written in Clojure, a pretty big fintech bank in Brazil of 5000 devs. AdZerk an ad serving company, and NextJournal, an awesome data-science notebook offering both have full on Clojure stacks. Apparently Cisco has a product called Threat Grid which is implemented in Clojure. Clojure/Script really dominates in that area compared to other Lisp from what I know here.
> If it's so good, why isn't it more popular?
Because everyone that could learn it, like you, back out because they ask this question :p Chicken and Egg is the answer really. Though I'd say, Lisp is tailored to experts, it doesn't make things easy and obvious, it kind of gives you infinite flexibility and customization. It has the opposite mantra of Python, the one and only one way, Lisp is like all and every possible way. So imagine a language that gives you infinite flexibility and customization, and every possible way to do anything and everything, yet is dynamic and without static type to help guide you in any of it, and has a syntax that isn't like anything you've learned in school, not like the math you know, not like the English you speak. That kind of language can't be wielded by just anybody.
by j-pb on 4/19/20, 9:38 AM
Common lisp by comparison, feels arcane, outdated and non lispy. You have to learn non composable macro syntaxes, and it's often way too low level and concerned about memory and imperative code and OOP.
Scheme is nice in terms of self contained purity, but then again not as nice to use and not as mind altering as clojure.
Clojure is basically a lisp build around immutable datastructures, common lisp is a lisp build around metaprogramming, and scheme is a lisp build around lambdas.
by kazinator on 4/20/20, 2:22 AM
You will have a very useful companion going forward, no matter what you work with.
No Emacs required; there is a REPL with persistent history and a decent multi-line editing mode built in, and the project provides an pretty accurate Vim syntax highlighting file (two actually, for the two languages).
It's conveniently documented in a single man page, like another Unix tool. That man page is also available as a hyperlinked HTML document, also all in one page.
by matthewn on 4/19/20, 6:00 PM
It's a delightful introduction to Lisp-y thinking. You can play online, or download and play offline: https://ifdb.tads.org/viewgame?id=zj3ie12ewi1mrj1t
by jim-jim-jim on 4/19/20, 5:57 AM
by misframer on 4/19/20, 5:10 PM
by smabie on 4/19/20, 6:42 AM
Also it comes bundled with tons of useful libraries.
by praptak on 4/19/20, 7:56 AM
It also has quite a lot of ideas that are useful outside Clojure, like its concepts around concurrency, state and immutability.
by rman666 on 4/19/20, 9:19 AM
by pm321 on 4/19/20, 9:03 AM
by clauderoux on 4/19/20, 8:46 AM
by sdegutis on 4/19/20, 6:24 AM
1. The syntax: It's just parens/brackets, where the first item dictates the meaning of the rest, all separated by whitespace. That's the whole syntax of Lisps. If you have a good IDE (e.g. Emacs + CIDER), this can make you slightly faster at editing code than normal.
2. Functional programming: Many lisps traditionally use recursion. It's not necessarily a core part of Lisp nor is it super great (I avoid it whenever possible). Most of the FP you get from Lisp you can also get from JavaScript and a good FP library (e.g. lodash).
3. Immutability: This isn't traditionally part of Lisps either, mostly just Clojure, and it can be done with libraries in JS. But people often mix these up and think it's a Lisp thing so I listed it here.
4. Macros: Many other languages have good macros now (Elixir, Rust, etc). It can be useful in certain situations, especially how it's used in Rust's stdlib and third party libs, but it's not a panacea as commonly thought.
5. Homoiconicity: This is one of the biggest touted features of Lisps and I just really don't think it's that great. It's mostly useful in writing macros, but other languages have macro systems that don't really suffer from not having this.
6. Bootstrapping: The original idea of Lisp being a language that can bootstrap an interpreter of itself using only a tiny set of special-cased evaluation rules ("special forms") is intellectually neat but not practically useful.
7. Common Lisp: This is its own thing. It's super complex and some people really love it and swear by it. It's kind of like a C++ competitor. It honestly shouldn't even be categorized with the rest of the Lisp family. That's like saying Europe is part of Italy.