Eli5 Where exactly do computers make decisions?

658 views

I understand the concept of coding, that it’s a bunch of if/then/unless kind of hardwired decisions. But where, PHYSICALLY, and how does this happen? This one I need actually explained like I’m five. I’ve never understood how code physically implements itself into fruition.

In: 1

10 Answers

Anonymous 0 Comments

Computers think in binary numbers, and they use a type of algebra known as *boolean logic*. **This is nothing to do with arithmetic**. Instead it was originally developed to makes rules using two values True and False and four operators OR, AND, XOR and NOT:

* False OR False = False
* False OR True = True
* True OR False = True
* True OR True = True

So ORing two values is always True unless all values are False.

AND goes:

* False AND False = False
* False AND True = False
* True AND False = False
* True AND True = True

The AND operator says that all combinations are False, unless they are all True.

XOR goes:

* False XOR False = False
* False XOR True = True
* True XOR False = True
* True XOR True = False

If they are all the same it’s false, otherwise it’s true.

NOT is easiest: it’s simply the other one.

* NOT False = True
* NOT True = False

Once computer scientists realised they had to work in binary 0s and 1s, they discovered they could use Boolean algebra, replacing False = 0 and True = 1.

A logic gate is a device that has two or more inputs, combines them using one of the operators above and gives one output. The internal mechanism is a combination of switches; in the 1940s these were made of valves^(1) which gave way to transistors which gave way to silicon chips. You can also model these using a battery, some regular light switches and a bulb.

Remember the XOR table? If both inputs are the same it’s true, otherwise it’s false. So let’s make an XOR logic gate:

[https://imgur.com/YuSGzeR](https://imgur.com/YuSGzeR)

You need A or B set to 0 to allow current in, and A or B set to 1 to allow current out and complete the circuit. If both are the same, no light.

So that’s how you do it with mechanical switches, and you can make the same electronic circuit using valves, transistors or silicon.

===

Valves need to be heated, so they glow and possibly attract moths. Such a moth might touch two terminals at once, creating a short or a “bug in the system”.

It’s quite astonishing to think how much electronic miniaturization has advanced since War2. The chip in the new iPhone 14 has 15 billion transistors on it, so assuming some logic gates are more complex, we might say there are three switches per gate, so 45 billion switches in all.

To make an iPhone 14 out of valves you might need 2 watts per valve, so 90 terawatts or 30x the entire world’s electricity production. Size? Allowing 1cm² per valve, this would cover half the land area of the USA.

So, not portable.

You are viewing 1 out of 10 answers, click here to view all answers.