5 ms·
whats the benefit of rust over julia or C for computation?
by dlphn___xyz 7y ago
whats the benefit of rust over julia or C for computation?
- jdc 7y agofrom TFA: >> We chose Rust because: >> It has a very minimal runtime (essentially just bounds checks on arrays) and is easy to embed into other languages such as Java and Python >> It contains functional programming paradigms such as pattern matching that make writing code such as pattern matching compiler optimizations easier >> It has a great community and high quality packages (called “crates” in Rust) that made developing our system easier.
- vmchale 7y agoDid they have to write the runtime in the same language? They could've used an ML with GC and it would've been better (for a compiler). It doesn't really have any functional programming paradigms. Pattern matching is present in imperative languages like past versions of ATS
- fluffything 7y ago> Did they have to write the runtime in the same language? No, they originally wrote the runtime in C++, but ended up re-implementing it in Rust because the C++ runtime had too many bugs. > They could've used an ML with GC and it would've been better (for a compiler). They originally wrote the compiler in Scala with the JVM GC, and they said it was much slower and much harder to embed. > It doesn't really have any functional programming paradigms. Pattern matching is present in imperative languages like past versions of ATS When choosing a language for such a project, there are many engineering trade-offs that must be evaluated. The Weld project has dozens of developers that need onboarding, documentation, examples, tooling, etc. Rust has a lower barrier of entry than ATS. One of the main things Weld does is interfacing with LLVM: this is one of the main things the Rust compiler does and Rust has great libraries for this. Another thing Weld does is interfacing with many dynamic languages (Python, R, etc.). Rust does not just have "C FFI". It also has _a lot_ of great tooling for automatically generating and validating all the boilerplate automatically. Finally, performance and code size of Weld is one of the main advantages over the alternatives. Rust generates reasonable code with LLVM, ATS has its own code machine code generator, which while reasonable, isn't as good. Finally, it is hard to find people who enjoy writing ATS code. They exist, but are not many. Even when you do find them, they often don't like collaborating with people (I only know one ATS user, vmchale on github, and they don't really like interacting with others). OTOH it is trivial to find lots of people that enjoy writing Rust with others. It doesn't matter if this is due to technical reasons, marketing, or hype, but it's a fact that you have to consider if you want a project to grow fast.
- TurboHaskal 7y agoDid you realise you are responding to the same Github user you're mentioning?
- rch 7y agoI like the memory safety, concurrency, and zero-based indices.
- giancarlostoro 7y agoRust performance is pretty much in terms of C/C++ performance but promises stability in regards to memory management due to the borrow checker. Rust is very impressive on its own. If you havent taken the time to research Rust because "its yet another language" you really ought to honestly.
- agumonkey 7y agoin this particular case it's to be a drop in replacement for the python datascientist, the rest is irrelevant I believe
- asjw 7y agoNone On the other side you'll gain all the instability that a young language suffer from, like in 6 months it could be impossible to compile this code and you'll need to refactor it It is also heavily used only at Mozilla , which is not a strong guarantee of longevity
- onei 7y agoThe Rust developers are working hard to ensure that no breaking changes ever appear in the language. As such old code would always be compilable, even if there's better ways to do it with modern features. Rust learns the lessons that older languages taught us. Why would you think they'd fall into such an obvious pitfall given how long they took to get to v1?
- jcranmer 7y agoRust guarantees stability on any feature in the stable release of the compiler. And anything in the standard library will remain in there in perpetuity, even if deprecated.
- shpongled 7y agoNot to sound like a member of the Rust evangelism strike force, but after using Rust for a couple years, I don't have any desire to go back to C - sum types alone are worth the switch to me, not to mention iterators, concurrency story, etc.
- shaklee3 7y agoC++ has sum types as of several years ago with std::variant.
- codr7 7y agoThe way Python has macros, sure :) You would have to keep everything in variants, or wrap/unwrap manually all over the place to get similar functionality. And C has tagged unions.
- shaklee3 7y agoCan you elaborate more? What do other languages have over std::variant/visit?
- atroche 7y agoPattern matching syntax (eg in Rust) makes a big difference.
- fluffything 7y agoThat would be like explaining C++ Concepts to an assembly programmer from the 60s that had never used a "function" as a way of abstracting code. If you really want to know, spend one afternoon learning any programming language with built in support for that (Rust, Ocaml, Haskell, ...). ADTs is one of the first things one learns. In Rust, the features you'd need to learn are enums, patterns, and pattern matching. But be warned that using C++ variant and std::visit will feel like you are being forced to only write C instead of C++ for the rest of your life, knowing that life could be much better. Once you learn this, there is no way to un-learn it.
- noobermin 7y agohttps://www.jwz.org/doc/cadt.html https://www.jwz.org/doc/cadt.html Not quite Julia, but for C/Fortran particularly for computational uses, if your issue is multiple array scans, it might be time to look at rolling it yourself and then calling your algo from python.
- mkl 7y agoThe computation here is actually not done in Rust. The Rust code is performing stages of compilation of the original source code, into an intermediate representation that LLVM finishes compiling. The fully compiled code is what does the computation.
- vmchale 7y agoThis is different from Julia. I don't really know why you'd write a project of this sort in C.