r/ProgrammingLanguages • u/yorickpeterse Inko • 14d ago
Blog post Mojo🔥 is now open source!
https://www.modular.com/blog/mojo-open-source19
u/benreynwar 14d ago
Compiler overview is at https://github.com/modular/modular/blob/main/KGEN/docs/MojoCompilerWalkthrough.md
22
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.
3
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.Â
7
u/IAMPowaaaaa 14d ago
I wonder if they implemented the Group Borrowing thing
13
u/verdagon Vale 14d ago
Alas, group borrowing was taken off the roadmap. Ironically, Carbon is using group borrowing though.
1
u/baldierot 13d ago
do you happen to have a guess as to where mojo's safety model is heading? or is it still rather nebulous?
5
u/baldierot 14d ago
well, this went rather quiet, as expected. gpu programming is not very popular. hope the systems programming part fleshes out and stabilizes in a year.
14
u/bgs11235 14d ago
let's see the commit number, 50K Commits + 400+ contributors... Gah damn.... This project might be big. Deffinetly interesting. I look forward to porting a lot of python stuff too mojo.
6
3
u/Meistermagier 13d ago
Is it though? Or do they still have half of their shit packaged away as proprietaryÂ
2
6
u/verdagon Vale 14d ago
I worked in the Mojo codebase for over a year, ask me anything =)
4
u/Infamous_Sorbet4021 13d ago
What are your thoughts on the negative reception Mojo has faced within the programming community, and how should the project move forward?
3
u/verdagon Vale 13d ago
My opinions on that might be a bit too spicy to speak aloud, because I was so close to it. Sorry! XD
3
u/njnrj 14d ago
Hey, thanks in advance. How doest it eliminate the GC? the borrow checker is not widely discussed as much as in the case of Rust. How does it compare to it?Â
9
u/verdagon Vale 14d ago
One can think of it like Rust's borrow checker with some ergonomic improvements, it's built on shared-xor-mutable just like Rust is.
1
1
u/AssOverflow12 13d ago
Is it possible to switch an existing Python backend with type annotations to this? What would I gain? Asking for a backend project.
3
u/verdagon Vale 13d ago
Depends what you mean by switched. If you want to call into Mojo code from Python, or Python to Mojo, that's something they're working on ~currently and some of that interop already works. If you want to migrate your typed Python code to Mojo, alas, that won't work any time soon.
2
u/AssOverflow12 12d ago
I meant the latter, meaning taking an existing Python codebase and instead of the standard Python toolchain, build it with Mojo. Similarly to how you could with JavaScript and TypeScript. Thank you for clearing that up!
1
1
1
u/lisp_turns_me_on 3d ago
Do you foresee working on vale.dev in future? Or is it abandoned now? I really loved the posts there.
6
u/Lime_Dragonfruit4244 14d ago
A very small amount of people touch gpu or general heterogeneous programming and even then for ml stuff you mostly express your models in jax, pytorch or related dsl or just use an embedded dsl like triton for writing escape hatches for when the compiler doesn't give you enough performance or go down to cuda or ptx directly. So i am not sure what does mojo as a product brings to the table. Its cool and all as a research project but I am having a hard time believing anyone would use it for real work.
18
u/Tok-A-Mak 14d ago
Not using cuda is the point.
-1
u/Lime_Dragonfruit4244 14d ago
You already get that from python based DSLs (triton, helion, etc)no need to bother with anything else. And for absolute performance touching cuda is inevitable. Might as well spend more time with cuda than to add more complexity to the ml stack. There is already a battle tested mlir based stack, jax + openxla.
3
u/mister_drgn 13d ago
The point is that touching cuda should not be necessary for performance. Also, if people move from cuda to mojo, they won’t be locked in to using nvidia gpus. That’s the real goal I think.
-3
u/FruitdealerF 14d ago
This project allows LLM contributions, why is it allowed to be posted in this subreddit?
4
u/yorickpeterse Inko 14d ago
You keep complaining about the LLM policy. If you don't like it, feel free to go somewhere else but your complaints are getting tiring and don't add any value.
As for why Mojo is allowed here: because it's been a pretty hot topic in recent years, with people of significant relevance/experience behind it, and to my knowledge much of it still being written by humans (though there indeed are signs of LLM usage).
In other words: because it's not some vibe coded slop project by somebody that had Claude Code do all the work, unlike 99.99% of other LLM built projects.
14
u/protestor 14d ago edited 14d ago
What about the zero tolerance policy though? It's zero, except when it isn't? You said things like
Once a project is tainted by LLM code it's impossible to determine how far the rot spreads throughout the project.
And
"No LLM generated code" means "No LLM generated code", not "A little LLM generated code is allowed".
But somehow you think this doesn't apply to Mojo because "to your knowledge" much of it is still written by humans (even though once a project is tainted by LLM code it's impossible to determine how far the rot spreads throughout the project)
So what is the actual policy?
31
u/qurious-crow 14d ago edited 14d ago
With all due respect, their frustration is understandable. The current policy, as stated, is totally unclear with regards to what constitutes acceptable/responsible use of LLMs, and seems to be applied inconsistently and arbitrarily.
https://www.reddit.com/r/ProgrammingLanguages/comments/1thd6fs/comment/omnrd85/
The zero tolerance policy exists because once a project is tainted by LLM code it's impossible to determine how far the rot spreads throughout the project.
In this case you're linking to a project that very clearly states it did use an LLM, even if only a little. "No LLM generated code" means "No LLM generated code", not "A little LLM generated code is allowed".
Mojo has had LLM-assisted contributions. It's documented in their pull requests. Under the above interpretation of the LLM policy, Mojo should not be allowed here. That comment left zero room for argument.
The problem is not the LLM policy per se, but that it sometimes means "this clearly LLM-assisted project is important and I trust that the people behind it use LLMs responsibly, so it does not count as vibe-coded/AI slop", but another time it means "no LLM means no LLM; if 0.01% of the codebase in a single well-delineated component was written with LLM assistance, and the author has disclosed this openly, that still disqualifies all of it".
16
u/ScottBurson 14d ago
I don't even object to the mods being permitted discretion to make such decisions, as long as the policy makes it clear that they may.
18
u/initial-algebra 14d ago
Yes, this is a clear double standard. Plus, Mojo itself is extremely AI-jerky, even if it's mostly engineered by humans. I understand that this doesn't actually disqualify it or similar projects like Verse from discussion here, but it is strange to bend the rules for it specifically. Especially since this post is basically just an advertisement with zero substance.
12
u/ScottBurson 14d ago
Gotta say, if 77 LLM-generated lines out of tens of thousands is too many, parent has a point.
I realize that being a mod is work — often thankless — and you sometimes have to make judgment calls. And I certainly don't want to see the sub overrun with slop. But a literally zero-tolerance policy seems too stringent to me, for exactly the kind of reasons you give here to justify allowing this Mojo post.
11
u/yorickpeterse Inko 14d ago
Gotta say, if 77 LLM-generated lines out of tens of thousands is too many, parent has a point.
Parent doesn't have a point, because it's not about the number of lines but rather because the poster outright lied (in the comment requested by AutoModerator) about their LLM usage when the rules are pretty darn clear on the matter.
Had the person sent a message saying something like "I used an LLM to write these 77 lines because after spending 3 weeks on it I just couldn't figure it out, here's what I did [...]" then it may have been a different story.
That wasn't the case though: the OP slopped their way through the project, deliberately ignored both the rules and tried to game the approval process. It takes a special kind of arrogance to do so and we have no interest in entertaining it.
10
u/newstorkcity 14d ago
To be fair, a post gets autoremoved unless they include the exact phrase from automod, with no room for explaining nuance. So if you have a project that is totally within the rules of the subreddit AI policy (not slop, but some AI use), then obviously people are going to just copy the canned response and not think anything of it. Whether they are right or wrong to do so is debatable, but it's inevitable that many non-slop projects will get rejected this way.
When you initially rolled out this policy, you said:
The comment must use an exact phrase (mostly as a litmus test to see if the user can actually follow instructions)
Which is great and all, but now following instructions is "lying" because the canned response and the actual subreddit rules don't line up. Especially when "did not use an LLM as part of the development process" is almost certainly false since it is almost unavoidable even if you actively try to avoid it, leaving everyone to guess on where the actual limits are (inline code completion? consulting an LLM in a chat? generating a small utility function?)
9
u/ScottBurson 14d ago
Here's the comment you're referring to:
Per AutoModerator's request I hereby confirm that this project did not use an LLM as part of the development process.
Okay, they shouldn't have phrased it so categorically, but I can't agree that it's an "outright lie". De minimis non curat lex. They made a judgment call themselves that their LLM usage deserved a de minimis exemption. Maybe they should have come clean and let you make that call, okay, but "outright lie" is, in my view, overstating their transgression. We are talking about less than 1% of the code.
Also, 77 lines out of tens of thousands doesn't seem fairly described to me as "slopp[ing] their way through the project".
Still, I understand your anger. It's the mods' responsibility to protect the community. Moderating is a hard enough job in any case — anyone making it harder is going to find themselves unwelcome.
Perhaps the rule should say something like: if you believe your LLM use deserves a de minimis exemption, you may request one, which the mods have sole discretion whether to grant.
6
u/FruitdealerF 14d ago
If there was somewhere else to go I would, but it's not like there are dozens of large communities on building programming languages. You removed this post for having one 77 line component which was only a small part of the standard library. You keep saying that the rules are stated clearly but you're willing to change them arbitrarily when it fits you.
And yeah I get that I'm annoying, and I'll stop complaining after this message since I don't see it making a difference and I don't want to get banned. But just being totally honest and human... I feel super bad about this whole situation. I've been working on my project for years, waiting for a good time to share it with this community, and now that it's finally nearing a state where I want to show it to the world for feedback; there is one person with an irrational anti LLM bias imposing a rule that says I can't. It feels extra unfair that human made slop is totally allowed and uncontested.
Again I'll get of your case shut up about it.
4
u/farsightfallen 13d ago
yikes, as someone that gave the benefit of the doubt to the mods by default, I stand corrected.
I get the argument of an ai-filter for slop, but that's extreme. If we're at the point whre we're putting a single line of ai generated code i nteh same category as entire vibe coded projects, then we've lost the plot.
-6
u/yorickpeterse Inko 14d ago
You keep saying that the rules are stated clearly but you're willing to change them arbitrarily when it fits you.
There have been what, two cases where we did allow something that made use of an LLM? Let's not pretend there's some sort of continued pattern of moderators abusing their power, because that just isn't the case.
I feel super bad about this whole situation. [...]
If you want people to appreciate your work, you have to do the actual work yourself, and prompting an LLM to do things for you is not that. There's nothing unfair about a community enforcing a set of rules related to that.
there is one person with an irrational anti LLM bias imposing a rule that says I can't.
It's not one person, it's the entire subreddit apart from a few people that start whinging just because they're no longer allowed to share their AI slop. You make it sound like there's some personal vendetta against you when this isn't the case.
It feels extra unfair that human made slop is totally allowed and uncontested.
It's not and we remove plenty of human produced slop. Just because you don't like people sharing their implementation of Crafting Interpreters (or something similar) doesn't make it slop, nor does it mean this entire community has to cater towards your needs.
1
u/Rechenplaner 14d ago
Does Mojo have the potential to be useful in the backend, for instance, as a faster alternative to TypeScript; for people who aren't keen on Go or Rust? Or is Mojo only useful for GPU/AI?
7
u/TheAgaveFairy 14d ago
Networking, async, and other pertinent language features are still in the works. There is a talk about the future of the language going on right now at their conference.
6
u/biskitpagla 13d ago
Just use Go. You're practically begging for more problems down the line. We don't even know if Mojo would succeed in its own niche, let alone as a general purpose language.Â
0
u/lppedd 12d ago
Or use TypeScript. It's just an amazingly expressive language and the new compiler is fast.
1
u/Super_Delivery3405 3d ago
It's just a transpiler to JS, you're still stuck with node or bun that's actually running the code.
44
u/benreynwar 14d ago
It seems like there is still lots of stuff that is not open-sourced that you need to compile to GPU. Am I missing something?