In a rapidly changing world, staying informed and inspired is crucial. Stay ahead of the curve and ignite your passion for knowledge as we navigate the ever-evolving landscape of our dynamic world. So, today’s post is about the new language MOJO developed by Chris Lattner.
The story behind the development of MOJO: In 2023, Chris Lattner, alongside his co-founders, established Modular, a company specializing in AI infrastructure. Their core objective is to develop a comprehensive AI inference engine that seamlessly handles models from various frameworks on a single platform, requiring minimal to no modifications. Mojo has been designed to incorporate a greater degree of low-level control and optimization-oriented features. These include strong typing, the ability for parallel execution, and a high-level application programming interface (API) to the Multi-Level Intermediate Representation.
Let’s check out some interesting facts about MOJO :
Why only MOJO not any other name?
Mojo means “a magical charm” or “magical powers.” It was thought that this was a fitting name for a language that brings magical powers to Python, including unlocking an innovative programming model for accelerators and other heterogeneous systems pervasive in AI today.
Why does Mojo have the 🔥 file extension?
They paired Mojo with fire emoji 🔥 as a fun visual way to impart to users that Mojo empowers them to get their Mojo on—to develop faster and more efficiently than ever before. They also believe that the world can handle a Unicode extension at this point, but you can also just use the .mojo extension. Share your views regarding this.
Is Mojo only for AI or can it be used for other stuff?
Mojo is a general-purpose programming language. They use Mojo at Modular to develop AI algorithms, but as it grows Mojo into a superset of Python, you can use it for other things like HPC, data transformations, writing pre/post-processing operations, and much more. For examples of how Mojo can be used for other general programming tasks, see the Mojo notebooks.
Is Mojo interpreted or compiled?
Mojo supports both just-in-time (JIT) and ahead-of-time (AOT) compilation. In the Mojo Playground notebook environment, Mojo is being JIT’d. However, for AI deployment, it’s important that Mojo also supports AOT compilation instead of having to JIT compile everything.
Does Mojo support distributed execution?
Not alone. You will need to leverage the Modular Inference Engine for that. Mojo is one component of the Modular stack that makes it easier for you to author highly performant, portable kernels, but you’ll also need a runtime (or “OS”) that supports graph-level transformations and heterogeneous computing.
How do I convert Python programs or libraries to Mojo?
Mojo is still early and not yet a Python superset, so only simple programs can be brought over as-is with no code changes. We will continue investing in this and when an update is provided regarding this we will try to upgrade our readers as well.
How does Mojo provide a 35,000x speed-up over Python?
Modern CPUs are surprisingly complex and diverse, but Mojo enables systems-level optimizations and flexibility that unlock the features of any device in a way that Python cannot. So the hardware matters for this sort of benchmark, they ran them on an AWS r7iz.metal-16xl machine. If you get access to the Mojo Playground, you can see Mojo’s capabilities and compare the relative performance of Mojo to Python in the Mandelbrot notebook. Just be aware that the Playground hardware is not the same as what’s used in the benchmark, so you will not see the same results.
An overview of creating a simple program in MOJO –
for x in range(9, 0, -3):
Note: You can run a Mojo program from a terminal just like you can with Python. So if you have a file named hello.mojo (or hello.🔥—yes, the file extension can be an emoji! Isn’t it interesting), just type mojo hello.mojo
Modules in MOJO :
It’s just the start of MOJO so only the following modules are available currently:
- Built-in modules
- Builtin Slice
- Python interop modules
- Standard library modules
Working model of MOJO :
For detailed information, you may visit: https://www.modular.com/mojo.