How does coding physically work?

560 viewsOtherTechnology

Like how exactly can a bunch of letters, numbers, and punctuation symbols make your computer do all kinds of things? Plus what happens inside the computer when it executes the code?

In: Technology

22 Answers

Anonymous 0 Comments

Okay, let me try to break this down into multiple layers:

**Hardware:**

Inside your computer is a bunch of interconnected “wires” and “gates”. I don’t think I need to give an explanation of a “wire”– But I think gates do deserve an explanation. Basically some wires are attached to these gates, and whether the wire has electricity running through it or not, the gate will “react” to that combination of electrical input, and either pass electricity along, or stop the passing of electricity.

Going even more basic, how could this work? One example is an “AND” gate, often represented like [this](https://www.electricaltechnology.org/wp-content/uploads/2018/02/AND-gate.png). What it does is that if both of the 2 wires going into it, are “turned on”, e.g. has an electrical signal going through them, it will output a signal. But if only one or none of the wires attached to it has an electrical signal, it won’t output anything.

Now I don’t know the exact fancy mechanisms of how these microscopic things work, but lets just imagine how we could make such a switch. You could either put in some type of resistance that can only be overcome when you have the combined amount of electricity running through both wires, or a switch that can only get turned on when both wires are providing power, the exact method is probably way past ELI5, but you can imagine something like this.

Now there is a handful of different kinds of gates, which react differently to each set of inputs. There’s forexample also a “NOT” Gate, and basically what it does, is reverse the signal. So you put in electricity into a wire, and the NOT gate stops that signal. Then when you turn the electricity off the wire, the NOT gate will start outputting a signal.

If you wanna look more into this, there is also XOR, NOR, OR and many other gates, that can take different set of inputs, and will “react” differently to them, and pass along an output depending on the circumstance.

Combining the gates in creative ways, you can start putting in a certain combination of input, and get a set of output, that can be useful.

**Language:**

Another element in understanding this puzzle, is also to understand that nothing and everything can have “meaning”, depending on how its “interpreted” by an observer. Forexample, as a european person who knows nothing about asian languages, I can look at chinese symbols, and its completely meaningless to me, because I don’t have any model to interpret and put meaning to those symbols. On the other hand, the arbitrary lines I’m typing out here, I have full intention of the meaning behind them, and since you asked the question in this language, I assume that we have some shared set of interpretation of these symbols, so by using them, I can transfer some meaning from my mind to yours.

However we do this, doesn’t really matter. And it doesn’t have to be symbols! We also talk, which is another way of communicating. There’s hand signals that deaf people use. And there’s even some super simple ways to do it, like morse code, where you just basically have 2 “symbols”, a long and a short beep. 2-symbol communication is something we can label as “binary”. Now if we look at the electrical wire, they kinda also have a binary option, either there’s electricity running through them or not.

We can forexample assign a number value to a bunch of wires, so forexample, the first wires value is 1, the second wire is 2, the third wire is 4 and so on. This would be the binary number system, so if I wanna write the number 6, and I have 4 wires, I would write it like this: 0110.

**Processing:**

Now combining the 2 elements above, we can built a set of wires and gates, where when we input the number 4 twice, which we could write as 0100 + 0100 we get the output 1000, which is 8, and we suddenly have addition! To see some more concrete examples of how to put the gates together to see this, you can do a simple google search, but I will also provide a link [here](https://www.electronics-tutorials.ws/combination/comb_7.html) to make it easy!

As you can see, we can use some quite simple steps, and a layer of interpretation, to make something useful. Now as with morse code, this binary set of 1’s and 0’s or ON/OFF wires, doesn’t have to be mapped to specifically numbers, we can also map them on to other symbols, words, actions, because its all just a matter of interpretation.

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