Does it make sense to write build scripts in C++?

Posted by Klaim on Programmers See other posts from Programmers or by Klaim
Published on 2012-04-04T14:34:16Z Indexed on 2012/04/05 5:42 UTC
Read the original article Hit count: 204

Filed under:
|
|
|

I'm using CMake to generate my projects IDE/makefiles, but I still need to call custom "scripts" to manipulate my compiled files or even generate code.

In previous projects I've been using Python and it was OK, but now I'm having serious trouble managing a lot of dependencies in two very big projects I'm working on so I want to minimize the dependencies everywhere.

Someone suggested to me to use C++ to write my build scripts instead of adding a language dependency just for that. The projects themeselves already use C++ so there are several advantages that I can see:

  • to build the whole project, only a C++ compiler and CMake would be necessary, nothing else (all the other dependencies are C or C++);
  • C++ type safety (when using modern C++) makes everything easier to get "correct";
  • it's also the language I know the better so I'm more at ease with it even if I'm able to write some good Python code;
  • potential gain in execution speed (but i don't think it will really be perceptible);

However, I think there might be some drawbacks and I'm not sure of the real impact as I didn't try yet:

  • might be longer to write the code (that said I'm not sure because I'm efficient enough in C++ to write something that work quickly, so maybe for this system it wouldn't be so long to write) (compilation time shouldn't be a problem for this case);
  • I must assume that all the text files I'll read as input are in UTF-8, I'm not sure it can be easilly checked at runtime in C++ and the language will not check it for you;
  • libraries in C++ are harder to manage than in scripting languages;

I lack experience and forsight so maybe I'm missing advantages and drawbacks. So the question is: does it make sense to use C++ for this? do you have experiences to report and do you see advantages and disadvantages that might be important?

© Programmers or respective owner

Related posts about c++

Related posts about builds