Mojo's not (yet) Python

https://lobste.rs/rss Hits: 45
Summary

You are getting early access to this article as a subscriber. Your support makes articles like this possible. Thank you.Mojo is a new proprietary, high-level systems programming language from Chris Lattner. The home page of Mojo says it's “Pythonic”. A user quote on the homepage says “Mojo is Python++. It will be, when complete, a strict superset of the Python language.” And the homepage talks about Python interoperability.As both a big programming languages nerd and someone who writes a lot of Python scripts, I have been curious to try out Mojo for some time. I assumed it was something similar to PyPy or Cython where you could write Python code and import some Python libraries and unless you did things that directly relied on the runtime itself (e.g. FFI calls), existing code would all basically work.On a Ubuntu 24.04 machine install these and we'll take a look.$ sudo apt-get install -y python3-pip cython3 pypy3 hyperfine $ pip3 install --break-system-packages mojo $ python3 --version Python 3.12.3 $ cython3 --version Cython version 3.0.8 $ pypy3 --version Python 3.9.18 (7.3.15+dfsg-1build3, Apr 01 2024, 03:12:48) [PyPy 7.3.15 with GCC 13.2.0] $ mojo --version Mojo 0.26.1.0 (156d3ac6) While there are many similarities between Python and Mojo at the syntax level, and while the goal of Mojo might indeed be to eventually be a superset of Python, I would say that it is basically not compatible with Python. I don't think I was the only person unclear about this since, for example, the Wikipedia page for Mojo currently has a Python-looking example of a sub function that doesn't actually compile. (Perhaps it used to compile under a previous version of Mojo.)$ cat foo.mojo def sub(x, y): res = x - y return res def main(): sub(3, 1) $ mojo foo.mojo /tmp/trymojo/foo.mojo:1:9: error: argument type must be specified def sub(x, y): ^ /tmp/trymojo/foo.mojo:1:12: error: argument type must be specified def sub(x, y): ^ /usr/local/bin/mojo: error: failed to parse the provided Mojo ...

First seen: 2026-03-25 17:52

Last seen: 2026-03-27 14:27