We are independent & ad-supported. We may earn a commission for purchases made through our links.
Advertiser Disclosure
Our website is an independent, advertising-supported platform. We provide our content free of charge to our readers, and to keep it that way, we rely on revenue generated through advertisements and affiliate partnerships. This means that when you click on certain links on our site and make a purchase, we may earn a commission. Learn more.
How We Make Money
We sustain our operations through affiliate commissions and advertising. If you click on an affiliate link and make a purchase, we may receive a commission from the merchant at no additional cost to you. We also display advertisements on our website, which help generate revenue to support our work and keep our content free for readers. Our editorial team operates independently of our advertising and affiliate partnerships to ensure that our content remains unbiased and focused on providing you with the best information and recommendations based on thorough research and honest evaluations. To remain transparent, we’ve provided a list of our current affiliate partners here.
Software

Our Promise to you

Founded in 2002, our company has been a trusted resource for readers seeking informative and engaging content. Our dedication to quality remains unwavering—and will never change. We follow a strict editorial policy, ensuring that our content is authored by highly qualified professionals and edited by subject matter experts. This guarantees that everything we publish is objective, accurate, and trustworthy.

Over the years, we've refined our approach to cover a wide range of topics, providing readers with reliable and practical advice to enhance their knowledge and skills. That's why millions of readers turn to us each year. Join us in celebrating the joy of learning, guided by standards you can trust.

What is a Compiler?

By John Sunshine
Updated: May 16, 2024
Views: 31,086
Share

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.

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.

Share
EasyTechJunkie is dedicated to providing accurate and trustworthy information. We carefully select reputable sources and employ a rigorous fact-checking process to maintain the highest standards. To learn more about our commitment to accuracy, read our editorial process.
Discussion Comments
By miriam98 — On May 25, 2011

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.

By NathanG — On May 23, 2011

@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.

By nony — On May 20, 2011

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.

Share
https://www.easytechjunkie.com/what-is-a-compiler.htm
Copy this link
EasyTechJunkie, in your inbox

Our latest articles, guides, and more, delivered daily.

EasyTechJunkie, in your inbox

Our latest articles, guides, and more, delivered daily.