Common Lisp vs Racket
I&#x27;m a heavy user of Common Lisp, and I only dabble in Racket from time to time. While Common Lisp is my tool of choice for a lot of reasons stated in the post, since the post largely skews favorably toward Common Lisp, I&#x27;ll offer two things that Racket shines at:<p>1. Documentation<p>Racket has a beautiful documentation system called Scribble [0]. Almost all documentation written for Common Lisp is ugly, inconsistent, and doesn&#x27;t follow any sort of standard. Common Lisp has a gazillion &quot;documentation generators&quot; which do little more than slurp up all the documentation strings and barf them back out as e.g. HTML. Common Lisp users tend to just rely on READMEs + jump-to-definition to learn how a project works. A few Lisp programmers (e.g., Shinmera, Edi Weitz) have made their own documentation systems that look better than average, but are still at least an order of
magnitude less capable than Racket&#x27;s offering.<p>Racket&#x27;s documentation system is aesthetically pleasing, very well organized, and makes the programmer <i>want</i> to write long-form documentation. Moreover, Racket (the language) sets a superlative example
of what its users can strive for in terms of quality of clear, no-nonsense writing.<p>2. Languages and DSLs<p>One of Lisp&#x27;s (any dialect) defining features is the ability to build domain-specific languages, syntactic extensions, and the like by way of a special kind of function that can run prior to the code&#x27;s execution. These special functions are called &quot;macros&quot;, and across Lisp dialects, there are lots of different takes on them.<p>Common Lisp gives you a grab bag of facilities for writing code that lets you change syntax at different levels: DEFMACRO (scoped variant: MACROLET), DEFINE-COMPILER-MACRO, DEFINE-SYMBOL-MACRO (scoped variant: SYMBOL-MACROLET), SET-MACRO-CHARACTER, and a few others. At best, I&#x27;d consider these only loosely related, and they all work on really &quot;raw&quot; data representations (parsed S-expressions and character streams). In part because of this, ANSI Common Lisp doesn&#x27;t provide access to any notion of environment, source location, etc. when writing new macros.<p>Macros defined by the above operators &quot;live&quot; in different places and are compartmentalized in different ways. There are some Lisp libraries that help you tame definitions and keep them fenced in, like NAMED-READTABLES which helps you organize where reader macros (macros which change how Lisp is parsed at the character-level) live and how to turn them off and on in a sane way.<p>Contrast with Racket which has explicit documentation on how to write macros [1,2], how to debug them [3], and how to encapsulate them a new DSL embedded in the system [4]. Racket—as a technical system—clearly defined the phases of compilation, what objects are manipulated during the phases (e.g., &quot;syntax objects&quot;), how to provide debugging information, and so on.<p>In the end, Common Lisp&#x27;s system for making DSLs feels a little runny. It&#x27;s supremely hacker-friendly, but it&#x27;s a bit more difficult to deliver, in one fell swoop, a language as a library. Racket, on the other hand, at the expense of having increased rigidity and needing to read two or three complete chapters of a manual, you get a way to neatly bundle up a language. This is why Racket had nice DSLs like Typed Racket, Hackett, Scheme RnRS, etc.<p>I use Common Lisp and I develop relatively large DSLs in the language, and even if I want to, it&#x27;s hard—if not impossible—to write large DSLs that have nice error messages, source locations, etc. without writing an entirely new &quot;reader&quot; (lisp&#x27;s term for a code parser) myself every time. Smaller DSLs where user code doesn&#x27;t exceed more than a few lines? Examples like:<p>- regex syntax<p>- string interpolation syntax<p>- a pattern matching feature<p>Common Lisp is great, and you get a ton of mileage out of the facilities it provides. But larger ones? Examples like:<p>- an embedded language for writing documentation with markup<p>- a <i>complete</i> language with lazy evaluation semantics<p>- a language for non-deterministic programming (like SCREAMER, Prolog)<p>- a language for strictly typed functional programming (like Coalton, Hackett)<p>Tackling these in Common Lisp requires ambition and a very steady hand, whereas Racket&#x27;s overall system (language, implementation, documentation) makes that a comparatively painless exercise.<p>[0] <a href="https:&#x2F;&#x2F;docs.racket-lang.org&#x2F;scribble&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.racket-lang.org&#x2F;scribble&#x2F;</a><p>[1] <a href="https:&#x2F;&#x2F;docs.racket-lang.org&#x2F;guide&#x2F;macros.html" rel="nofollow">https:&#x2F;&#x2F;docs.racket-lang.org&#x2F;guide&#x2F;macros.html</a><p>[2] <a href="https:&#x2F;&#x2F;www.greghendershott.com&#x2F;fear-of-macros&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.greghendershott.com&#x2F;fear-of-macros&#x2F;</a><p>[3] <a href="https:&#x2F;&#x2F;docs.racket-lang.org&#x2F;macro-debugger&#x2F;index.html" rel="nofollow">https:&#x2F;&#x2F;docs.racket-lang.org&#x2F;macro-debugger&#x2F;index.html</a><p>[4] <a href="https:&#x2F;&#x2F;docs.racket-lang.org&#x2F;guide&#x2F;languages.html" rel="nofollow">https:&#x2F;&#x2F;docs.racket-lang.org&#x2F;guide&#x2F;languages.html</a>