This text is superseded by https://gist.github.com/djedr/7d21eac05ce2bbbca29b29d532a1fbe4.
There are some reasons listed here. To expand on that, using the C preprocessor with JavaScript project also gives us an easy way to share constants between different files. Back-end (Node.js) and front-end (Angular, React). But you can also share constants between .js files and .css files or any other text formats. No fuss. Just #include "constants.cpp".
Macros that operate on plain text are more limited and sloppier than macros that operate on syntax trees, like sweet.js. But they are also simpler. And very often enough.
Also:
- cpp is simple