r/ProgrammingLanguages Inko 14d ago

Blog post Mojo🔥 is now open source!

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

63 comments sorted by

View all comments

23

u/IncredibleReferencer 14d ago

As a traditional programmer that doesn't know squat about GPU/AI programming, I'm confused by the value proposition of mojo. As best I can understand it it's an alternative to CUDA intended to be somewhat hardware agnostic, but it still requires licensed proprietary components to be used in any meaningful production environment. So your trading one lock-in for another. What am I missing?

11

u/Hornstinger 14d ago

CUDA is one of a few different GPU languages. You also have the Chinese chips which have their own language too as far as I'm aware so Mojo's proposition is to use one language i.e. Mojo across any hardware WITHOUT vendor lock-in so you're not juggling multiple languages and multiple compilers and also not locked into an ecosystem.

Plus it's fully Python compatible so instead of throwing away or translating Python scripts you cam use them in Mojo AND Mojo has C/C++ speed with some of Rust and Zig's comptime safety.

4

u/Llamas1115 13d ago

It’s not Python-compatible, they gave up on that (because it was never possible, you literally just can’t make Python fast without breaking the whole ecosystem).

3

u/Hornstinger 12d 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 10d 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 10d 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 7d 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.

1

u/biskitpagla 13d ago

Head over to the website for Taichi Lang and see the samples. You can do all that with Mojo in theory.Â