Mojo is a new programming language that promises better performance for machine learning development
A few days ago, it was announced that Chris Lattner, founder and chief architect of LLVM, and Tim Davis, former head of AI projects at Google, launched "Mojo," a new programming language based on Python that solves Python's implementation and performance problems.
Mojo is described as combining ease of use for R&D and rapid prototyping with suitability for high-performance end products. The former is achieved through the use of Python's familiar syntax, and the latter through its ability to compile to machine code, secure memory management mechanisms, and hardware-accelerated calculation tools.
About Mojo
This new programming language focuses on its use for machine learning development , but it presents itself as a general-purpose language that extends the capabilities of the Python language with systems programming and is suitable for a wide range of tasks.
For example, the language is applicable to areas such as high-performance computing, data processing, and data transformation. One interesting feature of Mojo is the ability to specify the emoji symbol “” as an extension for code files.
The project is designed to leverage the system's available hardware resources for calculations. For example, GPUs, specialized machine learning accelerators, and vector processing instructions (SIMDs) can be used to run Mojo applications and parallelize calculations.
The reason for developing a separate subset of the Python language, rather than joining existing CPython optimization work, is cited as:
A build approach, integration of the system's programming capabilities, and the use of a fundamentally different internal architecture that allows code to be executed on GPUs and various hardware accelerators. At the same time, the Mojo developers intend to stick to CPython support as much as possible.
Mojo can be used in both Just-in-Time (JIT) interpretation mode and for compilation to executable files (AOT, ahead-of-time). The compiler has modern technologies built in for automatic optimization, caching, and distributed compilation.
The source code in the Mojo language is converted into low-level intermediate code MLIR (Multi-Level Intermediate Representation), developed by the LLVM project, which provides additional functions to optimize the processing of data flow graphs.
The use of additional hardware mechanisms to speed up computations allows you to achieve performance that, with intensive computations, outperforms C/C++ applications.
Chris lattner is responsible for creating many of the projects we all rely on today, even though we may not have even heard of everything he built! As part of his doctoral thesis, he began the development of LLVM, which fundamentally changed the way compilers are built and today forms the basis of many of the world's most widely used linguistic ecosystems.
He then went on to release Clang, a C and C++ compiler that sits on top of LLVM and is used by most of the world's top software developers (including providing the backbone for performance-critical code). of Google).
When evaluating performance in the field of machine learning troubleshooting, the Modular Inference Engine AI stack written in the Mojo language, compared to a solution based on the TensorFlow library, was found to be 3 times faster on a system with a intel processor
However, Chris saw that C and C++ were not taking full advantage of the power of LLVM, so while working at Apple he designed a new language, called "Swift", which he describes as "syntax sugar for LLVM".
It is worth mentioning that the language supports static writing and low-level memory-safe features reminiscent of Rust features, such as reference lifetime tracking and variable borrowing (borrow checker).
In addition to the means for safe operation with pointers, the language also provides features for low-level work, for example, it is possible to directly access memory in unsafe mode using the pointer type, call individual SIMD instructions, or access hardware extensions such as TensorCores and AMX.
Currently, the language is under intensive development , and only the online interface is available for testing. Separate builds for local systems will be released later, after receiving feedback on the interactive web environment.
The open source code of the compiler, JIT, and other project-related development is planned after the internal architecture design is complete (the development model for a closed-door working prototype resembles the early stage of development of LLVM, Clang and Swift).
Since Mojo's syntax is based on Python and the type system is close to C/C++, there are plans in the future to develop a set of tools to make it easier to translate existing projects written in C/C++ and Python to Mojo, as well as to develop hybrid projects that combine Python and Mojo code.
Finally, if you are interested in learning more, you can find the details at the following link.