What?

It’s a program that translates an executable program in one language into an executable program in another. Ideally, it improves the program (in some way) in the process. It’s different from an Interpreter.

What’s the Point?

It allows us to code in one lagnhuage and execute it in another.

What other functions does it have?

  • Must recognise legal (and illegal) programs, and spit them out as errors if so.
  • Must generate correct machine code.
  • Must store machine code and variables.

Traditional 2-Step Compiler:

  • The Frontend transforms the code into an Internal Representation (IR).
    • It also checks for correctness.
  • The Backend takes that representation, optimises and then converts it to machine code.

Examples: