News for hackers. Stuff that matters.
Re:Clang Format Tanks Performance by devit on Wednesday November 20, 2019 @08:19AM (#21583623)
While Go and Elixir might indeed be slower, Rust is designed to generate optimal code and offer zero-cost abstractions like C and C++ and I would expect it to do so in this case.
Re:Clang Format Tanks Performance by pdimitar on Wednesday November 20, 2019 @08:54AM (#21583868)
That's what I keep hearing but here on HN periodically do pop up some benchmarks that show Rust being stomped.

But oh well, most benchmarks aren't pure or non-opinionated so there's that as well.

So far I like Rust quite a lot but -- as I said in another sibling comment -- its procedural style and syntax aren't stellar, in my eyes at least.

Re:Clang Format Tanks Performance by devit on Wednesday November 20, 2019 @09:22AM (#21584124)
Well, generally you can, approximately, given C/C++ code, produce Rust code that should give equivalent LLVM bitcode to the one produced by clang on the C/C++ code, so it should not be possible for Rust to routinely lose benchmarks to clang with a significant margin given enough effort in benchmark construction.
Re:Clang Format Tanks Performance by username90 on Wednesday November 20, 2019 @11:26AM (#21585276)
Only if you use unsafe Rust, otherwise you'd have to prove that safe Rust semantics are enough to describe the same operations used to squeeze out that performance in C/C++.
Re:Clang Format Tanks Performance by steveklabnik on Wednesday November 20, 2019 @12:49PM (#21586329)
It's more complicated than that. Compilers love restrictions, because that means they can optimize more aggressively. And there are features that Rust doesn't have that C++ does have that can make Rust faster; for example, because Rust doesn't have move constructors, moving is an incredibly cheap operation, whereas it can execute arbitrary code (including throwing an exception!) in C++.

There are also... I don't know how to frame this, social issues? Rust's guarantees often let you do some very aggressive things that you could write in C++, but wouldn't, because it's not maintainable. For example, if you must use reference counting, but don't need threads, Rust has a split between Rc<T> and Arc<T>. You can afford to not use the atomic version in Rust code because if you ever refactor later, you know the compiler will catch this for you, whereas you're just asking for latent, hard to track down bugs if you tried this in C++.

This goes both ways; there is some stuff that C++ is better at than Rust too. It's more complex than "unsafe Rust lets you do anything C++ can do directly and so if it's 100% unsafe in Rust it will be the same speed and if it's safe Rust it will be slower."

Re:Clang Format Tanks Performance by pdimitar on Wednesday November 20, 2019 @03:39PM (#21588235)
That's what I am falling in love with as I am learning Rust: both sensical and compiler-helping restrictions.

Rust can use less ways to do the same thing, I keep hearing from people, and I am hopeful it can be tackled in the future with clever deprecations or simply de facto libraries / ways of doing things.

Thanks for your hard work, it's much appreciated.

Re:Clang Format Tanks Performance by gameswithgo on Wednesday November 20, 2019 @09:11AM (#21584021)
since simd intrinsics got introduced there shouldn't be any reason for rust to get 'stomped'
Re:Clang Format Tanks Performance by pdimitar on Wednesday November 20, 2019 @09:19AM (#21584097)
Sorry, I don't mean to be demeaning. I am aware Rust's creators make huge strides and I am absolutely on their side. I already prefer Rust over a lot of languages, C and C++ included.

Just having some healthy skepticism, apologies if it reads like anything else.