| ▲ | nazcan 6 hours ago | ||||||||||||||||
Thanks for the excerpts! I was trying to understand the reasoning, which seem to just be in the 2nd excerpt: - The rules of signed/unsigned are complicated and there is too much auto-conversion - does that mean languages that make this more explicit means this is fine? It just seems ideal to have stronger typing. - It is mentioned that you can initialized an unsigned int to "-2" - but that presumably could also be fixed in the language. I'm trying to separate out which is "don't do this in C/C++" and which is "don't do this in any language". | |||||||||||||||||
| ▲ | Groxx 6 hours ago | parent | next [-] | ||||||||||||||||
that argument (and many others) also round to essentially "implicit imprecise integer casting is surprising but we do it anyway" which is... perhaps the actual problem??? I've made lints for Go that simply disallow implicit number casting, and omfg the (real, occurring but unnoticed) bugs it found. those kinds of lints are trivial to build, you can just stop doing it. forcing visible casts made many of these problematic patterns extremely suspicious at a glance, catching issues at review time far more easily. | |||||||||||||||||
| |||||||||||||||||
| ▲ | BobbyTables2 2 hours ago | parent | prev [-] | ||||||||||||||||
Considering Rust doesn’t have such nonsense, I’m inclined C/C++ have utterly broken generations of programmers. In what world is using a signed value to index a normal array a good idea? Makes for horrible footguns like: history[counter % SIZE] = … (One cursed day counter rolls over, becomes negative, and an out-of-bounds write occurs) Everything went South as soon as we broke the abstraction of arrays and treated them as pointers. Commenters here are pretty much arguing which way to hold scissors while running instead of realizing that one shouldn’t do that in the first place… | |||||||||||||||||