Mojo, the language to write the future of AI
The new AI developer language that crosses Python and MLIR.
Given the levels of popularity that artificial intelligence is reaching lately and considering its application in various fields, it is reasonable to think that the popularity and use of the main programming language related to it, Python, will further increase.
In fact, over the last two decades, Python has consolidated its position as the predominant language for the development of artificial intelligence, thanks to its simple syntax, a large number of libraries and its rich ecosystem. But Python is not alone.
A new programming language devoted to the development of AI, a potential competitor to him, has also recently made its appearance on the scene. We are talking about Mojos. Announced on May 2 by Modular, the new language combines the syntax of Python with the portability and performance of C, thus presenting itself as ideal for AI research and production.
Low-level systems programming and advanced compilation capabilities are provided through MLIR, the multilevel intermediate representation compiler framework. Being based on the MLIR framework, Mojo is portable to a large variety of hardware devices (CPU, GPU and TPU), which allows you to compile the same code for different devices without making changes to the code base.
Presented as faster than C++, more easily hackable than Nvidia’s CUDA and as secure as Rust, Mojo was created with the aim of bridging the gap between research and production, exploiting Python syntax, systems programming and phase metaprogramming of compilation.
So can we talk of Python++?
We are actually dealing with a superset of Python, compatible with all its existing programs, thanks to which it is possible to write fast, small, easily implementable applications that make use of all the cores and accelerators available.
As a result, Mojo’s potential exceeds that of a simple pure language for AI and ML models. Those who have already used it argue that it can be used to write everything in a single language, from scalable Python code to hardware programming, without the need to resort to C++ or CUDA.
As for memory management, Mojo’s compiler tracks the life of a variable using static analysis and destroys the data as soon as it’s no longer in use.
Why a new language?
One of the main reasons why new programming languages are created is that most of the existing programming systems rely on accelerators (such as GPUs) and only support data loading, pre- and post-processing and integration with external systems written in other languages. What Modular AI wants to do with Mojo is to merge all these functions into one new language.
A programming language that has powerful compile-time metaprogramming, incorporating adaptive compilation techniques, caching during the compile process, and other features that existing languages do not yet support.
However, Mojo is still growing as a programming language, and while it already supports many of Python’s basic features, it doesn’t yet support classes, for example.
Led by Chris Lattner, behind successful compiler and programming language projects like clang, LLVM, Swift and the MLIR framework, Modular is undoubtedly a company to watch.
Mojo explained by his creator:
Sources
New Language for AI Development: Mojo builds on Python with the Power of C
Mojo: The Future of AI Programming
https://codeconfessions.substack.com/p/mojo-the-future-of-ai-programming