2 ms·
I'm going to disagree witha lot of this review. Here's an example: "In other words, take a conditional out of the spec for the function. But in Section 10.5, h
by mcguire 8y ago
I'm going to disagree witha lot of this review. Here's an example:
"In other words, take a conditional out of the spec for the function. But in Section 10.5, he tells us that we should add a conditional to the spec of a function, namely in making Java’s substring method defined for out-of-bounds indices. I’m not completely sure he’s wrong (as I discuss in my Strange Loop talk, it comes down to: is there a clean way to describe this behavior?), but I find his claims that this makes the code “simpler” only slightly more credible than his claims about the Unix file API."
Ousterhout contrasts that with the similar operation in Python. Substring throws exceptions if the indices are out of range, Python returns the part of the string that is in-range. For example, calling it witha start, end pair where start > end results in an empty string, not an exception; it's much easier to use in my experience. And I doubt the formal specification is any larger, to address the author's point.
The formal does of Unix I/O is a horror show, sure, but what does the spec of it plus all of the filesystem that can back it look like?
- tabtab 8y agoThis sounds like the "limp versus die" design decision: http://wiki.c2.com/?LimpVersusDie http://wiki.c2.com/?LimpVersusDie The "right" answer depends on the domain. For a web startup, you may want to live with occasional errors being ignored in order to get your product up quickly and grow market share. Early Amazon.com used to fudge up my orders, but such didn't end the company. But a bank probably doesn't want the software to "guess" if there is a potential numerical problem. It would rather have the batch process "crash". Otherwise, it could generate thousands of bad transactions and get sued to Pluto. People used to debate this with MySql's default "truncation" setting. MySql was popular with start-ups because you could get it up and change the tables quickly without dealing with persnickity details, living with stuff occasionally falling thru the cracks.
- mcguire 8y agoThe difference is between total and partial functions. A total function can have well-defined results (thus, no guessing) and is much easier to use than a function that unnecessarily fails.