15.04.2018 Views

programming-for-dummies

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Choosing a Compiler 87<br />

than other compilers. As a result, it’s possible to compile the same C++ program<br />

under two different C++ compilers and create identically working<br />

programs that consist of different machine language instructions.<br />

The goal of every compiler is to create a program that takes up as little memory<br />

and disk space as possible while running as fast as possible. Usually, compilers<br />

make a trade off. To make a program run faster, the executable file may take<br />

up a large amount of disk space or require a lot of memory. If the compiler<br />

can reduce the size of your program and the amount of memory it needs to<br />

run, it may create a slow program.<br />

Book I<br />

Chapter 4<br />

Programming Tools<br />

To help you tweak your program <strong>for</strong> the best balance of speed, size, and<br />

memory requirements, many compilers offer optimization settings. By fiddling<br />

with these optimization settings, you can tell the compiler how to<br />

speed up or shrink your program, as shown in Figure 4-1.<br />

Figure 4-1:<br />

Compiler<br />

optimization<br />

settings let<br />

you make<br />

your<br />

program as<br />

small and as<br />

fast as<br />

possible.<br />

One major feature of a compiler’s code generation capabilities involves<br />

speed, which can measure two different features:<br />

✦ Speed can refer to how quickly the compiler works in translating your<br />

source code to machine code.<br />

In the old days, compilers could take hours or days to compile a simple<br />

program. Nowadays, compilers often work in minutes or even seconds.<br />

Shove in a program that consists of 800,000 lines of code, and in less<br />

than a minute, the compiler can create an executable file <strong>for</strong> you. The<br />

faster the compiler works, the less time you waste running and testing<br />

your program.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!