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
a lot of people are talking about how things become 1s and 0s, i’m going to talk a little bit more about how those 1s and 0s do stuff.
a really important thing that happened is that some guy named George Boole came along in the 19th century and figured out a way to do our normal math with just two numbers, 1s and 0s. this preceded our modern computer circuitry!
it just so happens that being able to do math with 1s and 0s is useful when you have stuff that cares whether there’s a current (1) or not a current (0). Early on people used this to do computations way faster than a human could do. Later on they might have hooked up a display or printer of sorts that might, based on a signal, spit out something when the math does something interesting. Eventually, with lots of money and lots of work and lots of miniaturization, this becomes displays, eventually this becomes video games, the internet, etc.
Basically: everything you do on a computer is some sort of math, and computers do that math with 1s and 0s
Edit: missing here is also mention of a person named Turing, who came up with a hypothetical machine that could follow instructions to do math. That was so foundational that we talk about computer languages as being “Turing-complete.” Boole and Turing together paved the way for random circuits (even if there are billions of them) to do something interesting, even to non-mathematicians, like run Crysis
From the start of writing code and all the way down to electrical signals go a lot of layers of abstraction. I think it’s easier to start from the bottom and go all the way up:
– Let’s take a light. You can turn your light on (1) and off (0).
– A screen is basically a set of a lot of tiny lights arranged in a grid. Someone made a basic controller that will read a stream of 1’s and 0’s to turn on each of those lights.
– Now comes the processor. It’s easy to make one that just counts 2 numbers together by [comparing input signals](https://www.wikihow.com/Add-Binary-Numbers). The result can be sent to the previous display controller by converting that result it into a stream of 1s and 0’s (eg 3+4=7. This 7 can be mapped to a long line of 1s and 0s to display it on our primitive screen)
– similarly the processor can perform other commands: subtract, multiply, store in memory, read from memory.
– one smart person created a language (assembly) that instead of writing 1s and 0s to let the processor do these commands, you could use simple text commands. When you write such a program, you let it compile (convert) the text into those bits.
– another smart person then used that language to create a higher level language. It would use those simple functions to let you write `if`, `loop` and many more commands that are more human readable. Again when you compile that text, with the help of the assembly language, it turns into 1s and 0s
– now you can create another higher level (easier) language which just combines these commands of the previous language.
You could go on and on, and developers basically write functions that just combine the available functions of a language like it’s a set of LEGO.
Transistors, particularly transistors as switches. A transistor lets electrical current through if it gets a control current. This lets you do binary logic. There’s four binary operators; AND, OR, XOR and NOT.
AND returns true if both input bits are 1. OR returns true if either or both bits are 1. XOR returns true if one input is 1 and one is 0. NOT turns the input to the opposite value, e.g. 1 becomes 0 and 0 becomes 1.
You can create these operators with transistors (and well, with possibly e.g. diodes, but that’s not as optimal). Then you group these sort of operators into blocks, and those blocks into bigger blocks, and eventually, you can do stuff like basic mathematics.
Start here: https://youtu.be/O5nskjZ_GoI?si=B_qPnfp9imvvbz2i
This is the PBS Crash Course on computer science. It will take you from nothing to computer literate. The first five or so episodes will focus on what you’re asking: how a computer does anything useful.
Remember, your sitting atop decades of advances specifically designed to make using one of the most complicated devices ever invented both simple and intuitive. Millions of Hours of very hard work went in abstracting this into something you could understand.
The wires in a computer all have either high current or low current, represented as 1s and 0s.
With these 1s and 0s, we can connect them to do math, but it’s a bit less intuitive than if we had 0-9.
From there, were arrange and rearrange the wires and their connections until we get the output that we want.
There isn’t a magic step that your screen takes to turn those 1s and 0s into this text you’re reading; the screen is designed so that when it’s given some math, the parts that we decided correspond to letters are visually displayed as letters.
All of this decided arbitrarily (relative to our intuition)
Electricity follows very predictable paths. We can use this trait to accomplish some fun things.
We can make a circuit with two inputs, which sends an output signal if one input or the other (but not both) is receiving a signal. This clever little guy is called a NAND circuit (standing for not-and). If we take two of these circuits and chain them together we can make a circuit which takes two inputs and outputs a signal only if both of the inputs are receiving a signal. This is an AND circuit.
We can keep chaining these different kinds of circuits to create more complex logical expressions: OR, NOR, XOR, NOT, etc. With these logical expressions we can create complex logical processors capable of storing a binary value until needed, counting in binary, and adding binary numbers.
With those three things we can do anything else: subtraction, multiplication, division, taking input from the user, drawing pixels on the screen, and storing your half-finished novel you’ve been meaning to finish.
Mostly, we do this by assigning significance to various binary numbers, and then performing binary arithmetic to change between states.
All of it comes down to that little NAND circuit.
Latest Answers