What is a Compiler?

John Sunshine

A compiler is a special type of computer program that translates a human readable text file into a form that the computer can more easily understand. At its most basic level, a computer can only understand two things, a 1 and a 0. At this level, a human will operate very slowly and find the information contained in the long string of 1s and 0s incomprehensible. A compiler is a computer program that bridges this gap.

A compiler is a special type of computer program that translates a human readable text file into a form that the computer can more easily understand.
A compiler is a special type of computer program that translates a human readable text file into a form that the computer can more easily understand.

In the beginning, compilers were very simple programs that could only translate symbols into the bits, the 1s and 0s, the computer understood. Programs were also very simple, composed of a series of steps that were originally translated by hand into data the computer could understand. This was a very time consuming task, so portions of this task were automated or programmed, and the first compiler was written. This program assembled, or compiled, the steps required to execute the step by step program.

These simple compilers were used to write a more sophisticated compiler. With the newer version, more rules could be added to the compiler program to allow a more natural language structure for the human programmer to operate with. This made writing programs easier and allowed more people to begin writing programs. As more people started writing programs, more ideas about writing programs were offered and used to make more sophisticated compilers. In this way, compiler programs continue to evolve, improve and become easier to use.

Compiler programs can also be specialized. Certain language structures are better suited for a particular task than others, so specific compilers were developed for specific tasks or languages. Some compilers are multistage or multiple pass. A first pass could take a very natural language and make it closer to a computer understandable language. A second or even a third pass could take it to the final stage, the executable file.

The intermediate output in a multistage compiler is usually called pseudo-code, since it not usable by the computer. Pseudo-code is very structured, like a computer program, not free flowing and verbose like a more natural language. The final output is called the executable file, since it is what is actually executed or run by the computer. Splitting the task up like this made it easier to write more sophisticated compilers, as each sub task is different. It also made it easier for the computer to point out where it had trouble understanding what it was being asked to do.

Errors that limit the compiler in understanding a program are called syntax errors. Errors in the way the program functions are called logic errors. Logic errors are much harder to spot and correct. Syntax errors are like spelling mistakes, whereas logic errors are a bit more like grammatical errors.

Cross compiler programs have also been developed. A cross compiler allows a text file set of instructions that is written for one computer designed by a specific manufacturer to be compiled and run for a different computer by a different manufacturer. For example, a program that was written to run on an Intel computer can sometimes be cross compiled to run a on computer developed by Motorola. This frequently does not work very well. At the level at which computer programs operate, the computer hardware can look very different, even if they may look similar to you.

Cross compilation is different from having one computer emulate another computer. If a computer is emulating a different computer, it is pretending to be that other computer. Emulation is frequently slower than cross compilation, since two programs are running at once, the program that is pretending to be the other computer and the program that is running. However, for cross compilation to work, you need both the original natural language text that describes the program and a computer that is sufficiently similar to the original computer that the program can function on to run on a different computer. This is not always possible, so both techniques are in use.

You might also Like

Discussion Comments


Compiler construction is an interesting topic in itself. I took a computer science class in college where I had to build a compiler. It was certainly nothing fancy, but it did get me exposure to computer programming at the most basic level.

We learned to create commands and things like “lexical parsing”—which was a fancy way of saying how to get the computer to read and understand your code. It gave me a lot of insight into what was going on behind the scenes with compilers.


@nony - I don’t know much about the Windows port either, but I’ve used the Microsoft C compiler. Microsoft has hobbyist versions of their professional compilers, and they’re more than adequate for my purposes. I also like the massive documentation that is available online.


The best C compiler is open source. It’s the GNU compiler and it’s available as a free download. It runs great on Linux and is very stable. As a matter of fact, it’s pretty much the standard by which others are measured.

I think that its big claim to fame is that it has been ported to a number of different hardware platforms, so you can leverage your time investment in your code and get greater exposure for your software product. It even has ports to game consoles as well. There is also a Windows port but I haven’t messed with that.

Post your comments
Forgot password?