Hacker News new | ask | show | jobs
by kbarros 484 days ago
Julia is my tool of choice for writing numerical code where performance is critical. I work in computational physics, and have found Julia and its ecosystem to be far nicer than Rust in this space.

It's true that accidental dynamic behaviors are a real concern and can be a performance killer. Fortunately, the language has nice tooling. In VSCode, I often use the visual profiling tool `@profview` to get a flame graph. Anything dynamic gets highlighted in red, and is quick to diagnose. There also exist nice static analysis packages like JET.jl. During development, one can use `report_opt` to statically rule out accidental dynamical behaviors. Such checks can also be incorporated into a project's unit tests. In practice, it's not much of an issue for me anymore. But to be fair, there is a big learning curve for new Julia users. See, e.g., https://docs.julialang.org/en/v1/manual/performance-tips/

1 comments

Those tools didn’t actually exist the year or so I was writing Julia professionally (and that was only 3 years ago) so it’s nice to see the language coming along.

At the same time, I would expect the Rust ecosystem to overtake Julia’s in that domain in the next couple of years. Polars is already nicer than pandas, I’ve seen a some promising work on numpy-style tensor libraries, and I’m pretty impressed by the progress with getting enzyme integrated into Rust (I could never make it work with Julia). Here’s a nice example repo I saw recently:

https://github.com/ChemAI-Lab/molpipx/

Not the person you’re respond to, but Rust is never going to have a REPL and is likely to never compile very quickly. For a lot of numerical and scientific use cases that’s a fundamentally restraining factor. WRT performance, you’re ofc correct but that’s not always as paramount as it may seem if you need to tweak the data dozens or hundreds or thousands of time. In that case, having to wait more than say 5 seconds or so is prohibitively annoying.

I think something in between Zig and Rust will emerge someday as a sort of optimal compromise between compile speed, safety, and programmability wrt memory and performance tradeoffs.

Agreed. Julia's combination of REPL + JIT + Revise.jl can feel like magic. The compiler automatically detects changes to your source code and provides hot-code reloading of fully optimized machine code, in the blink of an eye!

Also, it's worth emphasizing that the user experience of Julia has been improving greatly, even in just the last 3 years. Julia 1.9 introduced caching of native code [1], and now at Julia 1.11 the time-to-first-plot in a new Julia process is typically less than a second.

Having said all this, Rust is an absolutely fantastic language too, and might be preferred for large-scale software development efforts where static analysis is prioritized over an interactive development workflow.

[1] https://julialang.org/blog/2023/04/julia-1.9-highlights/#cac...

There is a rust repl by evcxr

There was also some other if I remember correctly I saw it in the comments of https://youtu.be/eRHlFkomZJg, but now I don't see it , I think it was evcxr only.

It is really easy to write python bindings for Rust, which is probably the easiest way to “consume” a high-performance library (e.g. a physics simulator, data-frames, graphing, a type-checker, etc).
Right, but Julia is just not terribly well-suited for large scale software development, which is why I’d rather use Rust.
> Julia is just not terribly well-suited for large scale software development

Why not and how so?

That isn't why it was designed for anyway, rather scientific computing.
Another tool in this regard is https://github.com/JuliaLang/AllocCheck.jl, "a Julia package that statically checks if a function call may allocate by analyzing the generated LLVM IR of it and its callees using LLVM.jl and GPUCompiler.jl"