Macros Don’t Belong In a Language
2026-03-15
Macros don’t belong IN a language, they belong BEFORE a language.
There is no longer (in 21st century) any reason to build a language as a single thing.
A “compiler” should be a pipeline.
Preprocess, then compile.
In the 20th century this approach was considered to be too expensive, but with 21st century hardware, this is 1000x cheaper (or more).
Winding macros INTO languages causes time-wasting, like thinking about macro hygiene. Macro expansion is a separate language - hygiene no longer an issue.
Macro expansion is a language of t2t (text-to-text) which is something different from the main purpose of creating a programming language for generating machine code.
Macros == fancy code editing features, like in a code editor, like emacs or whatever.
Macro-expansion is definitely a looping concept - expand, try again, expand, try again, …, but, this becomes insanely complicated and convoluted if you conflate the expansion process with the compilation process.
There is only one programming language - machine code - everything else is just semantic sugar that helps you generate machine code faster.
See Also
Email: ptcomputingsimplicity@gmail.com
Substack: paultarvydas.substack.com
Videos: https://www.youtube.com/@programmingsimplicity2980
Discord: https://discord.gg/65YZUh6Jpq
Leanpub: [WIP] https://leanpub.com/u/paul-tarvydas
Twitter: @paul_tarvydas
Bluesky: @paultarvydas.bsky.social
Mastodon: @paultarvydas
(earlier) Blog: guitarvydas.github.io
References: https://guitarvydas.github.io/2024/01/06/References.html


The pipeline-based compilation was already applied in the past. Here some examples:
1) C compilers
They work as a two-step pipeline:
_ expansion of macros, constants and inclusion of header files, by the C preprocessor.
_ conversion of source code in machine code.
2) Ratfor compiler
Ratfor is a programming language for numerical calculation, invented 1976 by Brian Kernighan (who was the co-inventor of C language). It is implemented as a preprocessor for Fortran 66. The code generation follows this pipeline:
_ conversion of Ratfor in Fortran 66.
_ conversion of Fortran 66 to machine code.
Ratfor was invented for providing the free form and the modern control statement to numerical programmers, overcoming the limitations of Fortran 66.
https://en.wikipedia.org/wiki/Ratfor
3) Objective C compiler
The first compiler for this language was implemented by Brad Cox as a preprocessor for C language:
https://en.wikipedia.org/wiki/Objective-C