Changes

Jump to navigation Jump to search
157 bytes added ,  13:52, March 22, 2012
make 'optimisation' a separate section
Line 3: Line 3:  
There are compilers for the more common programming languages available on a wide variety of different computer architectures.  This means that a program written in one of these languages is ''portable'' and can generally be used on any of the different machines just by using the appropriate compiler; note that there may be occasional problems with machine-dependencies, especially if there are substantial differences in the accuracy and size of numbers on the different machines.
 
There are compilers for the more common programming languages available on a wide variety of different computer architectures.  This means that a program written in one of these languages is ''portable'' and can generally be used on any of the different machines just by using the appropriate compiler; note that there may be occasional problems with machine-dependencies, especially if there are substantial differences in the accuracy and size of numbers on the different machines.
   −
Some compilers just perform a fast simple-minded translation from high-level source code to low-level machine language.  Many compilers have one or more optional optimisation levels.  Such optimisations generally make the resulting machine code 'better' (for some definition of 'better' such as 'faster' or 'smaller' or 'less power consumption'); higher speed may be important for frequently-used long-running programs; less memory usage may be important for embedded computers used within other devices; lower power consumption may be important for battery-powered computers (e.g. laptops).  As the level/amount of optimisation increases the compiler tends to spend more and more time doing the optimisation.  The word 'optimisation' is perhaps misleading - perfect optimisation is a very hard problem ([[NP-complete]] or even [[undecidable]]), so a conceptually better term would be 'improvement'.
+
Some compilers just perform a fast simple-minded translation from high-level source code to low-level machine language, while other compilers may optionally take (much) longer to perform the compilation by trying to improve or optimise the resulting machine code.   
    
==Outline of the compilation process==
 
==Outline of the compilation process==
Line 28: Line 28:     
:'''Assembly and linking''': translate the assembly language into executable machine code.
 
:'''Assembly and linking''': translate the assembly language into executable machine code.
 +
 +
==Optimisation==
 +
Many compilers have one or more optional optimisation levels.  As the level/amount of optimisation increases the compiler tends to spend more and more time doing the optimisation.  The word 'optimisation' is perhaps misleading - perfect optimisation is a very hard problem ([[NP-complete]] or even [[undecidable]]), so a conceptually better term would be 'improvement'.
 +
 +
Such optimisations generally make the resulting machine code 'better', for some definition of 'better':
 +
* '''faster''': higher speed may be important for frequently-used long-running programs.
 +
* '''smaller''': less memory usage may be important for embedded computers used within other devices.
 +
* '''low power''': less power consumption may be important for battery-powered computers (e.g. laptops). 
    
==References==
 
==References==
SkipCaptcha
265

edits

Navigation menu