4 ms·
If you were using std::vector::at (the proper way), you'd have bounds checking as well. One should only direct index if they really know that they are inside th
by colejohnson66 5y ago
If you were using std::vector::at (the proper way), you'd have bounds checking as well. One should only direct index if they really know that they are inside the bounds. And in Rust, there's std::vec::Vec::get_unchecked: https://doc.rust-lang.org/std/vec/struct.Vec.html#method.get_unchecked https://doc.rust-lang.org/std/vec/struct.Vec.html#method.get...
- jcelerier 5y ago> If you were using std::vector::at (the proper way), it is absolutely not the proper way and a complete anti-pattern
- School-Cotton 5y agoThat depends on the project. Anyway, it’s irrelevant, because you can do it either way in either language.
- gavinray 5y agoThis is the Ossia Score lead dev FYI, he's no stranger to either language
- School-Cotton 5y agoI don't know what Ossia Score is. Regardless, I didn't mean to imply anything negative about the competence of the person I was replying to.
- chlorion 5y agoYeah I agree using vector::at is a common and fairly bad anti-pattern. So long as you make sure your program is correct you never need to worry about indices being out of bounds. Requiring bounds checking is a sign you need to eliminate the errors in your software. This makes me wonder, why are people writing software with errors in it in the first place? Even master programmers seem to be too lazy and careless to remove the errors from their software. What gives?
- imtringued 5y agoI think I'm falling for Poe's law. Here is a honest answer. The problem is frankly unsolvable thanks to the halting problem. It's impossible to determine in general whether a program is going to reach a certain state except by testing all potential inputs and even that is only going to give you an approximate answer. If it were possible we would have written a program that solves the problem through static analysis.
- benibela 5y agoUsing C++ is an anti-pattern That is why I write all my code in Pascal, where you can enable bound checking for [] Enable it for a debug build, and you an be sure there are no overflows of any kind, and when it runs the program has pretty much no errors at all. Disable it for the release build, and it runs as fast as if it was written in C
- pjmlp 5y agoDefinitly not a complete anti-pattern in distributed computing software that cares about security and for whatever reason needs to be written in C++.