A Road to Lisp: Which Lisp
100 points
4 hours ago
| 19 comments
| scotto.me
| HN
nobleach
2 hours ago
[-]
Since a few folks here recommended Common Lisp to me as the language that would "tick all my boxes", I've been doing a deep dive. Right now, I'm working through SICP again with DrRacket. The first time I worked through it with MIT Scheme MANY years ago. It's shocking how much I've forgotten.

What I like about this article is that it walks through the different "camps" of Lisp. Scheme is so intriguing to me because of how small it can actually be. I can build nearly any paradigm I want to exist. The problem is, if I were to actually go find a job where they were using a Lisp, (I hear those actually exist) they wouldn't want to use my "Result monad + match statement - railway pattern" that I've used from OCaml and Rust. So learning something that is truly "common" can make more sense.

As far as learning though, Scheme feels "just right". I've imposed a "no AI until I've found a working solution" rule that keeps my mind engaged. Couple that with a willingness to say, "I don't know that right now... I'll think about it throughout the day and maybe by this evening I'll have an answer".

reply
AyanamiKaine
1 hour ago
[-]
I can also recommend clojure. For me it has the best parts of common lisp and the best of the java ecosystem. But its also quite different from common lisp and scheme. Different enough to find some unique ideas.

Writing scripts using [0] Babashka is also really nice.

[0] https://babashka.org/

reply
snorremd
26 minutes ago
[-]
As a former Clojure dev (now just using Clojure in my spare time) I love Babashka. Michiel Borkent really nailed it with sci (Small Clojure Interpreter) and Babashka. Running a custom Clojure interpreter in a GraalVM compiled Clojure app is quite clever.

Now there are of course limitations to what you can do in terms of not supporting Java reflection or the full Clojure compiler. But I've made some nifty small scripts and convenience helpers with it. And the dev experience of making these scripts is so much nicer than trying to write bash scripts. The Clojure edn syntax is super simple, and the REPL connected editor let me rapidly test parts of the code just like with full Clojure apps.

I don't have experience with other lisps, but I can vouch for Clojure being very nice. The community was welcoming and friendly to newcomers when I started learning, I hope it still is. One thing I love about the Clojure ecosystem and community is the effort taken to never break libraries. I've looked at libraries I used some ten years ago, and the API is still compatible with code I wrote back then. There is very little churn. Maybe this is because the language is largely untyped and editors only partially check "types". Having breakages in libraries you consume once every couple of months would get really tiring in Clojure land. I'd imagine the same problems would present themselves in Common Lisp and others.

reply
nobleach
1 hour ago
[-]
I particpated in a Clojure reading group for "Getting Clojure" back around 2017. Having the entire JVM ecosystem available, is absolutely a great benefit. I even fooled around with ClojureScript a bit. David Nolen is great at making the case for both.
reply
arikrahman
26 minutes ago
[-]
Now there's Jank too, the first time a Lisp dialect has reached into native world since Clasp. The way it interops Clojure with the LLVM is unprecedented.
reply
Jtsummers
18 minutes ago
[-]
> the first time a Lisp dialect has reached into native world since Clasp.

What's that supposed to mean? Many (probably most if we only consider the non-toy ones) lisp implementations are "native" (compiling to native machine code, not interpreted).

reply
jlarocco
53 minutes ago
[-]
On a related note, there's a cross-platform Common Lisp package, "Bike" https://github.com/Lovesan/bike, that lets you use .Net assemblies from Common Lisp.

I've used it a tiny bit at work (on Windows) and at home (on Linux), and ran into one issue with "out" parameters, but otherwise it works really well.

reply
nobleach
19 minutes ago
[-]
That's just crazy! (in a good way) I've been in software since 1998 and it's like I've just uncovered a whole new world.
reply
waffletower
35 minutes ago
[-]
Babashka is really nice indeed. Am hopeful for the C++ hosted Clojure dialect, Jank (https://jank-lang.org)
reply
adamddev1
23 minutes ago
[-]
How to Design Programs with Racket was life changing.

https://htdp.org

That helped me to think about recursion, functional programming, and type driven development. After going through HTDP I was able to breeze through complex problems that were unsolvable before.

reply
QuadmasterXLII
23 minutes ago
[-]
The funny thing about Lisp is that writing a Lisp interpreter is significantly fewer keystrokes than correctly installing Common Lisp and its tooling. The ratio of lisps to lisp programmers may actually be above 1.
reply
dieggsy
2 hours ago
[-]
CL also has pretty much arbitrarily extensible syntax:

- https://sr.ht/~dieggsy/whisper/

- https://dieggsy.com/json-literals.html

And could also be used to build languages, supporting more modern programming paradigms (though yes, I believe Racket does make this easier):

- https://coalton-lang.github.io/

I also might have written the Common Lisp example using reduce as well, which is in the standard library, but that's preference. Nice to have the option though:

  (defun calculate (instructions)
    (reduce
     (lambda (result op-value)
       (destructuring-bind (operation value) op-value
         (case operation
           (:add (+ result value))
           (:subtract (- result value))
           (:multiply (* result value)))))
     instructions
     :initial-value 0))

  (calculate '((:add 5) (:multiply 3) (:subtract 4))) ;; => 11
reply
BoingBoomTschak
2 hours ago
[-]
I'd have used

  (funcall (ecase operation (:add '+) (:subtract '-) (:multiply '*)) result value)
instead, looks funkier =)
reply
dieggsy
2 hours ago
[-]
Oh yeah, way more fun :) I just kinda saw CL in the Clojure and was trying to make it look like that.
reply
groundzeros2015
2 hours ago
[-]
For me the complete spec is the killer feature. You can learn Common Lisp in 1990 and write it the same now. As long as we can keep the compilers alive it will be forever.

It’s funny to me that it was critiqued for being “bloated” when now it looks like a focused minimal library.

reply
dismalaf
1 hour ago
[-]
Common Lisp wasn't standardised until 1994.

Also, SBCL has some nice features specific to them, I'm sure it's the same for other implementations. So while there's a lot that's common between them all I find myself using a lot of platform specific functions.

reply
Jtsummers
1 hour ago
[-]
Yes, but it existed before then (from 1984 on), and a large amount of code written for CL pre-standardization still runs without alteration or with minimal updates.
reply
pratikdeoghare
1 hour ago
[-]
Shut up and learn Common Lisp using Practical Common Lisp.

This would be my advice. Why? My own road was haphazard. Other books broaden your mind and teach you really cool tricks. This book gets you using lisp like you would say golang. But it still teaches you the lisp things and broadens your mind. Time spent choosing will be better spent reading this book. After that PAIP, On Lisp, SICP etc.

reply
mktemp-d
1 hour ago
[-]
Piggy backing to apply more recommendations too.

An Introduction to Programming in EMacs Lisp is also good for the first few chapters even if you don’t use emacs because you are given fundamental concepts of lisp that can be applied to the understanding of other dialects. It’s also free.

Learn you a Haskell (despite Haskell being not a flavor of list, they share similar DNA ) is great at understanding functional programming with lisp like languages.

reply
em-bee
1 hour ago
[-]
that's the book i learned with. it got me far enough that i was able to write two applications that i ended up using for several years.
reply
0xb0565e486
2 hours ago
[-]
I really wanted to Lisp as a main programming language, and sometimes I still do.

I just find readability such a hurdle regardless of how long I used it. I didn't find that it ever became as natural as the other group of programming languages.

I find a procedural style of programming so much easier to reason about, both when writing and reading.

Either way, I'm really happy I took some time to learn it and use it a little at some point.

reply
ux266478
1 hour ago
[-]
Lisp really needs extensive structural editing tools IMO, and you really have to change how you think about reading source text and that can take longer than you might think. The best Lisp experience by far and away is LispWorks. That being said, I never found it to be to my tastes either. Too much focus on making tree-representations of programs the centerpoint, which isn't how my internal grammar works. I'd much prefer less explicit delimitation where it's not actually needed, but that's also incompatible with the goal of sexprs.
reply
Jtsummers
1 hour ago
[-]
Common Lisp code can be very procedural if that's what you want to do. The entire loop macro is basically importing Algol-styled procedural loops into Lisp.
reply
em-bee
1 hour ago
[-]
that's the conclusion i came up with after learning common lisp. it didn't feel much different from what i had learned before.
reply
dieggsy
2 hours ago
[-]
For me, the most effective way to read Lisp is to essentially forget the parentheses (I shadow them out in matching, low contrast colors) and go almost entirely by indentation. I find this makes it more similar to reading other languages, though granted not exactly the same.

You do have to keep up with the parentheses of course, but editor settings or extensions can make this automatic if not invisible.

reply
groundzeros2015
2 hours ago
[-]
(Heresy alert. Inb4 homoinconcity)

I do find that most of my lisp skills carry over to JavaScript quite well while allowing me to write imperative functions more fluently.

Prog blocks are pretty good. I wonder if another DSL could be better.

reply
hnarayanan
2 hours ago
[-]
Maybe because Brendan Eich was tasked with "doing Scheme in the browser" before it pivoted to JavaScript.
reply
lvncelot
1 hour ago
[-]
Imagine what could have been...
reply
whartung
1 hour ago
[-]
> I find a procedural style of programming so much easier to reason about, both when writing and reading.

Then do that.

There's nothing stopping you from using pretty much any style of programming that you like. Or mix and match. Or evolve over time.

Loops, lists, arrays, structures. Simple iteration: dotimes, dolist, loop. If those are your bread and butter, then feast! CL will happily do that. That's what I do. I just don't think "functionally" when I do CL code, I'm just not there yet, so its unnatural for me, and not what comes spewing out of my fingers when I write code.

And it's "OK".

You don't have to use the other features of the language, but they're there if you want to dip your toe into it.

With CL, also, I tend to be really wordy on variable and function names. I'm really fond of kabob-case-for-identifers.

reply
belmarca
1 hour ago
[-]
Gambit Scheme (https://github.com/gambit/gambit) is a highly performant Scheme implementation (https://ecraven.github.io/r7rs-benchmarks/). Gerbil (https://cons.io) is built on top of it.

Both highly recommended.

reply
goatking
1 hour ago
[-]
I just wish a good IDE existed so I don't have to use Emacs. That's what made me drop lisp in the past.

I would be happy with (neo)Vim setup as well, but that was way behind Emacs and broken when I tried.

reply
ux266478
40 minutes ago
[-]
reply
goatking
35 minutes ago
[-]
Thanks.

However, price for hobby user license at 750 USD is laughable.

reply
jacobobryant
53 minutes ago
[-]
as of now neovim works great with clojure, not sure about other lisps. vs code also.
reply
goatking
41 minutes ago
[-]
I am/was mainly interested in Common Lisp. I might give Vim another try, that would be the best if it worked. I really don't like vscode
reply
kscarlet
42 minutes ago
[-]
PSA: VSCode users deserve to use the OLIVE plugin (https://github.com/kchanqvq/olive).
reply
iFire
1 hour ago
[-]
Since this is the largest gathering of LISP users I have seen, I have a question.

Why prefer lisp-1 over lisp-2 or vice-versa?

reply
wk_end
15 minutes ago
[-]
The argument is: if you don’t have hygienic macros, a Lisp-2 is going to be less brittle than a Lisp-1.

The classic example is, imagine you have a function with a local variable called “list”, common enough. Now imagine you invoke a macro inside that function which generates a call to the built-in “list” function - also common enough. In a Lisp-1 without hygiene that breaks - your local definition shadowed the built-in; in a Lisp-2 or hygienic Lisp-1 you’re in the clear.

reply
Jtsummers
51 minutes ago
[-]
Ignoring all the other distinctions between lisps, the main difference between lisp-1 and lisp-2 (or lisp-n) is going to be how clean your code looks when you lean into the FP style. In a lisp-2 you'll need to do something like this:

  (defun apply-twice (f x)
    (funcall f (funcall f x)))

  (apply-twice #'1+ 2)
Versus this with a lisp-1:

  (define (apply-twice f x)
    (f (f x))

  (apply-twice 1+ 2) ;; assuming 1+ is defined
But there are so many other differences between the lisps in the two categories that this probably won't be the deciding factor for most people.
reply
jwr
59 minutes ago
[-]
As someone who has used both kinds over many, many years: it really doesn't matter.
reply
dismalaf
1 hour ago
[-]
IMO if we look at Lisps today the question looks more like: SBCL, Chez Scheme, Racket or Clojure.

Common Lisp and Racket are Lisp-2s but honestly, the namespace thing seems like a minor difference compared to all the other features that differentiate them.

reply
gus_massa
59 seconds ago
[-]
[Racket is a lisp-1.]
reply
hnarayanan
3 hours ago
[-]
So many words to say: Scheme.

:)

reply
nobleach
2 hours ago
[-]
Perhaps, but Chicken? Guile? Chez? They're all pretty cool.
reply
tmtvl
1 hour ago
[-]
R5RS, R6RS, or R7RS?
reply
phplovesong
1 minute ago
[-]
There is also MLs that have the same idea, but with less implementation, as a lisp is something you hack in a weekend. An working ML not, as it takes way more effort.

Lisps have many fantastic ideas, but are really hard to read. Lisp code is what we had before perl guys went "hold my beer".

I know its just syntax, and it usually does not matter, untill it does. I did some clojure a long time ago, and before that some CL, and god, i cant understand my own old code. Contrast that to some language that has syntax i can read it still, years later. Go being the prime example of write once, read a decade later.

reply
criddell
2 hours ago
[-]
Another Lisp of note is AutoLISP.

Elisp::Emacs as AutoLISP::AutoCAD. AutoLISP was my first introduction to Lisp-style language. When I first started using it (1987) for macros in AutoCAD, I really had no idea what Lisp was. It was just a fun and easy way to automate AutoCAD.

reply
hnarayanan
2 hours ago
[-]
I had forgotten about this. The last I saw this was 20+ years ago!
reply
timonoko
41 minutes ago
[-]
Adding and substracting 3D-objects was the same as in OpensCAD.

Strange they did not make OpenSCAD in AutoLISP-style.

I have to read the manual all the time, because I never learn the weird syntax of OpenSCAD for-statement.

reply
wollowollo
2 hours ago
[-]
I wonder if Hylang is still alive.
reply
bbkane
1 hour ago
[-]
reply
BoingBoomTschak
2 hours ago
[-]
(Disclaimer: CL weenie) A decent and balanced writeup IMO. But it should really have contained the following:

Warning about the issues that come with ANSI CL's frozen spec (threads/sockets/unicode/extensible sequences/gray streams/etc... as extensions with a varying amount of support with compatibility layers often available to write portable-ish code, "bolted-on" CLOS never fully integrated) and its various rust spots, not just the good points.

Mention that CL has provisions for gradual typing (with limits) which are exploited by SBCL.

Scheme, obviously, along with the same warning as CL about pain of writing portable code that interacts with the OS (does it have compatibility layers like CL?) amplified by the R6RS vs unfinished R7RS-large mess.

A few words about the build system/third-party packaging situation and alternative implementations.

reply
ynniv
2 hours ago
[-]
I have a work-in-progress called Modus. 100% written by Claude, so take that however you will. The current release boots on a Raspberry Pi Zero 2 W. The next release (unreleased in the pipe for ~ months) is standard Common Lisp on bare aarch64 (pi) and x64 (qemu for now), with linux aarch64 and x64 command line interfaces à la sbcl.

https://github.com/modus-lisp/modus

Since you can't use an OS by itself, I've rounded out the Common Lisp environment with portable ssh client and server, web browser, and a bitcoin node. Framebuffer with VNC in the pipe

reply
whartung
1 hour ago
[-]
That's pretty neat!

God help me if I fell down a hole like that.

I must say, however, that e.g. code like (compile-compound) is something only an AI can love!

reply
ynniv
1 hour ago
[-]
i've spent decades reading and writing code. i just want something that works
reply
davidw
1 hour ago
[-]
When people have a lot of choices, that can create problems, because it's often the people with the least information trying to make that choice.

For instance "I'm new to Lisp, I want to try one..." is a person without a lot of background and information to make that choice. And they probably realize it and it makes them nervous about making that choice.

See: https://en.wikipedia.org/wiki/The_Paradox_of_Choice

reply
ChrisArchitect
2 hours ago
[-]
Related:

A road to Lisp: Why Lisp

https://news.ycombinator.com/item?id=48845209

reply