9 ms·
Python can run Mojo now
- mindwok 1y agoI 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 1y agoIf 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.
- jillesvangurp 1y agoThey already released their code under the Apache 2.0 license. Not everything in their stack is open source but the core things appear to be open source.
- ayhanfuat 1y agoTheir compiler is not open source. They only released stdlib code.
- almostgotcaught 1y 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 1y agoI 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.
- deleted 1y ago[deleted]
- bmacho 1y agoProbably not, since they would surely up it at least 15 arguments, instead of 3. But what else, then?
- js2 1y agoFor 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 https://news.ycombinator.com/item?id=35790367
- eddythompson80 1y agoI'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.
- pjmlp 1y agoIt could already be -fast, even if not blazing, if there was more love for projects like PyPy.
- GeekyBear 1y agoChris 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 https://www.youtube.com/watch?v=04_gN-C9IAo
- mattclarkdotnet 1y agoThat video is restricted, do you have a public link?
- GeekyBear 1y agoSorry, but I'm not having any issue with that link. Here is a link to the episode listing for that podcast, which might help. https://www.youtube.com/@LatentSpacePod https://www.youtube.com/@LatentSpacePod
- abybaddi009 1y agoDoesn't seem to be restricted. Do you mean region locked?
- slyall 1y agoVideo isn't region locked according to the tool I normally use https://polsy.org.uk/stuff/ytrestrict.cgi https://polsy.org.uk/stuff/ytrestrict.cgi
- duttish 1y agoJust worked fine for me. I'm logged into youtube, if you're not something with that perhaps?
- loudmax 1y agoIt's the Latent Space podcast, published June 13. It's a pretty decent podcast for keeping on top of AI stuff. Swyx, one of the co-hosts, is active here on HN.
- 1y ago
- tgma 1y agoI hope this ends up superseding Cython
- williamstein 1y agoSame, and I literally started Cython. :-)
- fnands 1y agoWhat's your current take on Cython vs other options? E.g. DSLs and I guess PyO3?
- fnands 1y agoI 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.
- Tiberium 1y 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 https://github.com/yglukhov/nimpy
- mindwok 1y agoThe 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.
- deleted 1y ago[deleted]
- benrutter 1y agoI'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 1y 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.
- benrutter 1y agoYou're right- I probably should have said something like "part of its sell" or "one of its selling points" or something. I didn't mean to undermine the ambitious goals the project has. I still wish it was a little bolder on syntax though, Python is a large and complex language as is, so a superset of Python is inherently going to be a very complicated language.
- markkitti 1y agoThe creators got burned on Swift for TensorFlow, their first MLIR project. One of the problems with that first venture under Google was that the language was not Python.
- anon-3988 1y agoI 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.
- devjab 1y 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.
- anon-3988 1y agoCan Zig recompile itself if I change a config in production? I am talking about this ``` python program.py --config <change this> ``` It is basically a recompilation of the whole program at every execution taking into account the config/machine combination. So if the config contains no keyword for lookup, then the program should be able to be compiled into a noop. Or if the config contains keyword that permits a simple perfect hash algorithm, then it should recompile itself to use that mechanism. I dont think any of the typical systems programming allows this.
- pjmlp 1y ago
- boguscoder 1y agoAre 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 1y agoMy 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.
- mkl 1y agoThe Python function is implemented in C and uses a faster algorithm [1], and this particular factorial is so small they put it in a lookup table [2]. It is a strange and very unequal choice for a demo. [1] https://github.com/python/cpython/blob/0d9d48959e050b66cb37a333940ebf4dc2a74e15/Modules/mathmodule.c#L1819 https://github.com/python/cpython/blob/0d9d48959e050b66cb37a... [2] https://github.com/python/cpython/blob/0d9d48959e050b66cb37a333940ebf4dc2a74e15/Modules/mathmodule.c#L1992 https://github.com/python/cpython/blob/0d9d48959e050b66cb37a...
- gjvc 1y agoi wish python were as fast as perl for equivalent string-based workloads
- ValtteriL 1y agoWas lowkey hoping this was about Mojolicious, the Perl web framework
- dkechag 1y agoYeah, 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.
- amval 1y agoFor 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?
- boxed 1y agoI believe they're still working towards making the syntax and semantics more python-like.
- dragonwriter 1y agoThe 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.
- eigenspace 1y agoNot unique though. Julia has had that since before Mojo was even started.
- melodyogonna 1y agoWhat does the performance of Julia's GPU kernels look like in comparison to kernels written by Nvidia or AMD?
- ChrisRackauckas 1y agoBenchmarks of an early version on NVIDIA's blog show that it is about the same (the average across the benchmark shows Julia as actually a little faster here, but it's basically a wash) https://developer.nvidia.com/blog/gpu-computing-julia-programming-language/ https://developer.nvidia.com/blog/gpu-computing-julia-progra.... While much has changed since then, the architecture is effectively the same. Julia's native CUDA support simply boils down to compiling via the LLVM .ptx backend (Julia always generates LLVM IR, and the CUDA infrastructure "simply" retargets LLVM to .ptx, generates the binary, and then wraps that binary into a function which Julia calls), so it's really just a matter of the performance difference between the code generated by the LLVM .ptx backend vs the NVCC compiler.
- JonChesterfield 1y agoThe 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.
- bishabosha 1y agoThey 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
- int_19h 1y agoIt's not a specific bitwidth in a sense that it maps to whatever largest integer type is natively supported by the target architecture (i.e. basically 32-bit or 64-bit).
- melodyogonna 1y agoFrom 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
- mhh__ 1y ago[flagged]
- 0xpgm 1y agoYour comment is quite subjective, and Python's popularity both in teaching and in industry would suggest otherwise.
- 1y ago
- pjmlp 1y agoGiven 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 https://www.youtube.com/watch?v=_XW6Yu6VBQE "The CUDA Python Developer’s Toolbox" https://www.nvidia.com/en-us/on-demand/session/gtc25-S72448/ https://www.nvidia.com/en-us/on-demand/session/gtc25-S72448/ "Accelerated Python: The Community and Ecosystem" https://www.youtube.com/watch?v=6IcvKPfNXUw 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-activity-7328539659192401922-beWb/ 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 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.
- fulafel 1y agoThe 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.
- bsaul 1y agoMojo 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.
- pjmlp 1y agoTrue, however that goal is not yet available today, it doesn't even run on Windows natively. And for those that care, Julia is available today on different hardware brands, as there are other Python DSL JITs as well. I agree they will get there, now the question is will they get there fast enough to matter, versus what the mainstream market cares about.
- b33j0r 1y agoI’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 1y 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.
- Someone 1y agoFTA (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.
- bgwalter 1y agoNo, 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/ 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.
- justin66 1y ago> C++ is easier. I expect that opinion will not be universally agreed upon.
- sanderjd 1y agoThe 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.
- hogepodge 1y agoOne 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.
- usrbinbash 1y agohttps://en.wikipedia.org/wiki/Mojo_(programming_language) 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 1y agohttps://docs.modular.com/mojo/faq/#open-source 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.
- Simon_O_Rourke 1y agoMany thanks for the update on this particular aspect of it. That rules it out of any production deployment until 2026 so.
- diggan 1y ago> That rules it out of any production deployment until 2026 so. Has that stopped everyone before? Java, C#/.NET, Swift and probably more started out as closed-source languages/platforms, yet seemed to have been deployed to production environments before their eventual open-sourcing.
- pelcg 1y agoMany developers had no problem using .NET and C# in production despite them starting out as closed-source for years.
- usrbinbash 1y agoYes, and there is a reason for that: Both are deeply integrated in Microsofts ecosystem, and whether one likes that or not, that ecosystem is the dominant platform for desktop computing, especially in commercial settings. What would be comparable driver for Mojo?
- Scene_Cast2 1y agoThe 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 1y agoAFAIK, there is a zero-copy interface for objects like numpy array and torch tensors where you can do in-place manipulation in mojo.
- adsharma 1y agoI 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 1y agoMy 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 1y agoTranspilers in general tend to be significantly less well maintained and optimised than direct APIs
- adsharma 1y agoI'm not a disinterested observer. Py2many has had a mojo backend for a year now. https://github.com/py2many/py2many/tree/main/tests/expected https://github.com/py2many/py2many/tree/main/tests/expected
- melodyogonna 1y agoThe plan is to have a mechanical tool someday that can transpile Python code to Mojo
- b0a04gl 1y ago[dead]
- MHM5000 1y ago> truck of salt :)))
- mikebrave 1y agoI really want to use mojo/max for graphics and game programming, but they don't seem interested in going that route.