Aviva Directory » Computers & Internet » Programming » Mojo

Said to combine the usability of Python with the performance of C, Mojo is designed to be the programming language of choice for artificial intelligence (AI) development.

A member of the Python family of languages, Mojo is fully compatible with the Python ecosystem and might be considered a subset of Python. Over time, it may become a superset of Python. Mojo bridges the gap between research and production by combining Python syntax and ecosystem with systems programming and metaprogramming features. The language allows for portable codes that are faster than C, with seamless interoperability with Python.

Mojo is under development with Modular, an AI company founded by former Apple and Google engineers and executives, and based in the San Francisco Bay area. A next-generation AI developer platform, Mojo was conceived as the language of choice for AI. While the company's intent is to open-source Mojo eventually, the language is currently being incubated within Modular.

According to Modular, the company hadn't intended to build a new programming language, but, as its AI development was underway, they realized that programming across the entire stack was too complicated. Seeking an innovative and scalable programming model that could target accelerators and other systems common in the AI field, they needed a programming language with powerful compile-time metaprogramming, integration of adaptive compilation techniques, caching throughout the compilation flow, and other features that weren't found in existing languages, such as high-performance support for a wide variety of accelerators.

Multi-Level Intermediate Representation (MLIR) is a new open-source compiler infrastructure that was first implemented at Google, whose leads moved to Modular. In its quest to build a next-generation AI platform, Modular was already using MLIR for some of its infrastructure but needed a programming language that could unlock the full potential of MLIR, so Mojo is the first major programming language designed expressly for MLIR.

In developing the language, the Mojo team chose to embrace the Python ecosystem since it's so widely used and generally works well with the AI ecosystem. Thus, the goal was to retain full compatibility with the Python ecosystem and to make it easier for Python coders to migrate to Mojo. There were influences from C, C++, Julia, Nim, Rust, Swift, and Zig, as well.

In terms of importing existing Python modules for use in a Mojo program, Mojo is 100% compatible with Python because it used CPython for interoperability. However, in terms of migrating any Python code to Mojo, it is not yet fully compatible. Although Mojo supports many of Python's core features, including async/await, error handling, variadics, and so on, the language is still new and has not yet incorporated some of the other features from Python, such as classes.

Where the goal is to mix Python and Mojo code, the expectation is that Mojo will cooperate directly with the CPython runtime and have similar support for integrating with CPython classes and objects without having to compile the code itself. This allows for plug-in compatibility with a massive ecosystem of existing code.

The intention is full compatibility with Python, although Mojo is an entirely new language with an entirely new compilation and runtime system. There is nothing in the implementation, compilation, or runtime that uses any existing Python technologies.

While compatibility and migratability with Python are important to the success of Mojo, it is a standalone language.



Recommended Resources

Search for Mojo on Google or Bing