4 ms·
> const-correctness may be another misfeature (I know I make fun of it), but the point isn't hard to see: if you take the time to const-correct your code, the c
by coliveira 16y ago
> const-correctness may be another misfeature (I know I make fun of it), but the point isn't hard to see: if you take the time to const-correct your code, the compiler will spit out errors that would have otherwise been runtime faults.
I think it is so interesting the mentality of static typing people. I would much prefer handling the few resulting run time faults than having to stuff with my code with const.
Anyway, there is no guarantee in C++ that something that compiles with all consts in the world will not throw a segfault at run time in the least expected moment...
- tptacek 16y agoNo compiler error ever ruined a NASA mission.
- edanm 16y agoFunny, but imo misses the point. The beauty of dynamic typing is that it makes the writing of the code easier, which makes development shorter, which gives you more time to thoroughly test your code. After years leading a QA team, I'm convinced that more time testing is always superior to more time writing code, even if the code you're writing is there to stop bugs!
- jemfinch 16y agoThe beauty of static typing is that it consists of a proof that entire classes of errors cannot occur when your program runs. Like Dijkstra said, tests can only prove the presence of bugs, never their absence. Static typing proves their absence and is thus extremely useful in writing highly reliable software.
- amalcon 16y agoI think it's interesting the mentality of dynamic typing die-hards. I find it much easier (for complex projects) to just type "const" where appropriate and let the compiler think about mutability for me, than to think about mutability myself. The mental overhead is definitely superlinear with the complexity of the project, and typing "const" a few times lets me use that resource for more subtle correctness issues. Of course, one problem with C++ (and, to a lesser extent, C) is that many of those subtle correctness issues are direct results of the type system in the first place. Go figure.