Mojo 现已开源
Mojo is now open source

原始链接: https://www.modular.com/blog/mojo-open-source

Modular 已正式将整个 Mojo 编程语言以 Apache 2.0 许可证(包含 LLVM 例外条款)开源,其中包括编译器和工具链。Mojo 旨在利用 GPU 和 AI 加速器等现代硬件,弥合高级语言易用性与底层性能之间的差距。 遵循以社区为中心的阶段性开发策略,Modular 现已将其完整源代码发布至 GitHub 仓库。用户可以使用 Bazel 从源码构建编译器,也可以选择从零开始编译,或使用预构建的二进制文件以加快工作流程。 尽管标准库已开放贡献,但为了确保设计的一致性,团队目前对编译器和工具部分实行闭源贡献模式。他们计划在今年年底前将这些领域向社区贡献者开放。随着 Mojo 的不断演进,开发者可克隆仓库、探索代码库,并加入社区论坛分享反馈与项目。

Modular 正式以 Apache 2.0 许可证开源了 Mojo 编译器,这是该语言发展过程中的一个重要里程碑。在此之前,团队已经发布了标准库和核心内核代码,并采取了通过社区反馈和公开设计提案进行构建的审慎策略。 这一公告在 Hacker News 上引发了热烈讨论。爱好者们重点关注 Mojo 以性能为导向的特性,例如用于安全内存管理的线性类型和完善的所有权系统。其他人则指出,与微软合作以实现对 Windows 的原生支持至关重要,开发者们认为这对该语言的广泛普及必不可少。 尽管一些人对于 Mojo 与 Julia 和 Python 等成熟替代方案的竞争地位存在争议,但许多用户表示,随着 Mojo 不再是专有软件,他们重新对该语言产生了兴趣。尽管部分评论者质疑该项目在闭源期间是否错过了“机遇窗口”,但总体评价非常积极。此举也发生在高通收购 Modular 的消息之后,这让社区对其未来走向,以及它挑战人工智能和高性能计算领域现有巨头的潜力充满好奇。
相关文章

原文

We are happy to announce that the Mojo🔥 language is now fully open source under the Apache 2.0 license (with LLVM exceptions)! The source code for the Mojo compiler, tooling, and everything else you need to build the language are now available in our modular GitHub repository.

The Mojo language is a bold bet: a novel general purpose programming language that goes further than older ones. Mojo integrates the latest in compiler and programming language research to unlock GPUs, AI accelerators, and other advanced compute. For the last four years, Mojo has been developed with an open community, but a closed compiler. Last week Mojo hit 1.0 (with source stability), and today we’re excited to open source the entire compiler and toolchain.

Apache 2: A permissive license

The Apache 2.0 license is the gold standard for programming languages and compilers, because it provides great flexibility to be used in all sorts of applications. The LLVM extensions to the license further expand those freedoms for building and distributing binaries compiled from Mojo. We want you to be able to adopt and use Mojo in as many applications as you can imagine.

Our open source approach has been deliberate: we’ve found that small and tight-knit design teams (not committees) are the best for finding the “soul” of a language, but that feedback from a broader community is essential to escape an echo chamber. As such, we first open-sourced the Mojo standard library, then released hundreds of thousands of lines of kernel code written in Mojo, tools, and support. We built together with community feedback and public design proposals, and are now open sourcing the compiler. We will continue to open our processes further as Mojo keeps maturing.

How to get and build the compiler

All code for the Mojo language is now available at the main modular GitHub repository. First, clone that repository locally:

bash
git clone https://github.com/modular/modular.git

cd modular

Then, to build the Mojo compiler from source and run it against a Mojo file you can use a single build command:

bash
./bazelw run --config=build-mojo KGEN:mojo -- run hello.mojo

At Modular, we use Bazel to manage the complex build processes and caching for Mojo and MAX. This one command will download or build everything needed to build the Mojo compiler and the Mojo standard library. The flag --config=build-mojo tells the build system to compile everything from scratch, using the source code on your local system.

This extends to working with the Mojo standard library, where you can modify the compiler or library code and run the full suite of tests via:

bash
./bazelw test --config=build-mojo mojo/stdlib/test/...

If you aren’t working on the compiler itself, you can use the flag --config=prebuilt-mojo and the build system will download the latest nightly binary distribution of the compiler, saving you some compilation time. Note that a prebuilt Mojo compiler is still necessary today if you are customizing MAX kernels or models.

Contributions

The Mojo standard library has been accepting contributions since 2024, and we’re grateful for everyone that has helped advance the language. One learning (particularly in today’s era of AI coding) is that we need to be deliberate about how we handle contributions. As such, we aren’t ready to take contributions to the compiler and tooling. We aim to accept contributions to the compiler and tooling by the end of this year, and we’ll share more details when we can.

To ask any questions about the Mojo compiler source as you read through it, or to share what you’re working on, please join our forum. Clone the source code and let us know what you’re building with the Mojo language. We’re excited to open Mojo up to the world and see how it grows!

联系我们 contact @ memedata.com