Mojo Vs Python &#8211; The Python Replacement Language
AI infrastructure company, Modular AI, recently unveiled Mojo, a new programming language that combines the syntax of Python along with the portability and speed of C, making it ideal for both research and production. Besides this, in the Product Launch 2023 Keynote, Tim Davis and Chris Lattner, the  person behind LLVM and Swift fame also released one of the fastest, unified inference engines called Modular Platform. https://twitter.com/Modular_AI/status/1653436642248781825 The creators of Mojo say that it had no intention of creating a new programming language. “But as we were building our platform with the intent to unify the world’s ML/AI infrastructure, we realised that programming across the entire stack was too complicated,” reads the blog. This means building a programming language with powerful compile-time metaprogramming, integration of adaptive compilation techniques, caching throughout the compilation flow, and other things that are not supported by existing languages. That is the direction that Mojo is heading towards. The team claims it is 35000X faster than Python. Key Features of Mojo Native support for multiple hardware backends: Mojo allows for utilization of CPUs, GPUs, TPUs, and custom ASICs, catering to the strengths of each hardware type. High-level syntax and semantics: Mojo’s high-level syntax and semantics are comparable to Python, making it easy for Python-savvy developers to learn and use. Automatic parallelisation: Mojo simplifies writing of efficient, parallel code through automatic parallelisation across multiple hardware backends, without requiring low-level parallelisation knowledge. Type inference and checking: Mojo offers a type inference and checking system, catching compile-time errors and reducing the likelihood of runtime errors. Static compilation: Mojo is statically compiled, resulting in faster execution times and better optimization as code is compiled before execution. Is Mojo a New Programming Language, Really? Looks like Julia, the one that was touted as the Python replacement for its scalability and one of the most embraced programming languages of the last few years, competing with Rust, finally has another competitor. Moreover, according to the documentation of Mojo, instead of starting from scratch, the programming language will leverage 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++. One of the major motivations behind building the new programming language according to the developers was that most of the modern programming systems rely on accelerators like GPU for operations, and only “fall back” on main CPUs for supporting operations like data loading, pre and post processing, and integrations into foreign system written in other languages. The company wanted to support the full gamut of this into one language. Moreover, to not build and innovate a new syntax or community, the company decided to go with Python and its ecosystem. A very smart move indeed! Mojo is also going to remain open-source till it becomes the superset of Python 3. Competitions Galore According to the Stack Overflow Developer Survey 2022, Rust is the most loved programming language, that too for the last seven years continuously. The problem with Rust is its complex syntax, making it a difficult steep learning curve. But even then, Rust is used by Meta, Dropbox, with Google planning to implement it as well. In the same survey, Julia ranked in the top 5 of the most loved languages, defeating Python. Same was the case the year before that. Viral Shah, the co-creator of Julia, in a decade old interview with AIM, said, “We wanted a language that did not trade-off performance for productivity and instead provided both high performance and high productivity.” Interestingly, Elon Musk had recently tweeted about how AGI will not be built on Python, but on Rust. This comes after him saying that he is a fan of Rust last year. To this thread, some users replied that they are on the side of Chris Lattner, and hope that it’s Swift, one of the earlier offerings of Lattner. Now, Modular said that “What if it’s the best of all of them?” https://twitter.com/Modular_AI/status/1649870472417538049 Addressing a lot of these questions on HackerNews about the comparison being made with Julia and Rust, and also future plans to compete with Python, Chris Lattner, one of the co-creators, praises Julia as a “wonderful language and a wonderful community,” calling himself as a super fan. Addressing the differences between Julia and Mojo, he stresses on the point that Mojo has a bunch of technical advancements when it comes to languages like Swift, Rust, C++, and even Julia, because it has learnt from them, and built over them. He further adds that there is definitely space in the AI/ML landscape for another language that makes it easier to deploy and scale down models, while also supporting the full Python ecosystem. He further said, “Julia is far more mature and advanced in many ways.” Interesting how Lattner looks at a problem and decides to make a new programming language altogether, as pointed out by a Twitter user. Though the developers have been humble about how they are taking the approach with Python, the community on HackerNews and Twitter is all out comparing it with Python. A Game Changer? Python, or even Julia, isn’t a preferred programming language when it comes to systems programming, but mostly for AI model building. Though it overcomes that limitation with low-level binding to C and C++ for building libraries. But building these hybrid libraries is a complicated task that requires the knowledge of C and C++ as well. This is where Mojo comes in and makes it into a one integratable and backwards compatible Python-like language – “Pythonic-C” But on the other hand, whenever there is a new technology coming in place, there are the sceptics and naysayers, who sometimes also bring up interesting points. While some people on Hacker News forum are arguing that this might be a Python replacement, some are still sceptical about the performance improvement that the creators of the language promise. Some even don’t call it ‘Pythony’, which the developers behind the language have made efforts to stay away from. Python seems like it’s becoming the language of the future for its ease of use, utility across many distinct domains, and support through various large language models.The duct tape of programming languages.Wouldn’t have expected it. https://t.co/Wmf7gKCNHr— Andrew Ruiz (@then_there_was) May 2, 2023 Another person on the forum calls Mojo the final nail in the coffin for “Julia as a replacement for Python”. Maybe Julia has missed out on its window of opportunity to replace Python, and Mojo is here to do the job. Still, the arena of programming languages remains unpredictable. Moreover, this might be just another Julia moment in the world of programming, with Python syntax. Anyway, OpenAI is on a somewhat similar mission with Triton, their own programming language.
Who knows? Mojo might be just another ‘Julia moment’ in the making, or might actually be the language of the future
AI infrastructure company, Modular AI, recently unveiled Mojo, a new programming language that combines the syntax of Python along with the portability and speed of C, making it ideal for both research and production.
["Julia", "Programming Languages", "Python", "Rust"]
["Go", "TPU", "OpenAI", "AI", "ML", "Julia", "Programming Languages", "RAG", "Python", "Aim", "Rust", "R"]
["AI", "ML", "OpenAI", "Aim", "RAG", "TPU", "Python", "R", "Go", "Rust"]
Mohit writes about AI in simple, explainable, and often funny words. He's especially passionate about chatting with those building AI for Bharat, with the occasional detour into AGI.