In October 2023, MoonBit underwent Alpha testing. This post aims to introduce recent updates to MoonBit’s language and toolchain, along with applications developed using MoonBit.
This week MoonBit has already supported compilation to Wasm GC in advance, although the Wasm GC standard is currently in the process of standardization(GitHub - WebAssembly/proposals: Tracking WebAssembly proposals). We are waiting for the Wasm GC proposal to be finalized and for Wasm GC to become a default enabled option in the Chrome browser.
Currently, there are two parsers working together in MoonBit, one is a faster parser generated by Menhir(Menhir), and the other is a handwritten parser with friendlier error messages. Each time parsing occurs, the faster Menhir parser will first be used for segmented parsing of top-level definitions, and if any segment contains errors, the handwritten parser will be switched in for a second pass, providing better error recovery.
MoonBit improved dead code elimination for top-level functions and global variables,further reducing the compiled size. For example, unused functions and variables in the built-in package will not appear in the compiled output.
For example, for the following project:
. ├── lib │ ├── hello.mbt │ ├── hello_test.mbt │ └── moon.pkg ├── main │ ├── main.mbt │ └── moon.pkg └── moon.mod
The output of
moon test would be similar to:
test lib ... ok