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.
Changes in MoonBit Language
1. MoonBit has already supported compilation to Wasm GC
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.
2. Faster parser and better error recovery.
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.
3. Improved dead code elimination for top-level functions and global variables.
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.
Build System
1. Support moon test
command, which runs files ending with _test.mbt
in each package.
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