What is a Compiler?

This article is a complementary resource to Learn C Programming course.

What is a Compiler?

Computers only understand a specific language. In layman's terms, that's 0's and 1's. However, writing programs in this binary format can be challenging.

Instead, we typically write programs in high-level programming languages like C, C++, or Java, which are not in the form of 0's and 1's.

To bridge this gap, we need a tool that translates code from one language into another, typically into binary (0's and 1's).

In this article, we'll learn about this tool, called a compiler.


What is a Compiler?

A compiler is a program that translates code written in one language (the source language) into an equivalent language (the target language).

Typically, the target language is machine language, which consists of 0's and 1's.

The compiler takes a source program as input and generates its equivalent in the target language.

A Compiler
A Compiler

If the target language is executable machine code, we can provide input to the compiled program to produce its output.

Running the target program
Running the target program

In general, compiling a program involves generating its equivalent executable machine code.

The compiler not only generates the target program but also reports errors to the programmer. For example, it will generate an error if you forget a semicolon in your C program.

In summary, compilers are essential tools in software development. They allow programmers to write code in high-level languages and ensure that computers can execute it efficiently.