Mojo 1.0 Beta

Mojo 1.0 Beta

Write like Python, run like C++. 像 Python 一样编写,像 C++ 一样运行。

Write fast code for diverse hardware, from CPUs to GPUs, without vendor lock-in, in a language that’s both user friendly and memory safe. 在无需厂商锁定的情况下,为从 CPU 到 GPU 的各种硬件编写高性能代码,同时使用一种既用户友好又具备内存安全的语言。

Built different (与众不同)

Modern 现代化 Mojo draws inspiration from the best parts of modern languages - like Python’s intuitive syntax, Rust’s memory safety, and Zig’s powerful and intuitive compile-time metaprogramming. Mojo 从现代语言的精华中汲取灵感,例如 Python 直观的语法、Rust 的内存安全性,以及 Zig 强大且直观的编译时元编程。

AI native AI 原生 Mojo is built from the ground up to deliver the best performance on the diverse hardware that powers modern AI systems. As a compiled, statically-typed language, it’s also ideal for agentic programming. Mojo 从底层构建,旨在为驱动现代 AI 系统的多样化硬件提供最佳性能。作为一种编译型、静态类型的语言,它也非常适合智能体(Agentic)编程。

Simply performant 兼顾性能与简洁 No more choosing between productivity and performance - Mojo gives you both. You can start with simple and familiar programming patterns, and add complexity as you need it. 无需再在生产力和性能之间做选择——Mojo 两者兼得。你可以从简单且熟悉的编程模式入手,并根据需要增加复杂度。

GPU programming GPU 编程 Mojo makes GPU programming accessible to everybody, without vendor-specific libraries and without separately-compiled code. You can finally write high-performance GPU kernels in the same language you use for CPUs. Mojo 让每个人都能进行 GPU 编程,无需特定厂商的库,也无需单独编译代码。你终于可以使用编写 CPU 代码的同一种语言来编写高性能 GPU 内核了。

Python interop Python 互操作性 Mojo natively interoperates with Python so you can eliminate performance bottlenecks in existing code without rewriting everything. You can start with one function, and scale up as needed to move performance-critical code into Mojo. Your Mojo code imports naturally into Python and packages together for distribution. Likewise, you can import libraries from the Python ecosystem into your Mojo code. Mojo 与 Python 原生互操作,因此你无需重写所有代码即可消除现有代码中的性能瓶颈。你可以从一个函数开始,根据需要逐步扩展,将性能关键型代码迁移到 Mojo 中。你的 Mojo 代码可以自然地导入到 Python 中,并打包在一起进行分发。同样,你也可以将 Python 生态系统中的库导入到 Mojo 代码中使用。

Compile-time metaprogramming 编译时元编程 Mojo metaprogramming uses the same language as the run-time code, providing an intuitive system to maximize performance. You can build hardware-specific optimizations with conditional compilation, ensure memory safety with compile-time evaluation, eliminate costly runtime branches, and more—all with clearly defined intentions and zero-cost abstractions. Mojo 元编程使用与运行时代码相同的语言,提供了一个直观的系统来最大化性能。你可以通过条件编译构建特定于硬件的优化,通过编译时评估确保内存安全,消除昂贵的运行时分支等——所有这些都具有明确的意图和零成本抽象。

Roadmap (路线图)

Mojo was born in late 2022 and has come a long way, but there’s still a lot to do. Mojo 诞生于 2022 年底,虽然已经取得了长足进步,但仍有许多工作要做。

  • Phase 0: Initial bring-up Implementing the core parser, defining memory types, functions, structs, initializers, argument conventions, and other language foundations. 第 0 阶段:初步构建 实现核心解析器,定义内存类型、函数、结构体、初始化器、参数约定以及其他语言基础。

  • Phase 1 (in progress): High performance CPU + GPU coding Making Mojo a powerful and expressive language for writing high-performance kernels on CPUs, GPUs, and ASICs, while empowering developers to extend Python seamlessly. 第 1 阶段(进行中):高性能 CPU + GPU 编程 使 Mojo 成为一种强大且富有表现力的语言,用于在 CPU、GPU 和 ASIC 上编写高性能内核,同时赋能开发者无缝扩展 Python。

  • Phase 2: Systems application programming Expanding Mojo to support more application-level programming, with a guaranteed memory-safety model and more abstraction features that developers expect for systems programming. 第 2 阶段:系统应用编程 扩展 Mojo 以支持更多应用级编程,提供保证内存安全模型以及开发者在系统编程中所期望的更多抽象特性。

  • Phase 3: Dynamic object-oriented programming Supporting more of Python’s dynamic features like classes, inheritance, and untyped variables to maximize compatibility with Python code. 第 3 阶段:动态面向对象编程 支持更多 Python 的动态特性,如类、继承和无类型变量,以最大化与 Python 代码的兼容性。

Open source (开源)

The Mojo standard library is fully open-source on GitHub and we welcome contributions! We also plan to open-source the Mojo compiler in 2026. Mojo 标准库已在 GitHub 上完全开源,我们欢迎贡献!我们还计划在 2026 年开源 Mojo 编译器。

We’re committed to open-sourcing all of Mojo, but the language is still very young and we believe a tight-knit group of engineers with a common vision moves faster than a community-driven effort. 我们致力于开源 Mojo 的全部内容,但该语言还非常年轻,我们认为一个拥有共同愿景的紧密工程师团队比社区驱动的努力推进得更快。

If you’d like to get involved, join our developer community! 如果你想参与其中,欢迎加入我们的开发者社区!