Hacker News new | past | comments | ask | show | jobs | submit login
The Common Lisp Cookbook (lispcookbook.github.io)
248 points by ghosthamlet on May 23, 2019 | hide | past | favorite | 27 comments



Hi!

I'm one of the (less active) maintainers. Four years ago I migrated the CL cookbook from sourceforge where it'd been gently resting for quite a few years (nearly a decade), and put it onto github, put together a CI system, and away it went. A few volunteers have been diligently working away on improving it, particularly `vindarel`, who has really taken the lead for content work in the last couple years as I've been pulled away by other things.

since 2015 we've had 492 commits into git, and these fine people have contributed to the git tree:

      Alexander Artemenko
      Andrew
      Andrew Hill
      Ben Dudson
      Burhanuddin Baharuddin
      chuchana
      Danny YUE
      Dmitry Petrov
      Fernando Borretti
      HiPhish
      Johan Sjölén
      Kevin Layer
      LdBeth
      Momozor
      Nisar Ahmad
      Nisen
      otjura
      Paul Donnelly
      Pavel Kulyov
      Pierre Neidhardt
      Salad Tea
      Victor Anyakin
      vindarel
      Vityok
      YUE Daian

thanks be to the contributors!

I'll be around to answer any Qs for an hour or two, then I'll keep an eye out tomorrow!


Love seeing a Lisp Cookbook pop up on HN.

Had a general question about CL. What advantages does it have over things like Racket and Chicken? And how could I potentially pitch the language to a non-dev?


It's defined by an ANSI standard; see (http://clhs.lisp.se).

There are a handful high-quality implementations, both free and commercial, many of which can generate efficient native code. When you can stick to the standard, you can reasonably expect your code to work across implementations and platforms.

The existence of the standard also means that you can often use code that is decades old with few changes. Furthermore, there are actually bodies of old code that you might want to use, because of its relatively common use in AI and academic communities in the 80s and 90s. See, for example (https://www.cs.cmu.edu/Groups/AI/0.html).

It's designed to support interactive programming to a greater extent that any other language except perhaps Smalltalk. For example, the ANSI standard defines functions you can use to change the definitions of classes at runtime and have existing instances automatically updated to use the new definitions.

Like Racket and Chicken, it has a good library ecosystem. The ecosystem is supported by a good package manager (https://www.quicklisp.org/beta/). That package manager is in turn supported by a decent documentation-search site (http://quickdocs.org).

Several Common Lisp implementations support easy delivery of programs as a single, self-contained executable. The buildapp library (http://quickdocs.org/buildapp/) shows how this may be done in a cross-implementation way by supporting both SBCL and CCL.

The Common Lisp community has been around for decades, as have some of its prominent members. There's a ton of useful, practical knowledge in the community. It does have a bit of an unfriendly reputation, and that's sometimes deserved, but with some patience and persistence you'll find that it also contains friendly and helpful people who know a lot about the language and its effective use.

You can find a guide to the community here (https://common-lisp.net/community).


I'd pitch:

- it's all interactive and that's a productivity boost. Write a function, compile it (yes, compile function by function), see warnings or get a debugger on errors, try it right away. Same for web development. No process has to restart to test your changes.

- build a self-contained executable: a joy to deploy.

- strong typing, catches many common errors (and coming: an ML extension for CL: https://github.com/stylewarning/coalton, already used in a large Rigetti codebase)

- stable.

- fast

- take in every language feature you want with libraries

- parenthesis: they help to edit code by structure, by semantic units, instead of by line or characters.

- most flexible language. Like Python's decorators or context managers ? Yet they're limited and have their idiosyncrasies.

- unmatched object system, with generic functions that help maintain your logic small.

And there are libraries :] https://github.com/CodyReichert/awesome-cl


Upsides: Many muture implementations both commercial and opensource (SBCL, LispWorks, Franz Lisp).

Can be very fast.

Less opinionated than Scheme/Racket. Supports FP, imperative, and OOP.

Supports system images where you can hack on running images to avoid downtime. Racket doesn’t support this.

Great debugging from the REPL.

Probably the most advanced exception/error system of any language.

Easy to learn (and powerful) macros.

ANSI standardized.

Powerful object system.

Downsides: Dynamic typing (some people might not have a problem with this).

No match statements.

Huge and complicated standard. Many unnecessary and unused/dead features.

Inconsistent and not orthogonal in the least. Multiple functions that do the same thing but have different argument orders or inconistent names.

A little low level compared to Racket. This might be a positive if you want C-like performance.

Not the greatest libraries compared to Racket. Documentation is often bad or non-existent.

Hard to learn effectively. Language gives little guidance on how it should be used.


There's the very good Trivia library for pattern matching: https://lispcookbook.github.io/cl-cookbook/pattern_matching....

(and I think libraries are better maintained that Racket's)


Congratulations on the efforts.

Is there any way to also get an epub out of it?



Thanks for sharing.


If you do, keep in mind that it's a continuous work in progress - the book keeps changing and a statically-generated ebook might not reflect that.


Sure, I just find reading it on a kindle is more confortable than regular screens.


not offhand. I really should sit down and examine that in relation to our build pipeline.


Thank you and all of the contributors for this, it's basically an essential tool for me when writing common lisp.


Another excellent companion with the Cookbook is `Common Lisp Recipes` by Edi Weitz. Edi Weitz is a profilic CL programmer and his libraries are worth their weight in gold.

Anyone learning CL must read his code if I were to say to learn from a master.

[1] http://weitz.de/cl-recipes/ [2] https://github.com/edicl


For a Vim user, what is a good plugin to provide SLIME like paredit and REPL capabilities for programming in Common Lisp? Is there a clear winner plugin in Vim like there is SLIME for Emacs?


Steve Losh in his already-classic CL blog post [^1] suggests either Vlime or Slimv, quote:

„If you’re like me and already have Vim burned too deeply into your fingers to ever get it out, I’d recommend Vim with Vlime. It will give you 80% of the experience you’ll get with Emacs.”

If you want 100% of SLIME goodness without sacrificing vim, try spacemacs [^2]. I switched about two years ago and am very happy.

[1]: http://stevelosh.com/blog/2018/08/a-road-to-common-lisp/#lis... [2]: http://spacemacs.org


I'm in the process of switching after many years of using vim, and it’s been incredible so far. Spacemacs really is like vim, only with way more features out of the box, and way better discoverability, so it's really quick to get up to speed.


> If you want 100% of SLIME goodness without sacrificing vim, try spacemacs.

Or just Evil + Evil-collection. Spacemacs is pretty bloated.


I have not heard before about evil-collection. I have thought about having a custom setup, but my .spacemacs has grown a bit, so it's going to be a major work. I will try it at some point, just to check my elisp-fu

Thanks for the tip!


Serious suggestion: http://spacemacs.org/

> The best editor is neither Emacs nor Vim, it's Emacs and Vim!


Offtopic, but I’ve been using Emacs for ages and my fingers hurt.

Are vi keybindings better. Can I edit things more quickly?


Yes absolutely.

http://wikemacs.org/wiki/Evil

For a spacemacs experience, see also which-key-mode.


I'm not sure I can say, as I learned Vim before Emacs. But you'll definitely have less chance of RSI


slimv is pretty good


Big discussion 2 years ago:

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

(Provided for interest purposes. It doesn't qualify as a dupe - https://news.ycombinator.com/newsfaq.html)


Great to have support still.


What is the best (video?) tutorial for learning how to use slime with cl in spacemacs?




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: