Therac-25: When software reliability really does matter
en.wikipedia.org
en.wikipedia.org
Oh sorry, that was me daydreaming. Of course nothing has changed, people just "try to be more careful". Since people never make mistakes, even when pressed with tight deadlines, this has worked out fine. Asking the computer to double-check your code is just not necessary.
(Hmm, I think I got that backwards. It's just not my day today, is it...)
Translation: Nobody ever got fired for going with C, even when it leaves a stiff on the table.
Ultimately, the Therac was a failure of software engineering more than a software failure. I don't blame the technology any more than I would blame a girder for buckling because a careless structural engineer didn't realize it was overloaded.
What makes the Therac-25 notable is the novelty of a software problem killing people. If it had been a second hardware safety mechanism that had been removed, it wouldn't be as notorious - but the engineering failure would be equivalent.
http://staff.washington.edu/jon/cnts/iccr.html
The software we wrote has been used without incident for more than ten years.
(original PDF if you have access to the IEEE: http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=...)
And an updated PDF: http://sunnyday.mit.edu/papers/therac.pdf
It's one of the first paper's read in 6.033 (Computer Systems Engineering) at MIT, which is actually taught by rtm.
For more, see http://www.nytimes.com/2010/01/27/us/27radiation.html
http://news.ycombinator.com/item?id=887406 (Oct. 2009)
I was disappointed that they disallow the use of external libraries, but then criticise C++ code that is vulnerable to the obvious integer overflow. In a real interview, I would expect a good candidate to indicate that they would pull in a bignum library to avoid this, but there is no way to say that in this sort of test. Likewise, depending on the exact specifications, you might consider using a 64-bit integer type to hold the sum, but that's not portable yet. Presumably, if you're limited to standard C++ (which has no bignum library) and required to pass the overflow test to get a top score, the only way to do this is to reimplement the relevant parts of a bignum type. Of course, that is exactly the wrong thing to do if you have to solve this sort of problem in reality.
It is particularly unfortunate that they would criticise a candidate's code for this, while at the same time making a basic mistake themselves in the specification for the equi function. (If, as the problem states, there may be many elements in the input, then the correct return type for an index into a std::vector<int> would be a std::vector<int>::size_type, not an int. A size_type is always unsigned, so returning -1 in the event of finding no match is a bad idea.)
Compiler output:
wrapper.java:23: not a statement
for(int i =0; i++; i<A.length())
^