Blog post: Rust vs Julia in scientific computing

Just wanted to add a few points to the post by @jakobnissen, which already contains most of what I would want to say…

People don’t decide to use C/C++ just for performance, but also for a better project scalability and elimination of many classes of bugs at compile time.

See:
image

https://arxiv.org/pdf/1901.10220.pdf&#:~:text=RQ1%20“Some%20languages%20have%20a,were%20associated%20with%20more%20bugs.

C/C++ just up with Python and a bunch of other dynamic languages for bugs per commit… From that statistic, it would be pretty weird to move from e.g. Python to C/C++ to “eliminate bugs”.
Besides that paper, this matches my experience with writing in static languages and I’ve seen lots of other articles/papers confirm this (I’ve written the most horrible bugs of my career certainly in C++).

This doesn’t defeat the argument, that static languages can be nice to avoid certain categories of bugs, but there are clearly way more factors to bug free code, than having a static checker which usually comes with big trade offs…

E.g. I’d much rather have HTTP.jl written in Rust, since there are so many corner cases that can happen at runtime, which are really fatal for serving a website, that it would be worth it to deal with Rust.
But e.g. writing a package like Makie.jl is pretty impossible in Rust, and I don’t think I would profit a lot from the static checker.

As mentioned above, well optimized Julia code can get close to the performance of Rust, but it will never reach its performance.

That’s pretty much like saying electric cars are faster than combustion cars. Of course there are situations where having no GC means you end up faster, but there are also lots of problems, that are more efficiently solved by having a GC or simply have the same performance ceiling.
Also, Julia is a language that allows you to opt out the GC much better than most other GC languages, so it seems especially untrue for Julia. Back in the days, I did lots of benchmarking of Julia against C/C++, and it was almost always possible to reach the same performance as heavily optimized C code, so I’m pretty optimistic it’s the same for Rust in most situations.

On the other hand, if you want the highest performance in Julia, you have to write a for loop.

Julia also has no cost abstractions as a selling point… I haven’t benchmarked Rust against Julia a lot, but I’d be surprised to see large differences between Julia’s iterators and Rusts… Maybe you run into a performance bugs in some specific implementation, or was this just an assumption without ever benchmarking it?

25 Likes