Building programs#

Des langages comme Fortran, C, C++ et Java, pour n’en nommer que quelques-uns, partage certaines caractéristiques : vous écrivez du code dans le langage de votre choix mais vous devez ensuite compiler à partir de ce code source. D’autres langages sont interprétés — le code source est analysé par un programme spécial et est considéré comme des instructions directes. Deux exemples très simples de ce type de langage : les fichiers batch sur Windows et les scripts shell sur Linux.

In this tutorial we concentrate on the first type of languages, with Fortran as the main example. One advantage of compiled languages is that the build process that you need to build an executable program, is used to transform the human-readable source code into an efficient program that can be run on the computer.

Remark: this tutorial gives examples for the Windows and Linux operating systems, however the workflow and general principles still apply to macOS.

Langages compilés#

Voyons un exemple simple :

program hello
    write(*,*) 'Hello!'
end program hello

C’est le programme le plus simple que vous puissiez écrire en Fortan et certainement une variation d’un de programmes les plus connus. Même si c’est simple à exprimer dans le code source, beaucoup de choses se passent lorsqu’on lance l’exécutable construit à partir de ce code :

  • A process is started on the computer in such a way that it can write to the console — the window (DOS-box, xterm, …) at which you type the program’s name.

  • It writes the text « Hello! » to the console. To do so it must properly interact with the console.

  • When done, it finishes, cleaning up all the resources (memory, connection to the console etc.) it took.

Fortunately, as a programmer in a high-level language you do not need to consider all these details. In fact, this is the sort of things that is taken care of by the build process: the compiler and the linker.