Metaprogramming in Non-Lisps

Lisp certainly isn’t the only language family with metaprogramming facilities. C has a macro system that allows textual replacement as a preprocessing step at the start of compilation. C++ has a complex and powerful template metaprogramming feature that’s itself Turing-complete. Plenty of dynamic languages, like JavaScript, Python, and Ruby, have eval functions that acts on strings to produce a result. Ruby, in particular, has quite a few nice features, and Scala’s macro system even allows you to manipulate the parse tree! But here’s fair warning: once you’ve experienced Clojure’s macros, you may not want to go back.

You may notice that in this book, sometimes I’ll refer to Clojure, and sometimes to Lisp in general ...

Get Mastering Clojure Macros now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.