What makes computer code ‘work’

804 viewsEngineeringOther

By this I mean, when you write code, what exactly gives that the power to do anything is it more code? 0’s and 1’s? more so, what gives that thing the power to do anything? At some stage I can only deduce what must just be magic making it work because it’ll boil down to something metal and plastic ‘talking to’ an electric current, which doesn’t make sense at all

In: Engineering

17 Answers

Anonymous 0 Comments

This may be easier to answer from the bottom up.

The fundamental thing in a computer is the electronic switch. They’re different from regular switches in that you turn them on and off with electricity instead of by hand.

If we agree that on=1 and off=0 we have a “yes” gate; the output just repeats your input.

That lets you build combinations of switches by using some switches to turn other switches on and off.

The basic setup is to build “logic gates”. We can easily change it so that a 1 input gives you a 0 output and vice versa (a NOT gate) or we can put two switches in series or parallel (an AND or OR gate) and so on.

If we combine logic gates we can get more complicated relationships. We can create feedback loops so that you only need to send a single 0 or 1 pulse to a circuit and then the circuit gets stuck in that position until you send the other pulse. Now we have a memory circuit.

Now we’ll add some timing circuits so that changes in our circuit happen in discreet steps.

Now we can do some cool stuff. We can build circuits that look at memory and use those bit positions as inputs to our logic circuits. We can take the output and send them back to memory.

That’s a primitive and really annoying-to-use computer. You program them by picking combinations of 1s and 0s (machine code) that will switch the rest of your circuits in the right way. The “right way” is something that gives you an other set of 1’s and 0’s that you can interpret in some meaningful way.

That all sucks to use so we spent several decades using those crappy programming “languages” to write programs that would take sort of english looking stuff (source code) and convert it to the bits that circuits use (machine code).

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