The code I never had to write
Metaprogramming is the practice of writing programs that inspect, generate, or transform other programs. In Nim, that usually means taking a small piece of source code and turning it at compile time into ordinary, statically typed Nim. That transformation is what has kept me interested in metaprogramming over the years. I enjoy finding a small description that captures what the programmer means, then letting the compiler expand it into the larger amount of mechanical code the program needs. The generated code is not necessarily clever. Often it is exactly the tedious code I would have written by hand, and am pleased never to write again. Three of my libraries show how my use of this idea has developed: protocoled , an early macro-based interface experiment; smartcli , which generates a typed command-line parser from help text; and dokime , which validates SQL against SQLite and generates typed query code. protocoled: generating an interface I wrote protocoled in the Nim 2 era...

