Compiler Types and Assemblers

Challenge 7-1: Introduction to Compilers

Compilers

Compiler Types and Assemblers

Interpreters

Compilers come in many different styles and they all have slightly different purposes. For example, if a compiler translates from high level to low level, then what do you think a decompiler would do?

A) Low level to low level

B) Low level to high level

C) High level to high level

Answer

B; a decompiler takes low level language and translates it into a higher-level language more easily read by humans such as Python.

There are many more than just these two though - there are bootstrap compilers, cross-compilers, transcompilers and more! All these different programs are still compilers but each one serves a slightly different purpose. While this might sound picky and unneeded, when you’re trying to get a job done right you don’t hammer a nail in with a saw right?

Assemblers

Compilers don’t always do direct translations either, sometimes they translate the code into assembly language, which is different to machine code.

Assembly is one of the lowest levels of code that humans can comfortably write. It's a slight step above writing binary ones and zeros, but it still needs you to know a lot about the system you're programming. With assembly, you can look at specific areas of memory and even interface directly with the computer's CPU!

Using assembly means that we now have the assembly code but we need another program to finish the translation. This is usually not called a compiler, because assembly is so low-level anyway, but instead is known as an assembler which specifically translates assembly into machine code.