He who sacrifices clarity for correctness deserves neither
-
-
An example: For mission-critical software, Ruby/Python/JS are very *unclear* about critical aspects of the design. However, C sacrifices clarity for correctness and achieves neither. Rust is an attempt to be as clear as the requirements necessitate in those domains.
-
An example from a Rust RFC I wrote about times (https://github.com/rust-lang/rfcs/blob/master/text/1288-time-improvements.md#proposal …). .elapsed() is both clearer and more correct than attempts to compare two instants directly (RFC explains in more detail).
End of conversation
New conversation -
-
-
I think, then, the claim doesn't provide us any explanatory power: in all cases you could argue "it'd be unclear to sacrifice correctness". Would you be willing to provide an example of where code could not be made clearer without being made less correct, and this is a problem?
-
The claim (a riff of a paraphrase of an old quote) is that when confronted with what appears to be a hard tradeoff between clarity and correctness, work hard to avoid sacrificing clarity. Quite often, people concerned with correctness ignore clarity.
-
The unfortunate consequence is that unclear code is rarely correct.
-
I think that's a claim that would need to be backed up by a study. Often I've personally found that unclear code is unclear for a reason, such as contorting around a business requirement.
-
The underlying business requirement can be turned into an encapsulating abstraction with a name. Same crappy code, easy to "chunk" in other parts of the code. In a case I'm working on right now, naming the abstraction also provides a good place for a warning about dangers.
-
I don't mean a framework or big abstraction. Just finding a way to get the code out of places it doesn't belong. In these contorted cases, I've often found that compliance is haphazard, but hard to audit because nobody can memorize the full description of the correct behavior.
-
What would be an example of code where making it more clear would compromise correctness?
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.