Metaprogramming in Racket: A Guide to Macros and Language Design

ANT

$5.99 $9.99You save $4.00
Format
Digital edition
PDFEPUB
Works on phone, tablet and computer Instant access after checkout Personal-use digital license
About this edition

• Instant access to your digital edition.
• Read anytime, anywhere, on your favorite device.
• No shipping — your book is delivered digitally.
• Simple, secure access after purchase.

Published date November 30, 2025
Author Charles C. Wright

Instant digital delivery after purchase.

Download link available immediately after checkout.
In stock
Quantity
Secure checkout — encrypted end to end Free exchange or return within 30 days if the product is defective. Digital formats available instantly
Readers also enjoyed

Discover another great read to add to your digital library.

$5.99 $9.99

Description

Have you ever looked at your own code and felt like a human compiler?
You find yourself writing the same patterns over and over again. You copy-paste a block of error-handling logic, changing only one variable. You manually validate JSON configurations because the language has no way to check them for you. You write boilerplate code that serves the machine, not the logic.

You are trapped in Phase 0 —the runtime. You are stuck obeying the rules of the language.
But there is another world. It exists in the split second before your program runs. This is Phase 1 : The Expansion Time. In this space, the code is still fluid. It is soft clay, waiting to be sculpted.

This book is your invitation to step behind the curtain. We will look at the Macro Expander , the engine that drives Racket. We will explore the concept of Homoiconicity , where code and data are the same thing. You will learn that what looks like a function call might actually be a program that writes other programs.

We will climb the Tower of Phases , a concept that baffles many developers, and demystify the difference between compile time and runtime. You will learn to break the rules of Hygiene —the safety mechanism that keeps variables distinct—so you can intentionally inject variables into your user's scope.
By the end, you won't just be writing Racket. You will be building your own languages to replace it.

What's inside This book is a comprehensive curriculum designed to take you from a complete novice in metaprogramming to a professional language designer.

The Philosophy of Rewriting: Understand why Racket treats code as Syntax Objects carrying source location and lexical scope, rather than just raw text. Pattern-Based Macros: Master syntax-rules to create clean, hygienic syntactic sugar like while loops and list comprehensions without writing complex logic. Breaking Hygiene: Step down to syntax-case to manually manipulate syntax, break scoping rules intentionally, and create anaphoric macros that introduce variables like it or self automatically. The Modern Standard: Learn syntax-parse , Racket’s professional macro system. Define reusable Syntax Classes to validate input grammar and produce helpful, precise error messages that guide your users. The Phase Tower: Finally understand the separation between Compile Time and Runtime. Learn how to use begin-for-syntax and cross-phase persistence to manage state during compilation. Language Creation: The ultimate goal. Learn to write a Reader and Expander to create a #lang. We walk through a case study of building a safe, JSON-like configuration language that compiles to strict Racket structs. Who it's meant for This book is for:

Racket Developers who want to move beyond basic functional programming and unlock the full power of the ecosystem. Language Enthusiasts who are curious about how compilers, parsers, and macro expanders work under the hood. Senior Engineers tired of writing repetitive boilerplate code who want to build smarter tools for their teams. Polyglots coming from Rust, Julia, or Elixir who want to understand the theoretical roots of the macro systems in those languages. You do not need to be a compiler expert to read this book, but you should be comfortable with the basics of Racket or a similar Lisp-family language.
Stop acting as a translator between your ideas and the computer. Stop waiting for language designers to give you the features you need. Open the hood, take control of the compiler, and build the language you have always wanted to use.

Read Metaprogramming in Racket today and start rewriting the rules.

Specifications

FormatEPUB, PDF
LanguageEnglish

Frequently asked

Do I need an account to download?

No. After purchase, you can access your ebook directly from the order confirmation or download page.

What if a copy arrives damaged?

Contact us and we’ll help you access the file or provide a replacement download if needed.

Reviews

5★84%4★11%3★3%2★1%1★1%
See all reviews

Customers also downloaded