Interpreted or compiled?

There are many ways to deal with some source code. It can be interpreted, it can be compiled, it can be compiled to an intermediate form which is then interpreted, and so on. There can be different tools that perform these diferent tasks, they are not exclusive.

 

What happens in the first part of a compiler and an interpreter is very similar:

  • check the syntax
  • make an internal representaion of the code
  • importing extern modules
  • static checking of code correctness
    • symbols in scope
    • type inferance
    • valid function calls
  • ...and more

 

The only thing that differs is what is done with the result. Either translated or executed on the file. Notice though that when doing the translation, you can perform more code optimization.

 

In both the interpretation/compilation, an important question is: how much is checked at "check time" and how much is delayed at run time. The best option is to verify the corectness of the whole program before it is run. That is, symbol scopes, type safety, no infinite loops, and so on... This static checking is a big part of the compiler/interpreter.

 

A serious compiler/interpreter should this static checking. However, for a prototype, it seems acceptable to delay all the checks at run time for the sake of simplicity. Indeed, the static checking involves a great deal of work and complexity and can be plugged in later on. And this is exactly what is planned: making first an interpreter prototype with no static checking and keep it for a later phase.

 

In the long term, it is also planned to have a simple internal representation which can be executed/interpreted by a virtual machine.