News for hackers. Stuff that matters.
Re:Rust 1.63 by int_19h on Thursday August 11, 2022 @07:17PM (#32433029)
C++ has had std::vector::at() - which checks for out-of-bounds indices - since C++98. The reason why it's not used all that much in practice is because indexing is relatively rare - most of the time, you just iterate over collections, or otherwise use iterators rather than raw indices. And there's no ability to opt into bounds checking for C++ iterators in the standard - implementations usually provide some kind of checked iterators for debug builds, but performance is such that you'd never want that enabled for release.
Re:Rust 1.63 by tialaramex on Friday August 12, 2022 @06:33AM (#32436584)
> indexing is relatively rare

This is also true in Rust for the same reason, arguably more true since Rust's built-in array type knows how big it is - but the observation in both languages programmers who want indexing write v[i] because that's the natural way to express what you meant, what's different isn't the frequency of need, only the language defaults.

> performance is such that you'd never want that enabled for release.

Let's make sure it's correct before we start worrying about performance

https://twitter.com/magdraws/status/1551612747569299458

Re:Rust 1.63 by pjmlp on Friday August 12, 2022 @02:19AM (#32435203)
I always keep them enabled for release, performance is good enough.

Most devs should learn to use profilers.

Re:Rust 1.63 by int_19h on Saturday August 13, 2022 @04:28PM (#32453478)
In what implementation, and what guarantees does its debug iterators provide?
Re:Rust 1.63 by pjmlp on Sunday August 14, 2022 @12:36AM (#32456366)
The one from your employer, Visual C++.
Re:Rust 1.63 by int_19h on Monday August 15, 2022 @04:47AM (#32467292)
If you mean _ITERATOR_DEBUG_LEVEL=1, they're about 4x slower for iteration. I suppose "good enough" is subjective, but if this much is acceptable, I'd rather use C# - it's in the same ballpark.