Modular AI and Mojo: Chris Lattner has done it again!


@clattner_llvm has done it again withv@Modular_AI!

My mind was blown and filled with new ideas after listening to @lexfridman‘s most recent podcast with him on the future of programming and AI.

Here are the top facts you need to learn about Mojo, the new programming language, 35000x faster than Python:


Mojo eliminates the need for programmers to manually adjust parameters for optimal performance on different systems, making the code more portable and efficient. It works by empirically testing different configurations on the target machine and caching the best result for that system.


  • Everything is Python is an object, and it is referenced as a pointer in the call memory stack. By eliminating these pointers and transferring these objects directly to the registers, there is already a x10 improvement in Mojo.
  • As opposed to Python, Mojo eliminates the Python GIL, and hence enables true multithreading. Fundamental with modern CPUs, GPUs, TPUs, etc.


Mojo, a superset of Python, brings remarkable improvements to typed programming. By integrating optional typing, Mojo not only maintains Python’s flexibility but also allows for better code optimization and completion. This facilitates gradual and flexible adoption of typing based on developers’ requirements and preferences, providing them the freedom to control code optimization levels.


  • Mojo allows optional typing, offering a balance between flexibility and optimization potential.
  • The introduction of types can be progressive in Mojo, enabling developers to add as many types as they need in their code. — Despite supporting types, Mojo remains fully compatible with Python, supporting all Python packages and dynamic operations.
  • Unlike Python, in Mojo, declared types are enforced by the compiler, adding a safety layer.
  • The approach of Mojo towards typing is designed to cater to different development situations, from prototyping to large-scale code bases. It aids in reducing errors, optimizing performance, and facilitating better code understanding.


One of the main advantages of Mojo is immutability, which improves performance. Immutability means that a value, once created, cannot change. This feature prevents bugs that could occur when an unexpected change to a value causes unforeseen consequences in other parts of the code. By providing what’s known as “value semantics,” Mojo ensures that if a data collection like an array or a dictionary is passed around within the code, a logical copy of all the data is made. This means that any changes made to that collection won’t affect the original data.


  • Mojo allows for the expression of complex data structures like atomic numbers or uniquely owned database handles.
  • Borrowed conventions in Mojo let the data be used without making copies, thus enhancing the performance.
  • Mutable references in Mojo can change the data without making a copy.
  • The abstraction level in Mojo can be adjusted from very low-level systems to application and scripting, making it a highly scalable system.
  • This level of detail is particularly beneficial to systems programmers who often need to directly manipulate bits and memory layouts.
  • Mojo combines the benefits of high-level languages (like Python) with the performance and flexibility of lower-level languages (like C++ or Rust).


Python was originally created for a completely different worlds, and Python libraries like 


 inherit these shortcomings. Mojo, on the other hand, when dealing with serving, complex distributed systems comes to the rescue, as it easily scales for new hardware without being hardware specific, and hence taking away the requirement of being an expert in hardware as a software engineer to create complex and efficient algorithms.


  • Mojo unlocks new hardware innovation, as it is easier to develop specific hardware for specific hardware needs when creating and designing an AI model for a certain task.
  • Heterogenous runtimes means that computing operations (CPUs, NPUs, GPUs communications) can now be better scheduled to avoid classical timely computer science problems.


To fully remediate the problem of needing to change the architecture and programming of extremely optimized AI models every single time third-party hardware vendors (Apple, NVIDIA, Intel, etc.) release new hardware, Mojo allows for an abstraction and scalable approach to factoring this complexity to avoid this problem.


  • Modular stack can adapt to new hardware designs and hence not requiring the software engineer to be equally proficient in hardware.
  • Vectorised and parallised techniques make it possible.
  • Tiling is also used for memory optimisation, and it makes sure the entire memory cache is used in each hardware.


  1. Mojo can implement CPython libraries.
  2. CPython objects can natively be used in Mojo directly.
  3. Mojo creates the ‚one world‘ that gets the best from Python, its interpreter, its libraries, etc.
  4. Latest Python research (by Microsoft) in latest release can only obtain a 20% improvement at best, far away from Mojo.

A few promises from @clattner_llvm himself:

  1. Mojo‘s developers will not have to go through the painful change from Python2 to Python3, whereby entire companies with huge codebases needed to completely rewrite their code.
  2. AGI could be run using Mojo programming language.
  3. Python code can run in Mojo code natively, at least as fast and generally faster than Python code alone.
  4. Mojo will NOT be Python 4.0, potentially avoiding a Cold War among Pythonians

Hope you enjoyed it as much as I did, and can‘t wait to see what the world builds with it.

Read more about it here and follow for more similar content:

Share this:

Like this:

Like Loading...