Language Target
Language Target
Language Target
Created: | Wednesday, May 4, 2022 |
---|---|
Author: | David Delassus |
Category: | Compiler Architecture |
Status: | FINAL |
This LEP specifies what is the targetted language of Letlang as well as its compilation unit.
Letlang is a compiled language, therefore the compiler does not produce bytecode to be interpreted by a virtual machine, and it does not interpret the Abstract Syntax Tree directly.
The compiler produces code in a targetted compiled language that is then assembled into a final executable.
The Letlang compiler produces Rust[1] code.
It was chosen because:
Rust’s compilation unit is the crate.
A crate is a tree of modules:
// root module
mod child_module {
// ...
}
mod other_child; // located in other_child.rs or other_child/mod.rs
It is either:
.rlib
file (an AR archive of machine code)Letlang’s compilation unit is a module. Each Letlang file is a module:
module hello::world;
# ...
Each module is compiled to a single Rust library crate, and linked together in a final binary crate.
NB: Each Letlang module can then be used as-is in a Rust project.
Each Letlang module requires the Rust crate letlang_runtime
, providing the
core features of the language.
There are too many CPU architecture to target, it would restrict Letlang’s availability to only one platform and operating system during development.
From a security point of view, this would be too much work to ensure memory safety, thread safety, etc… on all targets.
While this allow the compiler to target many platform at once, this target is still too low-level. A lot of work would be needed to ensure memory safety, thread safety, etc…
Reference | Title | Link |
---|---|---|
1 | Rust | https://www.rust-lang.org/ |
2 | LLVM IR | https://en.wikipedia.org/wiki/LLVM#Intermediate_representation |
3 | LLVM | https://llvm.org/ |