Writing/Book
Metaprogramming:
An Adventure
Metaprogramming is the practice of writing code that operates on other code: inspecting, modifying, even generating programs from scratch. It's incredibly powerful, somewhat underrated and understudied – and most importantly, incredibly fun.
I've been fascinated with this sorcery since I first encountered it. I've written plenty of useful code employing it, but the moment it became "work", it shifted into the realm of "advanced programming techniques". This book contains a bunch of those practices, but I've tried to tell it as an adventure.
For me, metaprogramming isn't something to learn for any serious purpose. Concrete goals narrow our vision; playing lets our imagination run wild, experiment and stumble onto innovation. We can later refine those discoveries into practical techniques, but novelty often begins with uninhibited, irreverent joy.
That joy is what I'd like to impart: a sense of wonder. Even with AI doing most of our coding nowadays, I hope you'll enjoy these strange and beautiful ideas as much as I enjoyed exploring them.
Start readingContents
- 01 Introduction
- 02 Tracer Tricks
- 03 Bytecode Manipulation
- 04 Dynamic Code Execution
- 05 Shell Autocompletion
- 06 Aspect-Oriented Programming
- 07 Domain-Specific Languages
- 08 A Metaprogramming Layer
- 09 Source Code Manipulation
- 10 Runtime Serialization
- 11 A Templating Engine in 20 Lines
- 12 A Metaprogramming Framework
- 13 Code Generation