What Is a Programming Compiler?

Ahead-of-Time Compilers Vs. Just-in-Time Compilers

Focused female engineer working at laptop in workshop
Hero Images / Getty Images

A compiler is a software program that converts computer programming code written by a human programmer into binary code (machine code) that can be understood and executed by a specific CPU. The act of transforming source code into machine code is called "compilation." When all the code is transformed at one time before it reaches the platforms that run it, the process is called ahead-of-time (AOT) compilation.

Which Programming Languages Use an AOT Compiler?

Many well-known programming languages require a compiler including:

  • Fortran
  • Pascal
  • Assembly Language
  • C
  • C++
  • Swift

Before Java and C#, all computer programs were either compiled or interpreted.

What About Interpreted Code?

Interpreted code executes instructions in a program without compiling them into machine language. The interpreted code parses the source code directly, is paired with a virtual machine that translates the code for the machine at the time of execution, or takes advantage of precompiled code. Javascript is usually interpreted.​

Compiled code runs faster than interpreted code because it doesn't need to do any work at the time the action takes place. The work is already done.

Which Programming Languages Use a JIT Compiler?

Java and C# use just-in-time compilers. Just-in-time compilers are a combination of AOT compilers and interpreters. After a Java program is written, the JIT compiler turns the code into bytecode rather than into code that contains instructions for a specific hardware platform's processor. The bytecode is platform independent and can be sent and run on any platform that supports Java. In a sense, the program is compiled in a two-stage process. ​

Similarly, C# uses a JIT compiler that is part of the Common Language Runtime, which manages the execution of all .NET applications. Each target platform has a JIT compiler. As long as the intermediate bytecode language conversion can be understood by the platform, the program runs.

Pros and Cons of AOT and JIT Compilation

Ahead-of-time (AOT) compilation delivers faster startup time, particularly when much of the code executes at startup. However, it requires more memory and more disk space. JOT compilation must target the least capable of all possible execution platforms.

Just-in-time (JIT) compilation profiles the target platform while it runs and re-compiles on the fly to deliver improved performance. JIT generates improved code because it targets the current platform, although it usually takes more time to run than AOT compiled code.

Format
mla apa chicago
Your Citation
Bolton, David. "What Is a Programming Compiler?" ThoughtCo, Aug. 27, 2020, thoughtco.com/definition-of-compiler-958198. Bolton, David. (2020, August 27). What Is a Programming Compiler? Retrieved from https://www.thoughtco.com/definition-of-compiler-958198 Bolton, David. "What Is a Programming Compiler?" ThoughtCo. https://www.thoughtco.com/definition-of-compiler-958198 (accessed March 28, 2024).