Julia vs Rust ML which is the best path?

Which is the best path, comparing Julia and Rust based ML for learning as well as for writing production level projects.
Given the adoption of Rust in AOSP, Firefox and Brave do you think Rust-ML can compete with Julia?

originally asked at machine learning - Julia vs Rust ML which is the best path? - Stack Overflow
posted here as advised by logankilpatrick

1 Like

I’m not a rust user, and I am an enthusiastic julia user so my answer may be quite biased. But honestly, I don’t see the benefit to rust for ML purposes. It doesn’t have much of a numerical computing community and it doesn’t seem to have many language features that make it all that great for numerical computing.

E.g. we saw the big effort that went into things like Swift for Tensorflow, only for that project to eventually be abandoned and from what I understand, Swift is a more friendly language for numerical computing than Rust (but still a strange choice)

I think the reality is that for most purposes, Julia and Rust just don’t have a lot of overlap in their competencies. A lot of the time, the only reason to mention them in the same sentence is that they’re both interesting new languages.

Julia is a remarkably powerful language that really excels at things like numerical technical computing, but it has some weaknesses. E.g. if you absolutely need small, statically compiled binaries, I wouldn’t seriously recommend julia yet (though I’ll mention that most people drastically over-estimate how necessary small static binaries are for them)

13 Likes

The two languages are definitely optimized for very different things.

Julia is optimized for ease of use, composability, fast numerical work on both CPUs and GPUs, and is JAOT compiled. Rust is optimized for safety, systems engineering, etc., and is statically compiled

For machine learning or scientific computing in general (especially anything involving linear algebra or differential equations), this is going to be much easier in Julia. For generic “production” work on the other hand Rust will generally have a significant edge.

Though, as Mason says, statically compiled binaries are less necessary than one might think, especially for many ML-type things.

3 Likes

Julia is better for machine learning; it’s really on the cutting edge. It’s also faster to write.

On the other hand, Julia is worse for production. For example, it doesn’t have a great deployment story yet (though one is in the works with StaticCompiler); not nearly as many properties can be statically checked by the compiler; it doesn’t have very sophisticated support for interfaces (which may matter especially for a large team); and so on.

3 Likes

Hypothetical comparisons are nebulous and difficult to pin down, so let me provide a more tangible one. To my knowledge, a great deal more academic and industry users make use of Julia than Rust for ML. Note that by “ML” I mean the training and analysis portions of your usual ML pipeline and not areas like ETL, preprocessing or deployment/inference. This balance may change in the future, but for now one language is certainly more battle-tested for ML than the other.

Careful, if we make more more natural inference step from here, we’ll end up recommending Python :wink:

4 Likes

I’ve used Rust for work (not ML or data science), and I quite liked it. Julia is a much better choice for getting into ML, for the reasons others have elaborated on. The benefits to Rust for ML are not too different for the benefits of C++ or C, namely, deployment and inference, or as was said, small, statically compiled binaries, like TensorFlow Lite. To me this is Julia’s biggest weakness, but I expect it to get fixed in time.

1 Like

I’m not an authority on ML, but I think I’m a proficient Julia user and decent Rust user, so take this with a grain of salt:

TL;DR: Rust had too much on its plate and couldn’t focus in linear algebra foundations - Julia could. There’s capable people on both sides but Julia seems more promising today, albeit nothing is certain.

I think Julia will win out because of the speed of development and mindshare capture, but it depends.

Other people have already talked about the Julia pros - I will mention Rust applications.

There’s the Are we learning yet site, which talks what specific needs in the Rust system aren’t met yet. You should research there and draw your own conclusions about what its promise and current state is.

As interesting asides, there’s some basic statistical applications which could count as ML and are great to do in Rust because of the ease of deployment, see for example Taking ML to production in Rust with a 25x speedup. I don’t think that link says anything more than “Python is not a good tool for this”, which we already know, but it will be very interesting to see how these small deployments can be combined with web assembly for blazing fast performance and minimal overhead.

It’s not that Julia can’t have that synergy, it’s that it hasn’t been a focus of the community yet.

On the flip side, the ndarray crate in Rust is what offers the most complete linear algebra experience in Rust land. To be very blunt, it doesn’t look like math, and I don’t see armies of data scientists who are used to SciKitLearn or TensorFlow flock to learn Rust for a couple of months to get that sort of speedup.

Furthermore, ndarray does not have support yet for:

  • sparse matrices
  • block matrices
  • diagonal matrices
  • and many other types of structured matrices

If you’re a Julia lover, don’t read the next spoiler:

Haunting Rust internals detail They don't even have matrices in the stdlib. Just vectors :frowning:

which I think is just a showstopper for many, let alone leveraging AD and GPUs atop that. Composing those features in Julia is just our bread and butter; in Rust that’s a hefty engineering effort.

That said, this was the best introduction tutorial I could find and found it quite challenging still just because of Rust - YMMV.

But let’s be clear - no one can predict the future, and I’ll be glad to be corrected. There’s amazing DL applications happening with Rust for sure.


Conclusion:

Time will tell!
Maybe small statistical apps deployed with web assembly will rule the day. Maybe uber composable Julia pipelines will. Maybe neither, or both in different niches. I’m open to learning from them and seeing what the future holds.

8 Likes

I don’t see why that would be a showstopper. It’s not like I’m going to use Julia without installing anything. Julia could move n-dimensional arrays into a package and I’d barely notice. Tbh the whole idea of a “standard library” seems like a throwback to before package distribution got good.

If matrices are in the stdlib or not is a red herring - it’s the fact that they couldn’t focus on developing linear algebra as a first class ecosystem because they had other priorities.

6 Likes