is rust faster than mojo
In what context?
in ray tracing or even in ai field as they are saying its 35000 times faster than python is rust 35000 faster than python as mojo would some day become general public languge due its performance and low level as well as high level feauteres as mojo is like python which is easy to learn
The 35000 is a number that shouldn’t be misinterpreted. It’s an “up to 35000 times faster” kind of claim, i.e. the highest number of speedup that was obtainable, in a problem that Python is not really good at (especially involving tight loops), and where the best Mojo-based solution did absolutely also involve some hand-optimizations, like explicit/manual use of parallelization and/or SIMD.
Now, then point, compared to Python, as far as I understand, is that in Python, such things are simply not possible; you cannot go lower-level in Python beyond some point, no matter how well you hand-write your Python code, there’s a limit due to the dynamic properties of the language, as well as the limited support for multi-threading, etc… whereas Mojo makes it possible to avoid this overhead, achieve – essentially – as fast implementations as possible, and if I understand it correctly, they also spend some effort in making writing such code (e.g. involving parallelization, as mentioned before) relatively straightforward to write.
In case you haven’t seen it yet, this short video presentation contains some code examples that make it more clear what these speedups look like, what kind of effort is or isn’t involved, and such.
Now, comparing to Rust: Rust too is a language that doesn’t limit your abilities to hand-write code that runs as fast as you want. This means, in principle, it’s possible to achieve the same kind of speedup over Python as Mojo does.
I haven’t looked enough into Mojo to know what their memory safety story is, i.e. whether they have some sort of “unsafe” mode, too; if they don’t that might be an indication that Rust could still have an advantage. In either case, the speed of code does largely depend not only on the programming language, but also on the algorithm and implementation the programmer writes; the amount of effort spent on optimizing it further; it’s not the case that you just flip a switch from Python to Mojo and – boom – your code is thousands of times faster without any effort of improving it yourself (using the tools that Mojo offers over Python).
Edit: This page is quite insightful (and the FAQ) appear also useful to look at. Sounds like they do want to (but haven’t yet got to) have a life-time system that’s somewhat Rust-style; also sounds like they do have a form of allowing unsafe code. Notably, Mojo right now is almost inaccessible; you can sign up to an online-only preview, but there’s no actual way to verify any of the speedups yet, as you cannot install Mojo. Also it’s not open-source, and it’s not clear how long it would take until it does become open-source, if ever.
So right now, the “Rust vs. Mojo” comparison will mostly have to be postponed; despite lot’s of news and articles about it, Mojo doesn’t really fully “exist” yet.
You can of course sign up and try the notebooks they released to get an impression.
I don't think mojo is going to be faster than rust or C for simple jobs running on a single CPU. Is probably going to be equally fast though.
If you listen to Chris Lattner he talks alot about multi core, accelerators etc - Welcome to the jungle
There is no deep learning without accelerators - and supporting those architectures is I guess what mojo might do better.
Here is clip where Lattner talks about that.
Also heard him being somewhat disillusioned with LLVM - gotten too complex.
I absolutely love Rust. I love its developer tooling ecosystem, the community of extraordinarily helpful individuals and organizations that go above and beyond to help when I have a question, the zero-cost abstractions provided by a strong type system, the low-level fine-grained control over program behaviour, etc.
However, Rust is simply not always the best choice. That is perfectly acceptable and even desirable, IMHO. If Rust were the best choice for every use-case, then Rust would not be a very good language. I know that Rust is, at this time, advertised as a general purpose language (and it absolutely is). With all of that said, I suggest that you (and I mean the proverbial you) worry about what actually matters to you. If pure speed is the only that you care about, then sure, you can make your decision based on that fact. Just please be aware that language choice does come with trade-offs.
To give some examples to concretize what I am saying and where Rust is my first choice:
- Safety and/or security-critical platform-specific software
- Memory-safe code that must be reliable; a critical OS component should not enter a preventable unrecoverable failure state
- Using Rust's powerful type system to encode complex invariants and provide enforceable contracts that allow writing safe code that operates on data crossing the FFI boundary
Sometimes, though, Rust is not the best choice. If you have the luxury of picking between Rust and some other language and the other language fits the use-case better, then I would advise using that other language. Your use-case may not require the guarantees that Rust provides, you may want/need convenience (i.e. a higher level language, or one with features that better model your requirements), etc. If that is the case, there is nothing wrong with choosing that other language.
I see countless threads and topics here, Discord, Reddit, or some blog that compares "Rust to ". The reality is unfortunately not that simple.I think that if, for example,
mojo makes more sense to you in this case, then you should use it. Speed is one metric, but it is not the only metric. There are trade-offs to every decision you make, because that is how the world works.
I am, in many ways, oversimplifying the issue, but I stand by my opinion and advice. Use the language that makes the most sense to you after carefully considering the trade-offs that each contains. It is a valuable skill to understand the inherent trade-offs that exist when choosing the primary language for your project.
Hopefully this helps at least a little to put things into perspective.
Best of luck I hope that you find the solution you need!
Currently Mojo does not run and build code for any machine I have. As such Rust is infinitely faster than Mojo.
On the other hand my limited understanding is that Mojo can do a good job of shunting huge parallel computations out the GPU's or whatever accelerators. That would be a great speed up over regular general purpose CPU usage for things like neural networks.
If you look at the machine code produced by the likes of Rust, C, C++, Pascal, etc it seems certain than no language could do much better than they do on regular processors. Certainly nothing like 35000 times faster.
I will look at Mojo again when it compiles code for the machines I use.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.