Beautiful Racket: An introduction to language-oriented programming using Racket

nil

Matthew Butterick. Beautiful Racket: An Introduction to Language-Oriented Programming Using Racket. 2024.

Racket positions itself as a “programmable programming language” – more so than Lisp’s usual claim to this title – which makes it attractive for exploring multi-paradigm and multi-language programming.

Racket’s main claim to a niche is allowing a programmer to define new domain-specific languages (DSLs), not necessarily Lisp-like, that can be combined together to let a program be expressed in the “most appropriate” form for the problem. This books is structured around exactly this idea, defining a succession of languages of increasing sophistication to demonstrate Racket’s capabilities. Each language has a “reader” to convert strings into Lisp S-expressions and an “expander” to translate these forms into Racket (or another Racket-defined language). The examples include a simple stack-based calculator, an embedded JSON parser, and a Basic interpreter that exercises the power of a full parser.

The description of Racket itself is very thorough, to the extent that this book could be treated as a language definition itself, complementing the article about it. Certainly it provides the most accessible way to learn the language and explore what it means to explore “language-oriented” programming.

It’s possible to define DSLs in Common Lisp or Scheme without Racket’s extra functionality, and in many cases that will be sufficient – especially when the DSL is a Lisp itself. But there will certainly be applications for which Racket is absolutely the right tool.

(Part of the series An annotated Lisp bibliography.)