Becoming the Metaprogrammer Real World Code Generation
summary
Code generation cuts boilerplate by producing real, typed code: tools like sqlc and mockgen are used at ngrok to replace repetitive DB scanning and handwritten test mocks, and JSON marshalling generators (ffjson-style) speed serialization by avoiding reflection. A YAML-driven error compiler generates type-safe error functions and exportable error codes for multiple languages and it works in practice. Best practices include go generate, adding a “do not edit” header, isolating generated files, and preferring simple string templates plus a final gofumpt step.
AI-written summary · about
chapters (14)
- 0:00Introduction
- 1:13What is Code Generation
- 4:05Why Code Generation
- 5:15stringer
- 7:18mockgen
- 12:59C Preprocessor
- 14:31ProtoC
- 16:54GoTest
- 19:39Browser Code Generation
- 21:49Typescript
- 22:29Code Generation
- 25:26Userfacing Errors
- 32:56Best Practices
- 41:07Recap
related talks
36mGenerating code in Go
51mGenerate You Some Code for Great Good
30mWrite Less (Code), Generate More
36mCode Generation to Survive
37mThings I learned after a decade of writing code generators
51mCode generation tips you didn't ask for
38mCode Generation and How to Use It Effectively
53mCode Generation: ....
