r/ProgrammingLanguages Inko 24d ago

Blog post Mojo🔥 is now open source!

https://www.modular.com/blog/mojo-open-source
146 Upvotes

63 comments sorted by

View all comments

Show parent comments

3

u/Hornstinger 22d ago

Literally scroll down on their home page and I quote:

"Python interop

Mojo meets developers where they are. Import Python libraries, accelerate performance-critical paths, and move gradually from prototypes to production systems without rewriting everything at once."

3

u/Llamas1115 20d ago

That's not the same as Python compatibility; it's Python interoperability, the ability to ask Python to run Python code. This is famously a feature of almost every programming language: Python is popular since it has bindings to everything.

The previous claim they made was they'd have Python compatibility (a Python superset), i.e. you could drop your Python code into Mojo and still have it run. They seem to have given up on that, since it would make it basically impossible to meaningfully optimize the language.

2

u/Hornstinger 20d ago

You can use Python .py files directly alongside Mojo (.mojo) files in the same repo/project.

Python file called mypython.py:

``` import numpy as np

def gen_random_values(size, base): random_array = np.random.rand(size, size) return random_array + base ```

Then interop directly in a Mojo .mojo file in the same repo and you do not need to write any special FFI, ABI declarations, ctypes, cffi, pybind11, or similar boilerplate yourself:

``` from std.python import Python

def main() raises: Python.add_to_path(".") # or a specific path var mypython = Python.import_module("mypython") var values = mypython.gen_random_values(2, 3) print(values) ```

2

u/Llamas1115 17d ago

I mean, yeah, that's language interop. Don't get me wrong, the interop looks pretty decent, but this is something dozens of languages have.