MoonBit
| 编程范型 | 多范型(函数式,指令式) |
|---|---|
| 設計者 | 张宏波 |
| 實作者 | MoonBit Team, 粤港澳大湾区数字经济研究院 |
| 发行时间 | 2023年 |
| 型態系統 | 静态、强类型、类型推断 |
| 操作系统 | 跨平台 |
| 許可證 | MoonBit Public Source License,可视为更宽松的 Server Side Public License |
| 文件扩展名 | .mbt |
| 網站 | www www |
| 受影响于 | |
| Rust、Go、OCaml | |
MoonBit 是由张宏波为主的团队创始,现由粤港澳大湾区数字经济研究院维护的一种专为高性能与资源效率设计的 通用型 编程语言 及 工具链,针对 WebAssembly 进行优化。[1][2]
MoonBit 的创建原因之一,在于其作者张宏波认为现有的语言如 Java、Go、Rust 等难以充分发挥 WebAssembly 指令集在 云计算 和 边缘计算 领域安全且快速的优势。
除对 WebAssembly 的原生支持后,MoonBit 现已支持 JavaScript、Native,以及 LLVM 后端。[3]
MoonBit 于 2023 年 8 月 18 日公开发布,并于 2025 年 6 月 18 日进入 Beta 阶段。
特性
[编辑]MoonBit 设计准则为“快速、简单、可拓展”,支持 函数式、並行式、过程式 以及 面向对象 的程式设计风格。[4]
MoonBit 采用了 强类型 以及数据导向的语言设计,对 运行时、编译时 性能,以及 Wasm 文件体积进行了优化,并提供了内置 调试、测试、值追踪、AI 编程辅助、代码覆盖率工具测量等工具。[3]
设计理念
[编辑]MoonBit 的语法接近 Rust,是一种 强类型 语言,具有 模式匹配、静态类型和类型推断等语言特性,从而对 数据类型 实施严格限制。不同于 Rust 无垃圾回收的设计,MoonBit 引入了 垃圾回收器,并采用了 WasmGC 提案。[5][4]
在语言设计哲学上,作者张宏波表示,MoonBit 同样从 Go 的“少即是多”中汲取了灵感,避免添加过多的语法。
MoonBit 设计为一门 大模型 友好的编程语言,采用实时基于语义的采样器,并通过包括安全类型系统、Wasm 沙盒安全、死代码消除的措施,确保 MoonBit 代码生成的可靠性。[3]
代码案例
[编辑]MoonBit 的 Hello World 程序如下:[3]
fn main {
println("hello world!")
}
生态
[编辑]MoonBit 的生态体系包含以下核心组件:
- Moon :MoonBit 编程语言的 构建系统。
- 外部函数接口(FFI)[7]:支持与宿主运行时集成,并可嵌入浏览器环境。
- 集成开发环境(IDE):在线 MoonBit IDE及 Visual Studio Code插件[8]。
应用
[编辑]2025 年 1 月,Golem Cloud 发布案例研究,介绍了 MoonBit 在 WebAssembly 组件构建中的应用[9]。
2025 年 3 月,北京大学在《编程语言设计原理》课程中采用 MoonBit 作为教学语言之一[10]。
2025 年 9 月,MoonBit 被收录至 WebAssembly Component Model 官方文档中[11]
会议
[编辑]2023 年 9 月,MoonBit 在香港科技大学(广州)举行的 IoT Thrust 研讨会上发表题为 “MoonBit For Cloud And Edge Using Wasm” 的报告。[12]
2025 年 3 月,MoonBit 作者张宏波在 Wasm I/O 2025 发表演讲《MoonBit & WebAssembly: Unlocking the True Efficiency of Wasm》。[13]
2025 年 5 月,MoonBit 作者张宏波在 LambdaConf 2025 发表主题演讲(Keynote),介绍 MoonBit 的异步编程支持。 [14]
比赛
[编辑]2024 年 11 月,MoonBit 全球编程创新挑战赛在河套深圳园区落下帷幕。[15]
參考
[编辑]- ^ Fei, Haoxiang; Zhang, Yu; Zhang, Hongbo; Wang, Yanlin; Liu, Qing. MoonBit: Explore the Design of an AI-Friendly Programming Language. Proceedings of the 1st International Workshop on Large Language Models for Code. LLM4Code '24 (New York, NY, USA: Association for Computing Machinery). 2024-09-10: 79–83. ISBN 979-8-4007-0579-3. doi:10.1145/3643795.3648376.
- ^ MoonBit Documentation. docs.moonbitlang.com. [2025-10-10].
- ^ 3.0 3.1 3.2 3.3 About us | MoonBit. www.moonbitlang.com. [2025-03-18] (中文(简体)).
- ^ 4.0 4.1 MoonBit. www.moonbitlang.cn. [2025-03-15] (中文(简体)).
- ^ moonbitlang/core, moonbitlang, 2025-03-15 [2025-03-15]
- ^ MoonBit 包管理平台. MoonBit. [2025-10-11] (中文).
- ^ Foreign Function Interface (FFI) — MoonBit v0.6.27 documentation. MoonBit Documentation. [2025-10-11] (英语).
- ^ Visual Studio Code 扩展. Visual Studio Marketplace. [2025-10-11] (英语).
- ^ Using MoonBit with Golem Cloud. Golem Cloud. 2025-01-03 [2025-10-10].
- ^ 编程语言设计原理课程. 北京大学. [2025-10-10].
- ^ Creating components. Bytecode Alliance. 2025-09-11 [2025-10-10].
- ^ IoT Thrust Seminar | Moonbit For Cloud And Edge Using Wasm. University Events. 2023-09-26 [2025-10-11] (中文(简体)).
- ^ MOONBIT & WEBASSEMBLY: UNLOCKING THE TRUE EFFICIENCY OF WASM. Wasm I/O 2025. 2025-03-27 [2025-10-111].
- ^ Introduction to MoonBit and its Async Model. LambdaConf 2025. 2025-05-13 [2025-10-11].
- ^ 1888 进 11 角逐桂冠!MoonBit 全球编程创新挑战赛圆满落幕!_深圳新闻网. www.sznews.com. [2025-03-15].