Rust vs Mojo - the new LLVM language

Curious if some of you have some thoughts on the newly announced Mojo language:

Superset of Python - but like Rust has a borrow checker and is also built on the LLVM compiler. Compiled language - so you can distribute just the executable without the interpreter.

It is aimed at the tensorflow/pytorch machine learning domain - but looks like it might be useful for general systems programming.

Feels a bit like C vs C++ in that you can switch immediately - but eventually will want to migrate to the new classes (struct & fn vs class & def) to take advantage of the type system and faster execution.


By bringing together the best of dynamic languages and systems languages, we hope to provide a unified programming model that works across levels of abstraction, is friendly for novice programmers, and scales across many use cases from accelerators through to application programming and scripting.

Makes me think of this famous xkcd cartoon


I personally am quite vary of the Python ecosystem and the various languages and dialects that developed around its deficiencies when it comes to writing performance-critical programs. Especially in the whole scientific computing realm. I really enjoy another LLVM-based language that looks similar to Mojo to me: Julia. I find the language really refreshing and it does not carry along the cruft from 30 years of Python development with it. I'm not sure whether Mojo can be successful and accomplish its grand goals of a unified programming model spanning accelerators, system programming, application development and scripting. Or if it becomes the next Cython, which I'd argue is a rather niche language beyond a few scientific computing libraries.

1 Like

If you allow me to pick out one particular thing that makes me not like the language very much upfront: it looks like they've got their explicitness goals completely backwards. One of the examples in the demo looks something like this:

let x: Array<_> = make_array();
mutate_in_place(x); // mutate in place
pass_by_value(x^); // give away ownership

That is, passing by mutable reference is implicit, while passing by value must be explicitly annotated. That sounds like it contradicts 50 years of industry experience :sweat_smile: It is mutating that should be explicit, because that's what can lead to surprises.

In any case, I don't think it's a Rust competitor. It's explicitly oriented towards machine learning, so I'd pretty much consider it a DSL rather than a general-purpose systems programming language.


Julia is a great language - not general purpose, but arguably the one the data science community should have adopted instead of python...

Would also have loved to see Rust being used for machine learning - does have 'unofficial' bindings for pytorch & tensorflow, but I'm afraid the community is not coming.

Love python, but always saw it as mainly a scripting language replacing shell scripts, perl, etc.

Always been a weakness that you didn't have direct access to fundamental machine types (int, float) - which you do in Julia. A package manager came late to the language - and the "batteries included" means that the standard library is full of modules that are not best in class but never will go away.

Python's list type is actually implemented with arrays - always bothered me - lists and arrays are different. Intention was to make it easy to learn programming - but why start out that way.

Nevertheless, Chris Lattner is a great guy to have behind Mojo.


I think it's good to see borrow checking make its way to another language.

I don't see Mojo competing with Rust though, as Rust is, for better or for worse, very much a statically-typed language. Mojo, on the other hand, will always have to support a large dynamically-typed codebase in order to maintain compatibility with Python. This has important consequences for what kinds of projects will be well-suited to each language and also the kinds of programmers who will be attracted to them.

Amen. I mean Julia is 20 years younger and the community must first develop. I do think a new language fully focused on scientific computing with performance in mind should be preferred over trying to make semi-suitable languages fit that particular purpose. Especially given that with numerical computing, you now have to be able to support a ton of heterogeneous hardware and distributed resources. In a perfect world we'd all write Fortran, of course, but I stopped trying to convince the masses of my divine message.

Okay, then Mojo probably will gain some traction. Who can put LLVM, Clang, Swift, MLIR and XLA on their resume? :sweat_smile:


At minimum I expect it to have traction in the AI space as it addresses the "environmental" pain points they describe in their "why" document.

It's then a question of whether it gets used more widely beyond that.

I think the AI part is mainly to try to grab that community and quickly have a large user base.

Interestingly Swift - Chris Lattner's previous language - already had integration with python, C and tensorflow - but maybe it never took off in the way he envisaged. Here is an old video where he talks about that

If Mojo manages to become a Python superset and have a good ecosystem, then I think it will compete with Rust for some programmers. But it depends on witch kind of Rust programmer.

For example, here an article from Aembit: Why We Chose Rust

Sadly, this article could be summarized as follows: We don't like Rust and we would prefer to code in Go. But, if we have chosen Go, then we may need to rewrite the code in a more performant language later.

This kind of Rust programmer would prefer a language with a simpler learning curve that allows them to optimize the code later.

For this kind of programmer, I think that Mojo may compete with Rust in the future.

On the contrary, here is an article from Qdrant: Why Rust? - Qdrant

This kind of Rust programmer chooses Rust because it is a good language.

For them, I don't think that Mojo would match.

1 Like

Yeah, I think that's true, it does depend on the specific circumstances. I agree Mojo won't be attractive to people who are willing to put in the time to learn Rust and whose needs are well-served by the existing Rust ecosystem. But programmers who want to get started hacking quickly and who want libraries that Python is well-known for (especially in data science) may prefer Mojo.

The rationale and vision are as described here.

The Case for a Next-Generation AI Developer Platform

AI software today is monolithic and research quality, fractured into technology silos that follow the organization chart of the Big Tech companies who built it. It was created by researchers to do research, and the quick evolution of AI has left no time to pause and build it right. Instead we've just piled on more and more layers of complexity over time, resulting in an industry that is struggling to maintain and scale fragmented custom tool chains that differ between research and production, training and deployment, server and edge. AI systems have become a vast sea of incompatible technologies that only the largest and most sophisticated companies can brute force to achieve their goals.

A unified, extensible platform to superpower your AI

So it's not just offering a new language but attempting to streamline the entire AI ecosystem while allowing re-use and interoperability with it.

In that sense I don't see it as a competitor to Rust. They have different goals. Though I can easily see how scientific researchers doing numerical computing in general, not just in AI might grab Mojo to wrap and performance-boost whatever they are already doing without (traditionally) having to drop down to C/C++.

I still hope it'll succeed. Because lifetime tracking is one of the hardest tasks in any language and now, when Rust have shown that it's actually possible to put in the language… we need more such languages.

Because stretching Rust to cover both low-level programming and high-level scripting would just turn it into a monster not suitable for either.