1.2. DEVELOPMENT TOOLS 5
• Compilers. A compiler translates the source code to target code. The target code may be the machine
language for a particular platform or embedded device. The target code could be another source
language; for example, the earliest C
++
compiler translated C
++
into C, another higher-level language.
The resulting C code was then processed by a C compiler to produce an executable program. C
++
compilers today translate C
++
directly into machine language.
The complete set of build tools for C
++
includes a preprocessor, compiler, and linker:
– Preprocessor—adds to or modifies the contents of the source file before the compiler begins
processing the code. We use the services of the preprocessor mainly to #include information
about library routines our programs use.
– Compiler—translates C
++
source code to machine code.
– Linker—combines the compiler-generated machine code with precompiled library code or
compiled code from other sources to make a complete executable program. Most compiled
C
++
code is incapable of running by itself and needs some additional machine code to make a
complete executable program. The missing machine code has been precompiled and stored in
a repository of code called a library. A program called a linker combines the programmer’s
compiled code and the library code to make a complete program.
We generally do not think about the preprocessor, compiler, and linker working as three separate
programs (although they do); the tools we use make it appear as only one process is taking place:
translating our source code to an executable program.
• Debuggers. A debugger allows a programmer to more easily trace a program’s execution in order
to locate and correct errors in the program’s implementation. With a debugger, a developer can
simultaneously run a program and see which line in the source code is responsible for the program’s
current actions. The programmer can watch the values of variables and other program elements to see
if their values change as expected. Debuggers are valuable for locating errors (also called bugs) and
repairing programs that contain errors. (See Section 4.6 for more information about programming
errors.)
• Profilers. A profiler collects statistics about a program’s execution allowing developers to tune ap-
propriate parts of the program to improve its overall performance. A profiler indicates how many
times a portion of a program is executed during a particular run, and how long that portion takes to
execute. Profilers also can be used for testing purposes to ensure all the code in a program is actually
being used somewhere during testing. This is known as coverage. It is common for software to fail
after its release because users exercise some part of the program that was not executed anytime during
testing. The main purpose of profiling is to find the parts of a program that can be improved to make
the program run faster.
The programming components of the development process are illustrated in Figure 1.1.
Many developers use integrated development environments (IDEs). An IDE includes editors, debug-
gers, and other programming aids in one comprehensive program. Examples of IDEs for C
++
include
Microsoft’s Visual Studio 2015, the Eclipse Foundation’s Eclipse CDT, and Apple’s XCode.
Despite the plethora of tools (and tool vendors’ claims), the programming process for all but trivial
programs is not automatic. Good tools are valuable and certainly increase the productivity of developers,
but they cannot write software. There are no substitutes for sound logical thinking, creativity, common
sense, and, of course, programming experience.
©2017 Richard L. Halterman Draft date: February 28, 2018