3 ms·
honestly it's bananas. I can't for the life of understand how such a poor form over function decision was ever made by an engineer. the number of bugs (>0) this
by mlevental 9y ago
honestly it's bananas. I can't for the life of understand how such a poor form over function decision was ever made by an engineer. the number of bugs (>0) this introduces into production code every year is reason enough (imho the only relevant metric) to prefer braces. are block delimiting braces really that onerous???
- coldtea 9y agoBecause braces don't introduce bugs? You can just as easily omit braces in a if/for etc statement and have a bug, or close the wrong brace at the wrong point (and also introduce a bug).
- mlevental 9y ago>omit braces so you're saying braceless ifs and fors are bad? yes I agree. > close the wrong brace -/+ 1 flipping the right number of braces to get that kind of bug is much much harder than indenting a block incorrectly
- avmich 9y agoBut the requirement for always having brackets is just plain inconvenient for many. Even C doesn't always require brackets.
- coldtea 9y ago>flipping the right number of braces to get that kind of bug is much much harder than indenting a block incorrectly Maybe, but enclosing an additional statement or more in your brace because you visually indented it incorrectly is just as easy as in Python. for (i=0; i<100; i++) { do_this_100_times(); but_this_just_once(); #oops } And if you didn't indent it incorrectly, then it's still possible: for (i=0; i<100; i++) { do_this_100_times(); but_this_just_once(); # oops } whereas in Python it's not: for i in range(100): do_this_100_times() but_this_just_once() # correct indentation takes care of it
- tigershark 9y agoI can upvote you only once sadly..