4 ms·
It seems that C developers tend to use Turing-complete scripts for building instead of a declarative language. Using scripts means that build configuration cann
by codedokode 2y ago
It seems that C developers tend to use Turing-complete scripts for building instead of a declarative language. Using scripts means that build configuration cannot be processed by automated tools for extraction of information or modification. Why don't you want to use declarative build configuration?
- GrantMoyer 2y agoIn my experience the short answer is that there are no declarative build tools for C or C++. The longer answer is that there are no declarative build tools because all the build tools aim to support all the insane build requirements of existing C or C++ projects. At that point embedding a turing complete scripting language actually makes for simpler build descriptions than some massive declarative system trying to handle all the corner cases. Of course, that raises the question: why don't any C or C++ build tools limit themselves to some sane subset of build requirements? That, I don't have a good answer for.
- mid-kid 2y agoIn general this exists in order to detect features of the target compiler, libraries, platform and etc. A lot of languages can get away with making assumptions, due to either having only one implementation/compiler, supporting very few platforms/architectures or being otherwise insensitive to the environment.
- juxtapose 2y agoI think I'm for Turing-completeness. Let me try to give my reasons... 1. No, using Turing-complete scripts does not prevent information extraction and meaningful automation. You can ask the program to dump useful information, e.g. targets, compiler flags, etc. That's what rizsotto/Bear does for Makefile. CMAKE_EXPORT_COMPILE_COMMANDS is another example. 2. I don't really think you can do anything further with declarative build languages, unless it is a really limited one like JSON or XML. Meson (a relatively advanced one in the space) advocates for non-Turing-completeness, but you still cannot, for example, modify meson build files reliably using an external tool other than a text editor. 3. Complex build configuration usually requires non-trivial computation and/or dynamic dependency graph building. Turing-completeness gives you a possibility and you don't need to wait for build tool upgrades. Comparing Meson to CMake, I find the niceties of Meson are usually not inherently non-TC. That is, you can theoretically reimplement a nicer CMake with all the niceties of Meson, while still being TC.
- JonChesterfield 2y agoMakefiles are mostly declarative and very definitely turing complete when you want that. That's a good compromise, simple stuff is simple and complex stuff is possible. All a rigidly non-turin-complete build tool means is the day will come where you have to throw it away and rewrite everything in a more powerful language, probably at the last minute and with a bunch of fires taking light around you.