# Why do we rely on computers in critical fields?

I assume that computers make many mistakes (like errors, bugs, glitches, etc.), which can be observed from the amount of questions asked everyday on different communities (like Stack Overflow) showing people trying to fix such issues.

If computers really make many errors (as I assumed earlier) then critical tasks (like signing in or receiving a receipt) must be designed to be almost error-free, unlike most of the tasks of most software and video games.

• Related: Why are computers so reliable? Jul 22 at 22:16
• @njuffa a CT scanner should be designed in such a way that nothing too bad happens even if the OS on which the control console runs crashes. So unless the OS glitches in such a particular way that it injects erroneous commands into the control streams, but otherwise behaves unsuspicious, the overall system is still safe. Which is quite unlikely, because if any bit errors happen at the OS level it usually will quickly trigger a segfault which puts a stop on any further shenanigans. Jul 23 at 7:27
• Apart from the fact that most computer "errors" are not errors but logical mistakes made by humans, humans make so much more errors! And yet we trust them with flying airplanes, cutting us open in the hospital and doing a manifold of tasks. When you say "many", what does this mean? Because doing the same things as humans, computer do basically no mistakes compared to the human counterpart (in what we consider a mistake, not "missing functionality" such as "not able to "drive" a car. Jul 23 at 15:06
• @leftaroundabout This was not always the case, and one of the case studies in EE and (Presumably) CS education was a fun little machine called Therac-25, the (horrifying) story is worth reading as a case study in safety critical design done very, very, wrong. Jul 23 at 17:21
• If you think the computer error rate is bad, you should check the rate of human errors. :) Jul 24 at 2:09

If computers really make many errors (as I assumed earlier)...

Your assumption is wrong. Firstly, computers do not (except in extreme cases) "make many errors", humans do. Computers simply do what they are told to, very quickly and very well. Extraordinarily well, all things considered.

Secondly, what you're perceiving as a high rate of errors is in reality a high perception of errors. A banking system that handles millions of transactions per day may have a hidden bug (a human error in coding) that in a very specific set of circumstances does something incorrect. Those circumstances may only occur after years of correct operations. One failure in several billion operations is not a high error rate, but you hear about the failure and assume that the banking system must be error prone.

Back in the days when humans handled all the transactions - way, way back when that was even possible - the average error rate for transactions was many orders of magnitude higher. You can see that today in accounting circles, where end-of-month processing routinely involves tracking down human data entry errors to figure out why the (electronically recorded and processed) books don't balance.

then critical tasks (like signing in or receiving a receipt) must be designed to be almost error-free

While signing into a system is a relatively simple thing to implement, the big-ticket flaws you've heard about generally come from outside of your own implementation. OpenSSL's Heartbleed vulnerability potentially allowed an attacker to snoop on your secure communications, Spectre/Meltdown potentially allows malware to snoop on your program's memory, and there are all sorts of interesting attacks on encryption that make life difficult. And any time you hear about one of these things it's sensational, front-page news on the tech sites and a flurry of "how do I protect against this" posts on programming sites.

And yet billions of logins happen daily, more billions of transactions get processed, making the true failure rate almost absurdly low.

unlike most of the tasks of software and video games.

Software development for critical systems is an entirely different environment than game development. For one thing, only one of the two is about making money as quickly and cheaply as possible. Games developers don't actually care if a few bugs go through to production, because who cares if your car clips through walls in an out-of-the-way part of the map, or in some rare case manages to slide through the ground and you end up falling out of the map... just reload a save or something, and we'll patch that later. After all, modern gamers are used to being used as alpha testers on games, just as long as they get to have some fun who cares? Especially if they're paying for the privilege. And it's not like you have the time or the budget to rigorously test every possible code path.

Critical systems development can't be that sloppy. Every element is tested thoroughly, ever combination of elements is further tested. A lot of very bright people are paid a lot of money to find new ways to torture your code to make it break down and produce errors, and when they succeed it's back to the dev team to find out whay it broke and fix that issue. The customer doesn't get to see the system in action until it has been tested in every conceivable way. Because when it fails really bad things happen, and save points are really far apart in the real world.

Why do we rely on computers in critical fields?

The simple reality is that there is no better option available to us. The things we use computers for simply can't be handled by humans alone in the volume, speed and accuracy required.

Are there alternatives? Maybe. Analog computing is great for some things, quantum computing offers some interesting possibilities. But for right now general-purpose computing is the best option on so many levels, and it's what we've spent most of the last century focusing on.

• Another thing (something I point out to people when talking about autonomous cars), once you fix a mistake in a computer it is fixed. Humans often make the same mistakes over and over again because they have to be taught separately. You can deploy a fix to millions of computers at once. Jul 25 at 10:19
• Still, every few years we hear about issues in critical software. Often, we later learn said software was not following best practices. From Therac-25, where best practices were nonexistent at the time, to Toyota's unintended acceleration where they were outright ignored. Jul 25 at 16:42
• A valid bug report to a real critical-system dev team results not only in the debugging of the software, but also in a review/debugging/revision of the development process that allowed the bug to get into the code in the first place, so that similar bugs can't be introduced in the future. (as you might imagine, this leads to very reliable software that gets developed very slowly :) ) Jul 26 at 2:15

Computer hardware almost always does exactly what software tells it to do.
It's useful to distinguish software bugs from unreliable hardware.

Cosmic rays can randomly flip a bit in memory, though; that's why servers often use ECC (Error Correction Code) memory to correct single-bit errors and detect most multi-bit errors. (And internally, CPUs usually use ECC for their caches.)

Computers that need even more reliability and availability1 than that, like flight computers in aircraft or space craft, often have 3 separate computers processing the same inputs. (Triple Modular Redundancy) If all 3 produce the same output, great, it's almost certainly correct. (Especially if each of the 3 computers is running software written by different teams.) If only 2 out of the 3 outputs match, the odd one out is assumed wrong, so it gets reset and the system uses the outputs of the remaining two until the faulty one is rebooted and agreeing with them. If all 3 systems give different outputs, you have a big problem. If 2 systems give the same wrong answer, that's even worse.

Safety-critical systems like those are programmed in software much more carefully than video games or even mainstream OSes. Practices like avoiding dynamic memory allocation (malloc) remove whole classes of bugs and possible corner cases.

Footnote 1: detecting an error and rebooting is not sufficient when the system is part of the flight controls of a jet plane that could crash if the controls stopped responding for half a second.

Related:

• For transient/uncorrelated errors, error detection and retry is an option. Wear-and-tear (e.g., electromigration) as well as extreme events can cause persistent errors. Frequency of errors can indicate correlation/less transient nature (e.g., SMART statistics can predict reliability). Testing is necessarily incomplete (cost and destructiveness constraints — and Heisenberg). 'Environmental' factors like voltage/voltage stability and temperature regulation influence reliability even with specified tolerances. Your long answers are great, but I also admire your ability to not post a book! Jul 23 at 17:29
• (For the record, I posted this answer when the question title was "Are computers really reliable?". Barmar's nice answer is aimed more directly at the new title, about why we rely on them in critical fields.) Jul 25 at 0:03
• You avoid dynamic memory allocation primarily because it's very difficult to allocate dynamic memory with guaranteed latency (= messes up realtime guarantees), and only secondly because you can have memory leaks or double frees (if you are coding in C, which is an awful language for that sort of things due to its many way to get to UB) Jul 25 at 6:26
• @Astrinus: It also avoids the possibility of churn in allocation / free leading to increasing fragmentation and eventual allocation failure even without memory leakes, in ways that are hard to test for. IDK how realistic that possibility is, but one could imagine it if the peak allocation footprint is not much smaller than total RAM, so it's plausible to be wasting enough due to fragmentation when trying to allocate a medium-sized array. Jul 25 at 6:33

Most errors in computer systems are caused by humans directly through design and programming errors.

Almost all questions on Stack Overflow concern programming problems and most errors that make it to end users are software bugs (human oversight).

Logic errors in hardware design (human oversight) have also caused trouble but theses errors are less common. Such issues can normally only be worked around at the OS or compiler level as hardware is almost impossible to fix once shipped.

Finally, as computers are electronic devices, they are susceptible to environmental influences (such as heat or radiation) and undesired complex physical interactions. Electrical interference can, for example, cause bit flips in DRAM but this is extremely rare as far as we are aware. It turns out such bit flips can even be caused intentionally from malicious software, which is known as row hammering, and it is believed by some that certain software might in rare instances cause bit flips by accident.

While the first two kinds of errors can be avoided through careful testing, simulation and formal modeling and verification, it is almost impossible to build an accurate physical model of an entire computer and all its smallest building blocks. As such, we will almost never be able to build a 100% reliable computer that works in uncontrolled environments. Nonetheless, finding better ways to build correct software through modeling and verification will already make computers much more reliable.

• These systems have a narrower focus which makes testing and maintenance easier. Also medical systems are more likely to be at least partly formally verified which is almost impossible for Windows, which — due to its age and history — lacks a clear enough specification. Jul 22 at 21:35
• Actually Windows is extremely broad in scope. Commercial operating systems are really the outliers, being much more complex and feature rich than most other software created today. Also, note that medical software has even caused fatalities in the past (cf. en.wikipedia.org/wiki/Therac-25), so it's not like this a domain where software is perfect. Jul 23 at 8:39
• Also note that not even narrow-scope medical devices might be that safe, see e.g. an article on security vulnerabilities in cardiac pacemakers from 2017. Computers are reliable enough, the problem is the humans writing the software, and lax design and development procedures. Or the emphasis on getting stuff out of the door as cheaply as possible. Jul 23 at 12:11
• @idmean: Like with many safety-related engineering fields, lessons were learned from that. It's often said in aviation that progress in safety practices is usually paid for in blood. Of course bugs are still possible, but in the Therac case there were many signs of buggy software for operators, but were assumed not to be safety-relevant because operators didn't know safety relied on that software, with no hardware interlocks. Jul 23 at 16:06
• @AZeed If it’s designed right. If you haven’t looked into the aforementioned Therac-25, I encourage you to do so. It’s become a de-facto standard case study in how not to handle design and development of safety-critical systems, and was one of the things that prompted many countries to create specific regulations regarding the design and development of such systems. Jul 23 at 16:09

Because there's no practical alternative. Modern life is too complex for ordinary humans to keep track of all the details. And critical systems often require reaction times far quicker than humans or mechanical systems are capable of.

Consider a spacecraft. It likely has thousands of components that have to be monitored constantly. Mission Control would have to have hundreds of people on each shift watching all these readings, and they still wouldn't be as reliable as the computers.

Or in a hospital ICU, what would you replace all the computerized monitors with? You can't have a nurse watching each patient. We need to automate this, and have the computers raise alarms when a reading goes to an abnormal value.

The old saying "Don't let the perfect be the enemy of the good" applies. Despite the potential problems, computers are good enough to do what we need of them. There are millions of cars on the road with computerized control systems in the engines -- when have you heard of any of them failing?

Computers can have bugs, but safety-critical systems go through extensive testing. When computer software fails, the bugs can be fixed or the equipment can be replaced; it's harder to fix human error (you can do additional training, but people have inherent limits on speed and concentration).

There are other ways to mitigave computer problems, such as redundancy. The Space Shuttle had 5 identical computers operating the avionics system. During critical mission phases, 4 of them would would operate together, each calculating a result, and they would "vote" on the output. See Redundancy Management Technique for Space Shuttle Computers. Some airliners use redundant computers with completely different hardware and independently-written software, to avoid the possiblility that the same bug will be in both; see How dissimilar are redundant flight control computers?

Of course, less critical systems do fail more often. A few days ago the display of my car's navigation and entertainment system froze after displaying the startup message about using the system safely. Restarting the car rebooted the system and it was fine then. This system isn't necessary for driving, so it wouldn't have been a problem if it happened during high speed driving when I couldn't stop and start the car.

Basically hardware is reliable because it has to. It's not possible to fix a chip, and it's either impossible or not economical to fix a circuit board after it has left the factory. If a company sells buggy hardware, they can expect customers to ask for a refund.

In addition, hardware and especially chips have huge upfront costs. If the design for a cpu makes it to manufacture with bugs, someone is going to lose a bucketload of money and be very displeased about it.

Therefore, hardware and chip companies had to come up with ways to ensure the product actually works. And when there's a bug and the product is sold anyway, you can expect full documentation, erratas and workarounds.

On the other hand, no-one cares about software. It's kinda expected that it's going to be full of bugs, and it's easy to fix them with an update, which costs very little. The huge cost of throwing away bad chips and redoing a fabrication run does not exist for software.

Unless the software runs something like a rocket, or a plane, or a fabrication plant, where bugs cost a bucketload of money, there is really no incentive to make software that actually works 100% free of bugs. In fact, "release early with bugs" is often the more profitable option...

On top of the incentives, it's easier to test hardware because it is simpler. It has less state. The number of flops in a design is known. Hardware rarely manages complex data structures, buffers are usually of fixed size, synchronization is handled by well characterized primitives like FIFOs, there are much less object classes, less genericity, etc. It is designed as small pieces that can be unit tested (I heard that also exists for software, but who does that?...). And the tools pretty much guarantee that what is synthetized will do what the HDL says it should do.

The way to make sure a class of bugs doesn't happen is to find a provably correct solution and automate it. For example, if a language supports automatic memory allocation, then there can't be memory allocation bugs. It's the same for many classes of bugs. Can't have buffer overruns in a language that actually knows the size of a buffer. That kind of stuff. But using a new language is complicated, due to mountains of legacy code. This is different from hardware, where each big new generation of CPU tends to throw away large parts of the previous designs.

Now for example, SQL injections. There's one way to do it right, and that's to use a library or language that does it properly, where you pass a SQL query with placeholders and variables separately, like python DBAPI does. This is such an obvious fact, that it should not even need mentioning, yet many languages have (or are still using) the old bug-prone way of putting raw strings into queries.

A tool like PHP, which consistently produces bugs, would not live for long in the world of hardware. It would not be profitable. Yet PHP still thrives, on the software side.

Extra:

There was a time where software had a similar "cost per bug" as hardware, that was before the internet. Back in the day, bugs could not be fixed by an easy auto-update download. Sometimes, you had to mail floppies... and in the worst case, like arcade machines, game consoles, software that is burned into mask ROM, it was impossible to modify. These had the same cost incentives as hardware to get it right. These must have been thoroughly tested. Software was also much simpler back in the day, of course.

• The tradeoff of this is that it has become affordable to do things with software that would just be too expensive to develop the hardware to do the same tasks, so long as you accept the risks of those bugs. And in a lot of scenarios having the human who uses the software manually intervene in those cases is an acceptable tradeoff against the benefit of having the tool in the first place, even if it only works some of the time. Jul 24 at 17:28

First of all nothing is unfailable. And if it be only, that its hit by a meteorite and gets completely destroyed.

Under the assumption, that there are no external factors, such as power failures, excessive heat, flooding, cosmic rays, etc. a computer will do exactly what you tell it to do.

As mentioned in other answers, this is the main crux of computers. If you do not give it clear enough constructions, there's room for error or malfunction, but this solely based on human error.

Testing exists for this purpose, but testing alone is not enough. You need to make sure, your tests are worth your money. There is a famous joke among programmers:

A programmer programs a bartender. He tests it by ordering a beer, ordering 20 beers, ordering 0 beers, ordering milk and ordering pretzels. Convinced that his software works, he opens the bar. The first guest comes in and asks for the restroom. The bar burns down in flames.

The punchline (forgive me for explaining it) is, that the programmer did not anticipate such input. As such, especially critical systems need to be guarded against all possible forms of failures in order to avoid a crush or bug. This way, a much higher reliability can be reached than letting a human do the operations.

Humans get tired, distracted, lazy. There have been too many incidents to count, where people did not bother to follow safety instructions completly (even in super critical sectors as the flight industry) which ultimately lead to disaster. Computers will follow your orders to the letter. It's on humans to account for all possible options.

While this may sound impossible (after all, aren't there infinite possibilities) let me conclude this with a small example.

Suppose you write a program that wants to read in a number greater than zero. The user could input 0, a negative number, a letter, a picture, whatever. So if your code looks like this:

user_input = get_user_input();
result = 1 / square_root(user_input);


the last line could become problematic and indeed the program will most likely crash if incorrect input was entered. So to guard it, you'd write

user_input = get_user_input();
result = default_value;
if( is_valid_number(user_input) ){
result = 1/square_root(user_value);
}
else{
print("Error: Please enter a number > 0");
}


As such, it is very much possible to build very reliable software, even with human error factors.

Computers aren't the source of the failure. Programming isn't the source of the failure.

Algorithms thought of by humans are the source of the failures.

If we get a human to do steps to "login" or "provide receipts", they will make as many, or more, errors than the program that replaces them.

In fact, when you take a set of clear steps and automate them, you get a massive reduction in process errors. This can be so large that you make a different kind of error -- you try to apply the process in cases when it isn't very reliable!

When someone signs into a hotel, for example, the front desk does a bunch of steps involving verifying their identity, checking the payment method, ensuring the room is clean, etc. Prior to computers this was all done without them, using paper records and steps the people involved where supposed to follow.

It was slow, extremely error prone, and cost a bunch of money.

Replacing the steps that humans are bad at with computers doing them made it faster, less error prone, and much cheaper. But when they did this, they also tended to implicitly fold in tasks the computers where not good at into the same workflow, like dealing with exceptions and the like.

So you can get powerless front desk staff who are unable to make the computer make an exception when it is in the business interests of the owner of the hotel and computer to let them do it. And when the computer does make a mistake, there isn't the skills or ability to route around it and fix it.

Computers have replaced entire office buildings full of paper-shufflers. Forms getting mailed in, processed following certain algorithms, totals added up and written on other forms, summaries generated and put on other forms. Typists typing up documents, sometimes in triplicate or more. Secretaries taking memos and categorizing them by importance and presenting them to their executive. All steps we now do with computers for far less cost and far faster.

The computer doesn't always do it better, but it does it with far, far less errors.

The result of this lower error rate is that we pile more systems on top of systems. If you had something that failed 99% of the time, you can't build much on top of it; but you drop that failure rate to 0.001%, you can now treat it as reliable. So you build a system on top of it and 1000 other systems; and now your failure rate is upwards of 1%. You keep doing this, generating value, until the failure rate is high.

The only super complex systems we have are either the result of extensive engineering, like cars or rockets or integrated circuits or manufacturing line or bridges, or are the result of computer programming. Of these, computer programming is by far the cheapest one to prototype and modify and extend.

With this cheap extension and prototyping, you get these insanely complex systems built on a budget that solve problems. But the cost to make them reliable is very high, much higher than the cost to build them and see if they work. So computer programs are almost always written the be cheap and fast.

There is a whole pile of computer programs that are not written this way. Software to control air planes and rockets, for example. And software for medical systems. But even there, the temptation remains; you could either make something cost 100,000x as much and be utterly reliable, or be 100,000x cheaper and fail "very rarely". There is a lot of economic pressure to save a 100,000x cost increase and justify the cheaper way of writing software.

Modern software engineering is the economic management of insanely complex systems. When and where should you spend efforts on making something reliable, and when should you accept the insane cost savings of not ensuring reliability? Every spot you can accept bugs in is a spot that is much cheaper, but also a possible reason your entire project won't work.

• Computers aren't the source of the failure. this isn't true, hardware do sometimes fail (bad sector on harddisk, computer fan jammed, a piece of very rusted metal in motherboard, ect).
– LLL
Jul 26 at 2:43
• @LLL Even there, their hardware failure rate is insanely lower than any other physical substrata you can run algorithms on (like humans writing on paper). Again, it is because they are insanely reliable that we end up daisy chaining them together to insane depth and experiencing failures.
– Yakk
Jul 26 at 13:12

The short answer is that we don't rely on them being error-free to any greater degree than we rely on anything else in a critical system to be error-free. Just as an individual computer hardware component can fail (and will fail in certain circumstances), any other non-computer component (mechanical, human or otherwise) can also fail. Just as the procedures ("programs") we write for computers can be incorrectly written, so can the procedures we write for humans to follow.

We achieve high reliability in systems not by counting on things not to fail but by knowing how and when they fail and designing the system to accommodate those failures.

As others have data to show correctness in computers, I wanted to add something about computer errors. In short, a filed bug can be designated as expected behavior for several reasons, and then adopted as part of the process.

This was an actual postmortem to code that managed account creation for credit report data. So very related to sign-in. The expected behavior was to continue account creation, even when the user failed their credit bureau verification. In doing so, there was a statistical subset where two accounts with two SSNs were linked.

Being assigned the bug, I fixed it by halting account creation on failing verification. This is my point, I made a value judgement and applied my own bias of what is right or wrong. The team lead drilled it into the team at the postmortem that there was no bug and errors had multiplied after my fix, further proof that the fix was incorrect.

In summary, there are real situations in which the computer's ability to be impartial is important. Is it really an error? To a business, ethical questions are debatable, sometimes what's important is to execute steps without bias.

Someone compared self driving cars to cars driven by humans. I would look at text messages instead: Delivering a text message without computer would force you to write it say on a postcard, take it to a letter box, where it is collected, sorted by delivery town, then some postman takes it to my home and drops it through the letter box.

Not only would the error rate be a lot higher (probably one percent or more of lost or misdelivered postcards), but you could expect a cost of say \$0.50 per postcard, not counting the time it takes for you. There are kids sending hundreds of messages a day, they would bankrupt their parents in a short time.

A cheap computer can easily do 100 trillion floating-point operations in a day. So if that is what you need to do, then you have no choice but using a computer.

You get the wrong impression if you look at stack overflow for questions how to fix bugs. These bugs are 99% of the time not in shipping software! If an inexperienced developer creates a bug, either they detect immediately that their software doesn't work and fix it, or some more experienced developer checks it and it gets fixed, or QA tests the software, finds the bug, fixes it, or sometimes a bug appears only in very exceptional circumstances, so nobody ever finds it.

And you get the wrong impression again because humans make many mistakes that go undetected. If your car is repaired, but the repair is badly done, you will likely never find out. If your hotel bill, calculated by a human, is not correct, you will never find out. Computer programs do the same things again and again, and that is how mistakes get found out and fixed.

I can assure you that safety-critical software is produced in a way which ensures a high level of "software integrity".

• The vast majority of commonly encountered programming errors are not made at all because the safety rules demand specifically educated and certified personnel, demand using best practices, observing coding rules and using specific tools;
• the vast majority of the few errors actually made are found in mandatory reviews and mandatory, very thorough tests;
• the companies producing such software are regularly audited to ensure that they adhere to these principles;
• the systems are designed so that errors which are inevitably still present (which is where you are right) are mitigated. Mitigation strategies include redundancy, safe failure modes (like stopping a car or a train in case of an error), isolation of defective subsystems, or fallback to a degraded but still useful state.

These strategies make it possible to produce software that exposes so few catastrophic failures that it can be used where such failure would mean death.

The alternative is to not rely on computers. While there are some instances where humans clearly outperform computers (looking at you, Tesla Autopilot), in the vast majority of cases where computers do something safety-critical, they also outperform humans by a significant margin (c.f., anti-lock brakes, traction control systems, flight computers, pacemakers, etc. ad nauseum).

• Do humans outperform the autopilot though? I doubt Tesla's AI will be DUI, fall asleep or be otherwise distracted. The only thing where humans outperform computers are dealing with unexpected input, and with upcoming AIs, that might not hold true any longer during the next couple decades. Jul 24 at 7:55
• Given that autopilot has been implicated in 11+ deaths, I totally don't buy the autopilot AI superiority argument: news.yahoo.com/… Jul 24 at 8:42
• That number says exactly nothing. What you need to compare is number of crashes with deaths per drivers with autopilot with number of crashes with deaths per drivers without autopilot. Still, this number is likely not very much comparable. It'd be the same as arguing, flying is very unsafe, because there was an accident where over 100 people died. Jul 24 at 8:47
• @LawnmowerMan It's still hard to compare -- while it may have caused deaths where a human wouldn't, it might also have avoided many deaths that are common with humans. Determining the net benefit is difficult. Jul 24 at 19:28
• @LawnmowerMan you seem to conveniently ignore though, that the Tesla Autopilot requires people to take over the steering wheel at any time and again people are negligent and do something else. Jul 24 at 20:00