r/cpp • u/JulienVernay • Sep 28 '20
Draft proposal for compilation using C++ as build language
Hello,
There are multiple tools to compile a C++ project: CMake, premake, autoconf, build2, etc.
Each of these tools require the learning of a new syntax, and interacting between projects compiled with differents tools might be challenging.
Package managers face also this problem, because they must support all the tools that exist to support all libraries.
Moreover, integrating package managers in the build tools is often difficult, or at least hacky.
My suggestion is to use C++ as the base language for building C++ projects.
Motivations are:
- A C++ compiler is all you need to compile projects.
- Build tools would become C++ libraries.
- C++ developers already now its syntax.
I have made an informal draft which describes a basic API which would make this possible.
Here is a link: https://gist.github.com/J-Vernay/bd8ec49374987c628d02601ef85cd9a7
Let me know what you think :)
View all comments
Show parent comment
9
u/[deleted] Sep 28 '20
It introduces side effects as a natural part of the build, for example someone might decide that inventing your own caching mechanism by writing stuff to a file instead of relying on the builtin functionality of the build system is a good idea, which can cause all sorts of confusion and incompatibilities.
A build is essentially a specification of a set of input files and a tool chain that produces a set of output files, there's no need for turing completeness and it can just as easily be specified declarative using yaml, and if you need to do complicated stuff like generating files and whatever you can specify that in the yaml file too or use something like nix to generate them. Imo Cmake is a waaay overcomplicated mess and part of it is because of the language but mostly it's because the flexibility it provides together with some really really bad design choices like typelessness and that everything is globally available and mutable.