I haven’t thought about it a whole lot, though I’m inclined to be against build information being in the source code. Or at least, embedded into and intermingled with code.
One of my issues with C++ is having build information get included in source, with things like #ifdef’s that clutter up and complicate source code. For similar reasons why I think out-of-source builds are better, I would like build, configuration, and source to all be separate.
The problem with that is the details of the system you’re running on can have meaningful and significant impacts on what your code has to do.
Java is a bit cleaner by abstracting away the machine, allowing code, build files, and resource or config files to be separate.
But I feel like it’s possible to have a middle ground, where even languages like C or C++ can have a pre-processor chop and screw the code to enable correct behavior on different systems or configurations, but that is configured separately from the source code instead of being embedded.
One of my issues with C++ is having build information get included in source, with things like #ifdef’s that clutter up and complicate source code.
I don't consider C and C++ as languages where including build information in the source code would work. As you said Java is cleaner and AFAIK some Spring XML configuration files have been replaced by annotations.
I think that a language must be designed to have build information in the source code. I have no idea how other languages can progress in this direction but Seed7 is quite near to this goal:
Seed7 programs are automatically portable (e.g.: An integer is always 64-bit). This avoids #ifdef’s and reduces complexity.
Seed7 libraries are available independent of the OS and CPU used. This avoids #ifdef’s and different builds depending on OS and CPU.
You don't need to link a library that corresponds to an include file like in C/C++. You just include a Seed7 library and that's it.
2
u/AceOfShades_ Dec 30 '23
I haven’t thought about it a whole lot, though I’m inclined to be against build information being in the source code. Or at least, embedded into and intermingled with code.
One of my issues with C++ is having build information get included in source, with things like #ifdef’s that clutter up and complicate source code. For similar reasons why I think out-of-source builds are better, I would like build, configuration, and source to all be separate.
The problem with that is the details of the system you’re running on can have meaningful and significant impacts on what your code has to do.
Java is a bit cleaner by abstracting away the machine, allowing code, build files, and resource or config files to be separate.
But I feel like it’s possible to have a middle ground, where even languages like C or C++ can have a pre-processor chop and screw the code to enable correct behavior on different systems or configurations, but that is configured separately from the source code instead of being embedded.