Compilers – Introduction: my study notes

These notes are from the Week 1 of the Compilers course by Stanford.

History

The problem that compilers tried to solve, in the ’50s was basically to improve the software developers’ productivity. At that time, they started to realize that the software cost was much greater than the hardware cost, even though the hardware was extremely expensive back then.

The first effort in trying to solve that was the creation of Speedcoding by John Backus which was a high-level language and an interpreter. The problem there was the interpreter system took 300 bytes of memory or 30% of the available memory of the machines, and then ran approximately 20 times slower than programs written directly in machine code. Later, they iterated over it and decided to create FORTRAN which was both a high-level language and a compiler. This project was so successful, that most compilers today preserve the structure of the FORTRAN compiler.

Structure of a Compiler

  • Lexical Analysis: divides a program into tokens
  • Parsing: groups the tokens into meaningful constructs
  • Semantic Analysis: tries to detect inconsistencies within the program
  • Optimization: modifies the program to make it more efficient
  • Code Generation: creates the actual machine code that will be executed

Leave a Reply

Your email address will not be published. Required fields are marked *