XiaoXuan Native
XiaoXuan Native is a memory-safe, general-purpose programming language inspired by Rust. It is designed to be simpler than Rust while it still provides automatic memory management without garbage collection, and avoids complex concepts such as ownership, borrow checking, and lifetimes. It aims to replace Rust in certain non-critical scenarios. It currently supports compiling to native code for architectures x86-64, aarch64 (ARM64), riscv64 and s390x (IBM Z), and will supports loongarch64 in the future.
Currently, XiaoXuan Native is written in Rust, but it will be self-hosted in the future 😄
Features
TODO
Comparison with Rust
XiaoXuan Native and Rust are both compiled, memory-safe, and GC-free general-purpose programming languages with similar user experiences, but they are very different internally:
Memory mamangement implementation principles
Rust’s memory management uses a strict set of “rules” to constrain the writing of user code, including concepts such as ownership, borrow checking, and lifetimes, which are “hard” embedded in the Rust compiler. If the user code passes compilation, it can be roughly determined that the code is memory safe. However, because these rules are checked during compilation, it is possible to write syntactically correct Rust code that fails to compile.
XiaoXuan Native’s memory management implementation is much simpler, using “data immutability + reference counting” internally, which is reflected in the syntax. That is, as long as you write syntactically correct XiaoXuan Native code, you can be sure that the code is memory safe even without compiling it.
Although XiaoXuan Native’s memory management method is slightly less performant than Rust’s is some cases, it is more intuitive and simpler, and you can write memory-safe programs with performance comparable to Rust’s without having to learn new concepts or constantly remember rules.
Compiler implementation
The syntax design of the XiaoXuan Native is not only easy for humans to read and understand, but also makes the implementation of the language’s lexer and parser very simple. And because there is no extra “rules” checking, the compiler is also very simple. In additional, XiaoXuan Native has its own IR and code generator, and does not rely on any traditional compiler (such as GCC and LLVM) or library. These features make XiaoXuan Native language easy to implement, and any engineer can understand the source code of the XiaoXuan Native compiler, find bugs, and make improvements.
In contrast, the Rust compiler is not so easy to understand, and you need a lot of knowledge and experience to participate.
Related projects
- XiaoXuan Assembly LoongArch Assembler for LoongArch (la64).
- XiaoXuan Assembly RISC-V Assembler for RISC-V (rv64gc).
- XiaoXuan Assembly ARM Assembler for ARM (aarch64).