What is Compiler?
Compiler is a computer program that has the capacity to translate high-level language into a machine language/ low-level language that is readable to the computer. The high-level language is know as source while the low-level language is known as machine code.
Computers usually read instructions in machine language format written in binary. A binary is string of numbers made up of 0s and 1s. Computers can’t understand human readable languages and humans many not also understand computer language (machine). Therefore programmers work with the programming language the have understanding of, which can then be translated to the machine language which the computer can understand. Compilers do the job of translating high-level (human-readable) language machine (computer-readable) language.
Interpreters can also be used in place of compilers to translate source codes to machine codes.
Advantages of Compiler
Here are some of the advantages of using compiler program in programming
1. Independence
2. Optimisation
3. Data Security
4. Speed
Independence
Compiler compiles commands into machine language binaries, no other program or application is needed to be installed to execute the executable file of sources codes. The only thing needed is that each program has to be compiled for specific operating systems. If a program is compiled for a particular OS architecture, the user only needs to OS that runs on same OS architecture.
Optimisation
Hardware optimization is of one the advantages of compiler because compiler translates sources into a specific machine language for targeted hardware which is well optimized and runs faster. By this, the compiler creates machine language code that will efficiently run on a specific hardware.
Having generic code may run optimally run a any hardware.
Data Security
Executable files generated from the compiler can be executed on any other systems without the need for actual source code. Which makes the program unhackable, secure and private
Speed
Compiler runs faster than interpreter because it is a precompiled package, what is needed is to executive the executable files that are generated.
Read also: Compiler: Definition, Structures, Types and Applications
Disadvantages of Compilers
1. Hardware Specific
2. Time consuming
3. Extra memory
4. Debugging Difficulty
Hardware Specific
Compiler translates instruction codes into a particular computer native language, the programs are therefore compiled for a particular OS and architecture. For instance programs are complied specifically for OS X, Linux or Windows and for 32-bit or 64-bit architectures
The cost of developing, updating, maintenance and marketing multiple versions of source codes for the same application is very high.
Time Consuming
Another disadvantage of a compiler is that it takes time to compile sources code. As a larges application suites, compiler takes huge amounts time to compile, while smaller programs take little time to compile. During time of testing for functionality and troubleshooting hiccups, it takes time for codes to compile, as a programmer, you have no other option than to wait while it runs.
Extra Memory
Compiler occupies extra memory as it generates a new file.
Debugging Difficulty
One of the drawbacks of having a compiler is that it is difficult to debug identified errors as it returns all the errors at once after reading the source codes. It makes it difficult to navigate through the enter codes and fix the errors.
Read also: Advantages and Disadvantages of Interpreter