Wednesday, 3 December 2014

Why a Build System in IDEs Era?

Some friends of mine criticized my old post «Build your C/C++ programs everywhere with SCons», arguing a build system is useless in modern world.

 BUT, even if it's true that IDE are really helpfull, those friends forget some important facts
  1. Ant, Maven, SCons, Gradle, CMake are used today
  2. The most ancient are Ant, Scons and CMake of 2000 (not so old)
  3. Gradle first released version was in 2009-07-20, so quite recent
  4. Android projects use Gradle as build system
  5. libGDX uses Gradle too
So, build systems still exist and even somebody continue to develop these old tools. Why? Well, let's to understand what's a build tool, first.

What Is a Build System?

A build system is a software responsible to manage compilation of source code and other useful tasks, such as build a JAR file from these sources or upload it or signing your executable. They are used for compiled languages, to keep track of what compile again and what is not necessary. Let's suppose we are working on a C project with following sources
  • User.h + User.c: a struct to contains user informations
  • List.h + List.c: data structure to store Users
  • main.c: our main program
These sources have a hierarchy: main depends on List and User; List depends on User. But C language ignores dependencies among source files. It doesn't know what to compile first. And, when you have just modified one source, we would like to do not compile unchanged sources. Have you ever tried to compile Firefox? Think about to do it every time you change a single character. To avoid these problems, we must use a build tool. The most famous is Make, but I also like SCons.

...but a IDE Does it For Me!

Yes, and it's a good thing. IDEs are basically a front-end for your build system. Yes, they have plugins to do many things graphically and they provide GUIs for many console utilities (diff, VCS, debugger and, obviously, build tools).
You can live happily without use directly a build tool. But sometimes could be usefull to know what's under the hood of your IDE. Also, know your build system could help you in your work: not all function exposed by your GUI could be exaustive for your task. Maybe, upload your compiled C program to a remote server and copy some lua script on the same repository could be usefull.

A Question of Portability

Why all projects on GitHub or on Sourceforce are so... simple? 'cause they are composed just with their source files and their build script. This ensure you to use your favourite IDE to help a project. Eclipse, Netbeans and XCode can use different build system. So, with a single build script, you can use your IDE of choice.

Should I Stop Using a IDE?

No, of course! Continue coding with Eclipse or with Netbeans! But please, don't blame who's using a command line to manage his programs :)

No comments: