'

What is a Compiler?

A compiler is a computer program that translates one programming language to another. The main use for compilers is to translate high-level languages (written by humans) to low-level languages (readable by computers). Grace Hopper, a Navy computer scientist, was one of the earliest proponents of high-level programming. In the 1950s, Hopper released the first compiler program.
Binary code made up of many ones and zeroes
Share on linkedin
Share on twitter
Share on facebook

A compiler is a computer program that translates one programming language to another. The main use for compilers is to translate high-level languages (written by humans) to low-level languages (readable by computers). 

High-Level Languages vs Low-Level Languages

High-level programming languages are those that are easily understood by human programmers. They use recognizable commands similar to natural languages like “if,” “else,” “then,” “or.” Low-level languages are easily understood and executed by computers but make little sense to the naked human eye. An example of low-level coding might look like “83FA0376 078BD989.”

Computers aren’t inherently able to understand words like “if” and “or.” They need to be given commands in low-level languages that communicate processes very specifically. However, if human programmers had to write all code in low-level languages they would spend huge amounts of time defining concepts over and over and clarifying how different commands should work. 

High-level programming languages use abstraction to ‘abstract away’ the most basic details of functions. That is, they can use the term “or” without having to add code every single time to explain the meaning of “or.”

Examples of High-Level Languages

  • Python
  • Java
  • C++
  • Ruby

Examples of Low-Level Languages

  • Assembler
  • Machine code
  • Bytecode


Side-by-side comparison of high-level and low-level programming languages

History of Compilers

Grace Hopper, a Navy computer scientist, was one of the earliest proponents of high-level programming. In 1980 she said, ““I kept calling for more user friendly languages. Most of the stuff we get from academicians, computer science people, is in no way adapted to people.” In the 1950s, Hopper released the first compiler program along with the high-level language FLOW-MATIC, which was designed for the UNIVAC I. 

Before Grace Hopper’s compiler, programs for the UNIVAC I were written as strings of letters and numbers, like B00120 C00185. In each set of six digits, the first two described the operation to be performed, while the last three designated a memory location in the computer’s storage. The third digit was simply a placeholder.

Hopper voiced that these strings were difficult for users to memorize and write quickly without error. However, she was repeatedly told by fellow team members that natural-language programming that could be interpreted by computers was technically impossible. Her compiler and the FLOW-MATIC language proved them wrong. The compiler allowed programmers to use English-like functions like “TRANSFER” and “IF.”

More and more high-level languages followed FLOW-MATIC – COBOL, Java, C++, Python, etc. All of these languages use compilers to translate human-language terms to computer commands.

Types of Compilers

Source-to-Source Compiler 

Sometimes known as a transcompiler, this type of compiler translates one high-level language into another. The most prominent use case for a source-to-source compiler is translating an older version of a language into the most current version – for example translating code written in an old version of Python to Python3. When an organization switches their org-wide standard from one language to another, they can use a source-to-source compiler to ensure legacy programs continue to work with newly created ones.

Decompiler

A decompiler does the opposite of a compiler – it translates machine code back into a readable source code like Python or Java.

Just-in-Time Compiler (JIT)

A just-in-time compiler translates source code (high level language) into machine executable code at runtime rather than before. Just-in-time compilation is more efficient in that it uses less memory than traditional compilation methods. However, programs using JIT compilers have a slight delay, or warm-up time, before running. This is when the compilation takes place.

Assembler

An assembler translates assembly language to machine code. Both assembly languages and machine code are considered low-level languages. However, assembly language is semi-readable by human programmers with a trained eye, while machine code is purely made up of ones and zeroes. 

Disassembler

A disassembler translates machine code into assembly language. 

Compilers are a key technology for programming that allow humans and machines to seamlessly interact. With robust compiling programs, people are able to learn relatively simple coding languages, making coding skills accessible to anyone who wants to learn. Looking back on Grace Hopper’s efforts convincing her colleagues of the necessity and feasibility of compilers and human-oriented programming is a good reminder of the importance of pushing the bounds of technology. 

Related Articles