There is a brand new language called Mojo that appeared in 2023 and became very eye-catching quickly. It was created by Chris Lattner, the original architect of the Swift programming language. Mojo is designed to be a superset of Python. The syntax is very similar to Python and thus very friendly to Python developers.
Mojo is a compiled language and is magnitudes faster than Python. It’s specifically optimized for ML/AI-related calculations and thus can be interesting and helpful to learn for common Python developers.
In this post, we will introduce the very fundamentals of Mojo and compare them with their counterparts in Python. I’m sure you will be surprised by its syntax and efficiency when compared with Python.
Why Mojo
Mojo is currently a proprietary programming language developed by the AI company Modular, whose goal is to build an extensible and unified AI platform that removes complexity and adds flexibility and speed to AI development. And Mojo is the new language developed for this platform to solve the AI infrastructure scaling and acceleration issues. It is the first programming language built with MLIR, a compiler infrastructure that’s ideal for heterogeneous hardware including modern CPUs and GPUs. In a nutshell, Mojo is a new language for AI.
Mojo and Python
Mojo is designed to be a superset (or advanced version) of Python, similar to how TypeScript is a superset of JavaScript which is a great enhancement to JavaScript. Therefore, it will be very easy for Python developers to get started with Mojo.
Python is a dominant language in ML/AI and many other fields, especially in data-related ones. However, Python suffers from poor low-level performance and global interpreter lock (GIL) for concurrency. These issues have long been a headache issue for Python developers and are the embarrassing reason why people say Python is slow and not concurrent. They are also an important fact that limits the development of Python and what makes Python end up as a glue language where all core functionalities are developed in other more…