Writing a Compiler - Language Design
compiler language
Things we want
Simplicity
- Small and simple syntax.
-
We will apply UX Concepts to Language Design, this implies removing
choice, and making things evident.
Performance
- Compiler will be written in C.
- The goal is to achieve extremely fast compilation times.
- The resulting code must also perform well.
Interoperability
-
Offer a Javascript target. A C target will be implemented in the future.
- Be able to import Javascript libraries
Language Safety
- No global variables
- No undefined values
- No variable shadowing
- Bounds checking
Things we want to avoid
Null Pointers
Variables must be initialized at declaration. The language does not define a
Null type or value.
= and ==
Similar looking operators can be hard to spot and cause unintended behavior.
One way to fix this would be by changing the grammar, so the
=
operator can only be used in Statement
s and not
in Expression
s.
Dangling else
Case without break