Programming code tells the computer to do something, but what makes the code actually mean anything to the computer?

1.22K views

Programming code tells the computer to do something, but what makes the code actually mean anything to the computer?

In: Engineering

36 Answers

Anonymous 0 Comments

**A computer is basically a HUGE electric “marble race” game, with the track shaped by the program.**

You start with logic gates. LOTS of them. The power tumbles in lots of different ways according to the way the “track” is set up, and after a lot of applied ingenuity you get it to actually do something useful.

What do I mean by a logic gate? OK, let’s say you design a tiny electronical circuit that has two wires (A & B, say) going in and one wire (C) coming out. And that it’s designed so that there’s an output signal if (and only if) it’s getting at least one input signal. If both are missing, nothing comes out. That’s basically a logical OR – C gives a signal if and only if it gets one from A OR B.

Then you design another that gives an output when, and only when, it has no input on a specific wire. That’s a NOT operation.

You can go on to work out how to build basic circuits that do other logical operations, but with OR and NOT you’ve now already got enough circuit designs to combine to give all the possible logical operations – AND, XOR and so on. [You can make an AND with three NOTs and an OR, for example: feed each of A and B into their own NOT gates; feed the two outputs into an OR gate; feed the output from that into the third NOT gate; what comes out is basically A AND B. Proof left, as they say, as an exercise.]

So now you start working out how combine all the gate types into bigger combinations that do something more interesting. You can combine them to tweak a set of electrical values that represent a number so that you effectively add 1, for example. So you keep going, building the complexity. What you’re aiming for is a heap of circuits that will copy the values from one place to another, then do interesting things based on what those values are, then move on to the values in another place, and so on. And those values that make it do the different interesting things – are the program.

Add power. Electricity tumbles in all sorts of different ways, and the track ticks into a different shape. Add a bit more power, and it ticks into a new shape again. And the shapes are controlled by whatever values we put in some special places – those values are the program. Keep adding power and with enough ticks, suddenly you’re browsing Reddit. You’ve got a computer.

Big marble race, like I said.

You could, quite seriously, design a “computer” to run a modern operating system using marbles. It would be enormously big and INCREDIBLY slow – and the engineering challenges to make it work would likely be insuperable – but in principle you could do it.

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