News for hackers. Stuff that matters.
Re:Getting Past C by lacampbell on Tuesday January 03, 2017 @05:30PM (#13313807)
I just keep hearing about how rust handles safe bounds checked arrays with (and I quote) "Zero-cost abstractions", which to me implied it would be faster than C, since C pays some performance penalty by branching.

Hope you feel better soon.

Re:Getting Past C by wmf on Tuesday January 03, 2017 @05:35PM (#13313842)
"Zero-cost abstraction" really means zero additional cost beyond what is required. So Rust still pays a cost for bounds checking, but it's the same cost as if you optimally hand-coded the bounds check in C.
Re:Getting Past C by pekk on Tuesday January 03, 2017 @11:28PM (#13315681)
Adding the cost of bounds checking is not actually "zero cost" relative to a C default of not bounds checking. There's really no reason to speak in this misleading way except marketing.

Of course, bounds checking is worth paying a cost! As are many other common foot-guns like remembering to free memory. Which starts to raise the issue of when it would actually be necessary to reach for Rust instead of (arbitrary example) Java. Because a language with enforced bounds checking is not really the same kind of thing as C, and we've already had languages that are safer than C for decades.

Re:Getting Past C by Manishearth on Tuesday January 03, 2017 @06:23PM (#13314246)
"Zero cost abstraction" means that the abstraction doesn't impose an additional cost. It is the same cost of branching that C will have, modulo optimizations.

(Languages with dependent types can help move bounds checks to compile time, but Rust does not have those)

Re:Getting Past C by staticassertion on Tuesday January 03, 2017 @05:35PM (#13313847)
Ah, I see. For what it's worth C will perform similar optimizations to Rust, which is why I expect similar performance. And thank you.