Will Mojo Replace Python?
Recently, Modular, the company behind Mojo, a programming language that offers a unique blend of Python’s usability with the performance capabilities of C, raised $100 million to fix AI infrastructure for developers.
Its high performance has prompted many developers on Reddit to ask: Will Mojo kill Python and become the king of programming languages? Should a person who wanted to learn Python in the first place stop that and start learning Mojo?
What’s Mojo?
The developers of Mojo discovered that programming languages were excessively complex. This required developing one that supported features not found in other languages, such as adaptive compilation strategies, caching during the compilation process, and strong compile-time metaprogramming.
Soon, Mojo became a popular programming language among the developers. Software and machine learning engineer Santiago Valdarrama has gone to the extent of saying that, “Mojo has the potential to take over AI development.”
Mojo is at Its Heart Just Python
Modular has described Mojo as a superset of Python that is adding new functionalities by making Python the base language, thereby, making it more versatile and the fastest ever.
This seems wise, not just because Python is already well understood by millions of coders, but also because after decades of use, its capabilities and limitations are now well understood.
Moreover, Mojo leverages the entire ecosystem of Python libraries, while also being built on a brand new codebase. This, along with the high computational ability of C and C++ will enable AI Python developers to rely on Mojo, instead of falling back on C or C++.
Mojo Has Its Own Space
Python is one of the most popular programming languages in the world due to its user-friendliness and flexibility. For developers, meanwhile, its poor speed and performance present the biggest obstacles. For improved efficiency, developers consequently rewrite the Python prototype in C++.
However, the two-language method is ineffective for developing AI. Companies that have invested millions of dollars in Python codebases have no appetite to rewrite that code.
Performance comparison of Python and Mojo. Source:
This is where Mojo will win. Python is not an option for when you need high-performing code, taking advantage of modern hardware. Though pretty new, if Mojo delivers, there’s no chance for any other language.
Python is Not Flawless
One of the reasons Mojo quickly gained attention is its ability to address the shortcomings of Python. Python continues to be a highly popular programming language. There is a drawback though: performance.
Although a few percent off is not really noticeable, Python is remarkably slower than other programming languages like C++. This makes it impossible to use Python in the inner loops of the code, where efficiency is essential.
Many people rewrite their slow Python code in C++ or Rust when they need speed. Unfortunately, the two-world problem, also known as hybrid libraries, or the constant necessity for two languages, makes debugging extremely difficult. It also greatly complicates the use of huge frames.
This becomes a three-world/n-problem with AI. Programming system innovation is restricted in the field of artificial intelligence. A programming language called CUDA is exclusive to one hardware manufacturer.
Although a number of new hardware systems are being developed, there isn’t a standard language that is compatible with all of them. Within the AI community, these further fragment programming methods.
Not Python, C++ is the Target
Mojo is no threat to Python, instead it lifts it up and gives Python programmers superpowers. However, Mojo’s target is something else: C++. So, while developers think Mojo will replace Python, Chris Lattner, the co-founder of Modular AI, the company that developed Mojo, has a different take.
“If anyone should be scared, it should be C++ and hard-to-use accelerator languages. Python is what developers love: C++ is mostly a pragmatic necessary evil for when you need performance,” Lattner wrote in a post on X.
This is in line with what AIM had said before about C++ not being the go-to language for AI development.
Deliberately or not, Mojo is positioning itself as a subset of Python to cover an extremely wide space. The fusion of Python’s AI dominance with Mojo’s performance capabilities could be a paradigm shift for AI development.
link