News for hackers. Stuff that matters.
Re:Why is Rust slightly slower than C? by freejulian85 on Wednesday September 11, 2019 @09:29PM (#20946765)
I didn’t realize it was possible to be so wrong.
Re:Why is Rust slightly slower than C? by dang on Wednesday September 11, 2019 @11:54PM (#20947790)
Ok, but please don't be rude or post shallow dismissals here. If you know more, it would be great to share some of what you know. Then we can all learn something. Alternatively, it's fine not to post even when someone else is wrong.

https://news.ycombinator.com/newsguidelines.html

Re:Why is Rust slightly slower than C? by monocasa on Wednesday September 11, 2019 @09:53PM (#20946959)
I love C, and have written tons of C++:

What the parent is saying is essentially right. C++'s compile time polymorphism and lamdas can allow faster than C given the right subset of language chosen. For instance std::sort regularly outperforms qsort(3).

Re:Why is Rust slightly slower than C? by otabdeveloper2 on Thursday September 12, 2019 @01:50AM (#20948419)
> given the right subset of language chosen

Yes, if by that you mean "idiomatic C++ as C++ programmers write it".

It's the inexperienced "C/C++" (no such thing, BTW) that are 'choosing subsets', and doing it wrong 90% of the time.

Re:Why is Rust slightly slower than C? by monocasa on Thursday September 12, 2019 @04:06PM (#20955848)
> It's the inexperienced "C/C++" (no such thing, BTW) that are 'choosing subsets'

That's blatantly not true. Strousup himself contributed to the joint strike fighter C++ coding standard which has things like "Allocation/deallocation from/to the free store (heap) shall not occur after initialization." which means that the STL is off the table for example.

Beyond that, there's pieces like RTTI/dynamic_cast that should be avoided for a lot of reasons, perf being one of them.

Re:Why is Rust slightly slower than C? by ncmncm on Friday September 13, 2019 @12:12AM (#20959112)
Most of the STL does no allocation. The containers allocate only at known places, permitted during initialization. They also know how to allocate from provided bespoke stores, which are permitted, in JSF code, even after initialization is done.

So, no, the STL is very much on the table, as in any competently constructed work product.

Re:Why is Rust slightly slower than C? by ncmncm on Thursday September 12, 2019 @02:04AM (#20948478)
There's no substitute for competence, in any language. Fear of the C++ compiler is not a great predictor of competence.