top | item 44331316

Python can run Mojo now

325 points| cantdutchthis | 8 months ago |koaning.io

165 comments

order

pjmlp|8 months ago

Given that NVidia now decided to get serious with Python JIT DSLs in CUDA as announced at GTC 2025, I wonder how much mindshare Mojo will managed win across researchers.

"1001 Ways to Write CUDA Kernels in Python"

https://www.youtube.com/watch?v=_XW6Yu6VBQE

"The CUDA Python Developer’s Toolbox"

https://www.nvidia.com/en-us/on-demand/session/gtc25-S72448/

"Accelerated Python: The Community and Ecosystem"

https://www.youtube.com/watch?v=6IcvKPfNXUw

"Tensor Core Programming in Python with CUTLASS 4.0"

https://www.linkedin.com/posts/nvidia-ai_python-cutlass-acti...

There is also Julia, as the black swan many outside Python community have moved into, with much more mature tooling, and first tier Windows support, for those researchers that for whatever reason have Windows issued work laptops.

https://info.juliahub.com/industries/case-studies

Mojo as programming language seems interesting as language nerd, but I think the judge is still out there if this is going to be another Swift, or Swift for Tensorflow, in regards to market adoption, given the existing contenders.

fnands|8 months ago

Mojo (and Modular's whole stack) is pretty much completely focused at people who are interested in inference, not training nor research so much at this moment.

So going after people who need to build low latency high-throughput inference systems.

Also as someone else pointed out, they also target all kinds of hardware, not just NVidia.

bsaul|8 months ago

Mojo is marketed as a way to get maximum hardware performance on any hardware, not just nvidia.

This may appeal to people wanting to run their code on different hardware brands fro various reasons.

fulafel|8 months ago

The limitations of DSLs and the pull of Python make it a practical sweet spot I think if they manage to get the Python compatibility up to par.

ForHackernews|8 months ago

I love Julia and want to see it break through. It suffers from the lack of a big corporate patron.

btian|8 months ago

Mojo runs on nVidia and AMD.

The competitor is Triton, not CUDA or Julia...

GeekyBear|8 months ago

Chris Lattner (the tech lead behind Mojo, LLVM, Clang, Swift and MLIR) appeared on a podcast a bit over a week ago and discussed the state of Mojo and where it is going.

He also discussed open sourcing Mojo and where the company expects to make its money.

https://www.youtube.com/watch?v=04_gN-C9IAo

mattclarkdotnet|8 months ago

That video is restricted, do you have a public link?

JonChesterfield|8 months ago

The factorial test giving zero on majo suggests they aren't doing arbitrary precision integer arithmetic.

I liked mojo as a python superset. Wanted to be able to run arbitrary python through it and selectively change parts to use the new stuff.

A "pythonic language" sounds like that goal has been dropped, at which point the value prop is much less clear to me.

melodyogonna|8 months ago

From Chris Lattner on Modular discord few days ago:

Yep, that's right. Int behaving like a machine integer is very important for systems performance. Leaving the "int" namespace untouched allows us to have a object-based bigint in the future for compatibility with python. As others have mentioned above, it is still a goal to be compatible with python in time, just not a short term priority

eyegor|8 months ago

I guess they abandoned the python superset idea? I followed them for a bit when they first publicly launched and they said "don't worry, we'll be a real python superset soon" and the biggest omission was no support for classes. A few years later, it looks to be missing the same set of python features but added a lot of their own custom language features.

saagarjha|8 months ago

Taking unchanged Python and making it fast is basically impossible.

bishabosha|8 months ago

They explicitly casted it to an 'Int' on the mojo side, but the modular website claims that isnt a specific bit-width so i am surprised

markkitti|8 months ago

The Python superset concept was always a gimmick. The goal was always to juxtapose Python with a language that superficially looks like Python in order for you to completely migrate from Python to Mojo. It is just providing a smooth ramp for you to do so in the same Apple migrated folks from Objective-C to Swift.

Embrace. Extend. Extinguish.

mhh__|8 months ago

[deleted]

js2|8 months ago

For anyone not up to speed on Mojo: Mojo is a pythonic language for blazing-fast CPU+GPU execution without CUDA:

https://news.ycombinator.com/item?id=35790367

eddythompson80|8 months ago

I'm glad the blazing-fast tech is finally making it to python. Those guys were pretty busy with Rust for like the past 10 years. I'm glad they are finally starting to making a blazing-fast python stuff.

mindwok|8 months ago

I am really rooting for Mojo. I love what the language is trying to do, and making it easier to run SOTA AI workloads on hardware that isn't Nvidia + CUDA will open up all kinds of possibilities.

I'm just nervous how much VC funding they've raised and what kind of impacts that could have on their business model as they mature.

mkaic|8 months ago

If they can manage to make good on their plans to open-source it, I'll breathe a tentative sigh of relief. I'm also rooting for them, but until they're open-source, I'm not willing to invest my own time into their ecosystem.

bgwalter|8 months ago

No, Python cannot run Mojo. Like Cython and hundreds of other projects, Mojo creates a C-extension, which is then loaded.

https://docs.modular.com/mojo/manual/get-started/

  curl -fsSL https://pixi.sh/install.sh | sh
  pixi init life \
  -c https://conda.modular.com/max-nightly/ -c conda-forge \
  && cd life
No, thanks. C++ is easier.

hogepodge|8 months ago

One of the big differences here is that the Mojo/Python interop package is doing a lot of the heavy lifting of compiling and loading the code. The goal here is to have a language that's close to Python that gives you hardware acceleration as you need it, without having to configure and build C++ code for every platform.

We've run a few events this year (disclosing again that I work for Modular, to put my comments into context), and we've had some great feedback from people who have never done GPU programming about how easy it was to get started using Mojo.

C++ is a powerful and mature language, but it also has a steep learning curve. There's a lot of space for making GPU (and other high performance computing) easier, and platforms/languages like Triton and Julia are also exploring the space alongside Mojo. There's a huge opportunity to make GPU programming easier, and a bit part of that opportunity is in abstracting away as much of the device-specific coding as you can.

I was a HPC C++ programmer for a long time, and I always found recompiling for new devices to be one of the most painful things about working in C++ (for example, the often necessary nightmare of cmake). Mojo offers a lot of affordances that improve on the programming experience at the language, compiler, and runtime levels.

sanderjd|8 months ago

The example in the article seemed a lot easier to build and use than a C++ extension.

It's unclear to me from this comment, what exactly your pushback is.

justin66|8 months ago

> C++ is easier.

I expect that opinion will not be universally agreed upon.

anon-3988|8 months ago

I am not that intrigued that Python that can call some pre-compiled functions, this is already possible with any language that produces a dynamic library.

The space that I am interested in is execution time compiled programs. A usecase of this is to generate a perfect hash data structure. Say you have a config file that lists out the keywords that you want to find, and then dynamically generate the perfect hash data structure compiled as if those keywords are compile time values (because they are).

Or, if the number of keywords is too small, fallback to a linear search method. All done in compile time without the cost of dynamic dispatch.

Of course, I am talking about numba. But I think it is cursed by the fact that the host language is Python. Imagine if Python is stronger typed, it would open up a whole new scale of optimization.

pjmlp|8 months ago

I would rather image CPython being like Common Lisp, Scheme, Raket, Smalltalk, Self compilation model.

Sadly the contenders on the corner get largely ignored, so we need to contend with special cased JIT DSLs, or writing native extensions, as in many cases CPython is only implementation that is available.

devjab|8 months ago

> I am not that intrigued that Python that can call some pre-compiled functions, this is already possible with any language that produces a dynamic library.

> The space that I am interested in is execution time compiled programs. A usecase of this is to generate a perfect hash data structure. Say you have a config file that lists out the keywords that you want to find, and then dynamically generate the perfect hash data structure compiled as if those keywords are compile time values (because they are).

I'm not sure I understand you correctly, but these two seem connected. If I were to do what you want to do here in Python I'd create a zig build-lib and use it with ctypes.

Scene_Cast2|8 months ago

The thing I focus on when writing compiled extensions for Python isn't the speed of the extension, but rather the overhead of the call and the overhead of moving objects from Python -> compiled and compiled -> Python.

Is there a zero-copy interface for larger objects? How do object lifetimes work in that case? Especially if this is to be used for ML, you need to haul over huge matrices. And the GIL stuff is also a thing.

I wonder how Mojo handles all that.

MohamedMabrouk|8 months ago

AFAIK, there is a zero-copy interface for objects like numpy array and torch tensors where you can do in-place manipulation in mojo.

benrutter|8 months ago

I've never been thats sold on Mojo, I think I'm unfairly biased away from it because I find new languages interesting, and its big sell is changing as little as possible from an existing language.

That said, importing into Python this easily is a pretty big deal. I can see a lot of teams who just want to get unblocked by some performance thing, finding this insanely helpful!

atomicapple|8 months ago

> its big sell is changing as little as possible from an existing language.

This is not really true. Even though Mojo is adopting Python's syntax, it is a drastically different language under the hood. Mojo is innovating in many directions (eg: mlir integration, ownership model, comptime, etc). The creators didn't feel the need to innovate on syntax in addition to all that.

Tiberium|8 months ago

> as I'm definitely in the market for a simple compiled language that can offer Python some really fast functions So, Nim? https://github.com/yglukhov/nimpy

mindwok|8 months ago

The real point of Mojo is not the language, it's the deep roots into MLIR which is an attempt to do what LLVM did for compilers, and do it on GPUs / ML hardware. Chris Lattner is leading the project and he created LLVM and MLIR.

Someone|8 months ago

FTA (emphasis added): “Chris Lattner mentioned that Python can actually CALL Mojo code now”

So, the message is that it is possible to create nice Python bindings from Mojo code, but only if your Mojo code makes the effort to create an interface that uses PythonObject.

Useful, but I don’t see how that’s different from C code coding the same, as bindings go.

Both make it easier to gradually move Python code over to a compiled language.

Mojo presumably will have the advantage that porting from Python to Mojo is much closer to a copy paste job than porting Python to C is.

amval|8 months ago

For a language that announced itself (and raised a lot of money on the premise of) claiming to be "a Python superset", this does not sound like a huge achievement.

In all fairness, their website now reads: "Mojo is a pythonic language for blazing-fast CPU+GPU execution without CUDA. Optionally use it with MAX for insanely fast AI inference."

So I suppose now is just a compiled language with superficially similar syntax and completely different semantics to Python?

Certhas|8 months ago

I think it was pretty clear immediately that running python code was a far away goal. There was a lot more talk about lifetimes and ownership semantics than details about Python interop. Mojo is more like: Can we take the learnings of Swift and Rust and solve the usability and compile time issues, while building on MLIR to target arbitrary architectures efficiently (and call it a Python superset to raise VC money).

That said, the upside is huge. If they can get to a point where Python programmers that need to add speed learn Mojo, because it feels more familiar and interops more easily, rather than C/CPP that would be huge. And it's a much lower bar than superset of python.

dragonwriter|8 months ago

The real unique selling point of Mojo is "CPU+GPU execution without CUDA", specifically, you write code that looks like code without worrying about distinctions like kernels and device functions and different ways of writing code that runs on GPU vs. code that runs on CPU, and mojo compiles it to those things.

saghm|8 months ago

> For a language that announced itself (and raised a lot of money on the premise of) claiming to be "a Python superset", this does not sound like a huge achievement

I feel like that depends quite a lot on what exactly is in the non-subset part of the language. Being able to use a library from the superset in the subset requires being able to translate the features into something that can run in the subset, so if the superset is doing a lot of interesting things at runtime, that isn't necessarily going to be trivial.

(I have no idea exactly what features Mojo provides beyond what's already in Python, so maybe it's not much of an achievement in this case, but my point is that this has less to do with just being a superset but about what exactly the extra stuff is, so I'm not sure I buy the argument that the marketing you mention of enough to conclude that this isn't much of an achievement.)

melodyogonna|8 months ago

I've written this somewhere else before, Modular did not raise $130m to build a programming language, nobody does that. They raised that much money to revolutionize AI infrastructure, of which a language is just a subset. You should definitely check some of the things they've put together, they're amazing

dismalaf|8 months ago

It was never going to have Python semantics and be fast. Python isn't slow because of a lack of effort or money, it's slow because of all the things happening in the interpreter.

meander_water|8 months ago

Fwiw the website still claims this:

> Further, we decided that the right long-term goal for Mojo is to adopt the syntax of Python (that is, to make Mojo compatible with existing Python programs) and to embrace the CPython implementation for long-tail ecosystem support

Which I don't think has changed.

boxed|8 months ago

I believe they're still working towards making the syntax and semantics more python-like.

boguscoder|8 months ago

Are labels on first output misplaced or mojo was actually slower?

’’’ 3628800 Time taken: 3.0279159545898438e-05 seconds for mojo

3628800 Time taken: 5.0067901611328125e-06 seconds for python ’’’

que-encrypt|8 months ago

My guess is that the slight overhead of interacting with mojo led to this speed discrepancy, and if a higher factorial (that was within the overflow limits etc) was run, this overhead would become negligible (as seen by the second example). Also similar to jax code being slower than numpy code for small operations, but being much faster for larger ones on cpus etc.

adsharma|8 months ago

I like mojo for being closer to python than other systemsy languages.

But asking people to learn another language and migrate is a tall barrier.

Why not write python and transpile to mojo?

dummydummy1234|8 months ago

My impression is that mojo is not python, there are similarities, but under the hood mojo is much more similar to c++/rust.

As part of this it has a stronger type/lifecycle/memory model than python.

Maybe you could write, some level of transpiler, but so much of the optimizations rely on things that python does not expose (types), and there are things that python can do that are not supported.

faceplanted|8 months ago

Transpilers in general tend to be significantly less well maintained and optimised than direct APIs

melodyogonna|8 months ago

The plan is to have a mechanical tool someday that can transpile Python code to Mojo

tgma|8 months ago

I hope this ends up superseding Cython

williamstein|8 months ago

Same, and I literally started Cython. :-)

fnands|8 months ago

I think that's one of the real strong use cases I see coming up.

If they can make calling Mojo from Python smooth it would be a great replacement for Cython. You also then get easy access to your GPU etc.

mikebrave|8 months ago

I really want to use mojo/max for graphics and game programming, but they don't seem interested in going that route.

b33j0r|8 months ago

I’m someone who should be really excited about this, but I fundamentally don’t believe that a programming language can succeed behind a paywall or industry gatekeeper.

I’m always disappointed when I hear anything about mojo. I can’t even fully use it, to say nothing of examine it.

We all need money, and like to have our incubators, but the LLVM guy thinks like Jonathan Blow with jai?

I don’t see the benefit of joining an exclusive club to learn exclusively-useful things. That sounds more like a religion or MLM than anything RMS ever said :p

ModernMech|8 months ago

> the LLVM guy thinks like Jonathan Blow with jai?

I would not compare Chris Lattner with Jonathan Blow. Lattner is a person with a reputation for delivering programming languages and infrastructure; whereas for Blow, it seems like an ego issue. He's built a nice little cult of personality around his unreleased language, and releasing it will kill a lot of that magic (running a language project with actual users that has to make good on promises is much different than running a language project with followers and acolytes that can promise anything and never deliver on it).

Lattner has a record of actually delivering dev products people can download and use. Mojo is closed source to make raising money easier, but at least you can actually use it. Jai isn't even available for people to use, and after a decade of Blow dangling it in front of people, it's not clear it'll ever be available, because I'm not sure he wants it to be available.

gjvc|8 months ago

i wish python were as fast as perl for equivalent string-based workloads

almostgotcaught|8 months ago

> Functions taking more than 3 arguments. Currently PyTypeBuilder.add_function() and related function bindings only support Mojo functions that take up to 3 PythonObject arguments: fn(PythonObject, PythonObject, PythonObject).

Lol wut. For the life of me I cannot fathom what design decision in their cconv/ABI leads to this.

rybosome|8 months ago

I was wondering if it is function overloads of the same name, defining it non-variadically:

add_function(PythonObject)

add_function(PythonObject, PythonObject)

add_function(PythonObject, PythonObject, PythonObject)

There was a similar pattern in the Guava library years ago, where ImmutableList.of(…) would only support up to 20 arguments because there were 20 different instances of the method for each possible argument count.

MHM5000|8 months ago

> truck of salt

:)))

usrbinbash|8 months ago

https://en.wikipedia.org/wiki/Mojo_(programming_language)

> As of February 2025, the Mojo compiler is closed source

And that's where the story begins and ends for me.

roflmaostc|8 months ago

https://docs.modular.com/mojo/faq/#open-source

> Will Mojo be open-sourced?

> We have committed to open-sourcing Mojo in 2026. Mojo is still young, so we will continue to incubate it within Modular until more of its internal architecture is fleshed out.

Soon it might be though.

ValtteriL|8 months ago

Was lowkey hoping this was about Mojolicious, the Perl web framework

dkechag|8 months ago

Yeah, I also get confused with references. I was annoyed from the start, when "Mojo" was announced as a Python family language. Mojolicious uses the "Mojo" namespace and is referred to as that quite often. I know Perl is not as popular as it used to be, but Mojolicious is probably the most popular framework of a language that is roughly in the same "space" as Python, so that naming choice was very ignorant IMHO.