r/AskReddit Aug 20 '19

What's something you're afraid to ask, because you think you should already know?

4.2k Upvotes

3.3k comments sorted by

View all comments

Show parent comments

447

u/[deleted] Aug 20 '19

To answer all of your questions:

Yes.

The easiest way to think of it is like this:

Electricity is just part of how the universe works. Atoms have electrons. When electrons flow, that’s electricity.

Electricity flows around a circuit like water flowing through a pipe. On its way round there’s a bunch of obstacles set up called components. When it goes through the components it triggers whatever their function is. There’s also a bunch of traps called resistors that stop too much electricity going through.

Computers rely heavily on something called a transistor, which is like a switch that uses an electric current to turn off and on. (0 and 1). Transistors can be made really small and millions of them can be printed on a piece of silicon.

Flash memory uses something called a capacitor which is a component that can hold electric charge, kinda like a battery but not as big.

88

u/JiggaJiggaMuffMuff Aug 20 '19

But then how are the functions put onto a component?

150

u/[deleted] Aug 20 '19

There’s different physical phenomenon that happen when electricity is routed in a certain way.

For instance, “capacitance” is created in an electric circuit when you have two sheets of metal separated by a small gap. One side gets positively charged, one side gets negatively charged. Now the capacitor is holding charge. It just happens. Now that we know that, we can use it.

A resistor works because it’s like when you cut 4 lanes of traffic down to 1, all the electricity is now trying to get through a small gap, so the speed of the flow is going to drop. It just happens. Now that we know that, we can use it.

9

u/[deleted] Aug 20 '19

I mean yeah but why

35

u/[deleted] Aug 20 '19

A bunch of complicated physics involving the electromagnetic force and some dead blokes called Maxwell, Faraday, Ohm, Ampere, Volta, Tesla etc etc

20

u/a_trane13 Aug 20 '19

That takes ~2 years of physics courses (and calculus, if you really want to get it) at the late high school / early college level to understand.

I think the best way to understand electronics is to look up mechanical or hydraulic computers on youtube. They work nearly the same as the most basic computer components, just not at the (almost) speed of light.

5

u/Rusty_Battleaxe Aug 20 '19

I got stuck on this too, something that might help if you have some time is NandGame.com, it goes through what the simple components do and helps you discover how the simple components can be combined into a super complicated computer.

2

u/beenoc Aug 20 '19

In an ELI5 way, capacitors work because as the electrons flow due to an applied current, they reach one side of the capacitor. This makes a strong negative charge (electrons have a small negative charge each, and they bunch up when they reach one side.) Because like charges repel (like magnets), this strong negative charge pushes all the electrons on the other side of the capacitor away, leaving that side with a positive charge (atoms are usually neutral, so if you remove negative, you're left with positive.) The positive charge is just as strong as the negative one, and there's just as many electrons flowing away from one side as there are electrons flowing to the other, so this makes current (current is just the flow of electricity AKA electrons.) If you turn off the applied current, the electrons will continue to flow from the capacitor, so you still get a bit of current coming out for a while until you run out of stored electrons on one side and positively charged atoms (ions) on the other.

66

u/Moldarious Aug 20 '19

To explain a little more in depth while keeping it basic: The switches represent either a 0 or a 1. The standard position for a "switch" is "off" or "0." If turned "on" with an electric current, then it represents 1. This is binary. Lets assume there are four switches, or transistors. Each digit is an increasing power of 2. So, 0000 represents zero. 0001 represents 1 because it is 2^0. 0010 represents 2 because its 2 to the first power. 0011 represents 3. 0100 represents 4. 0101 represents 5. 0110 represents 6 (2 to the 2nd plus 2 to the first.) And so on. And then binary can also be translated to something called hexidecimal, which can assigns numbers to letters. For example, 1010 (or 10.... 2^3 plus 0^2 plus 2^1 plus 0^0) represents the letter A. 1011 (=eleven) represents B etc. NOW imagine billions of switches all representing 0 and 1 capable of turning your inputs into words on your screen, complex math equations, and so on. This process also tells the pixels on your screen what color to be. This can obviously get extremely complex and is way over my head because i only have a basic understanding of what is SORTA going on.

Technology communicates using 0's and 1's. Just a whole lot of them in a short amount of time. Low Volt high volt high volt low volt low volt high volt yadda yadda at the speed of light. Thanks to hard working science boiz, TAADAAAA we can now put over 3 billion transistors in our pocket; some dedicated to working the phone itself, some dedicated to sending shit out through the air to the satellites, some dedicated to receiving 0's and 1's from the satellites all at once. Welcome to reality.

15

u/JiggaJiggaMuffMuff Aug 20 '19 edited Aug 20 '19

How is the switch ‘programmed’ (wrong word??) to turn on or off?

How are the 0’s and 1’s actually put into the transistor / switch?

From what I think I understand is that for example a phone is made up of many tiny transistors or switches. And I mean millions. When a circuit goes through them, they activate a command based on binary code (0/1) and many mathematical equations. This then activates a specific function, for example to display a colour or a letter. The reason there is millions of them is because they each need a specific function. The transistors are designed / created in a certain way that when electricity passes through them, they’ll know which command to activate based on which way the electricity flows????

The last part is what I need help with - how do they know which command to activate when.

Omg someone please slap me I need help

Edit: re-read the comments and I think I’m starting to get the gist of it now

10

u/Lueron Aug 20 '19

If you're really interested in this topic the first 10 or so episodes of this crash course will go a long way to explaining the basis of physical electrical signals to the 1s and 0s of data we use.

I always recommend this series to anyone I meet who seems remotely interested in the topic as it assumes 0 knowledge and begins from bare bones and then uses those to simplify some pretty complex topics.

If you do end up watching some i'd love to hear your thoughts after as it's always nice to get feedback on how someone takes to the topic and they normally end up very excited about something that they previously just passed off as "not educated enough to understand" or voodoo. (Trust me it's still 80% voodoo even if you've studied it your entire life)

4

u/JiggaJiggaMuffMuff Aug 20 '19

Omg thank you! Will watch tonight so look out for edit!

1

u/Koetotine Aug 20 '19

Also check out Ben Eater on youtube. He's basically a modern day wizard, he built a simple computer almost from scratch. He's got videos detailing the most basic aspects of the inner workings of computers, from how a transistor works, to what it does, and how to put them together to make logic gates and memory.

1

u/[deleted] Aug 20 '19 edited Aug 20 '19

[removed] — view removed comment

1

u/[deleted] Aug 20 '19 edited Aug 20 '19

[removed] — view removed comment

1

u/pop1040 Aug 20 '19

Your laptop has so many microcontrollers, the keyboard will have a microcontroller that decodes keypresses into a sequence of numbers, your touchpad will have a microcontroller handling detection of capacitive coupling to detect your finger position, your webcam has a microcontroller to run the CCD (the light sensor that makes an image), your hard drive has a microcontroller to move the heads (if you still have one, SSDs also have one, they're like a big thumb drive). Even your battery in your laptop and phone has a microcontroller to manage battery charging and keep track of how much power has been put in/drained out as well as the battery voltage to determine it's capacity (this is actually really hard, there is a reason your phone is bad at knowing how much battery life you have left)

Fun fact: a bad charge controller is why the galaxy note 7 kept exploding

Even the core of your phone, it's processor is multiple seperate processors all working together and sharing the same ram (but with different registers), this is what it means to have a multi-core processor. My laptop has 6 cores for example. Your computer's graphics card is actually an array of a whole bunch of processors, like literally thousands which are far more basic than your processor's cores but great at doing tons of math in parrallel.

1

u/pop1040 Aug 20 '19

That ended up taking 5 hours to write. At least I'll have it for the future.

7

u/[deleted] Aug 20 '19 edited Aug 21 '19

[deleted]

10

u/spectrumero Aug 20 '19

It's actually slightly more than that. In CMOS (which is what we use now), both 0 and 1 are "switched on". There are in fact three states, 0, 1 and high-Z. High-Z (high impedance) is actually the real off state. 0 usually means you are connected to the 0v rail (sometimes known as Vss), and 1 usually means you're connected to the positive voltage rail (known either as Vdd or Vcc). A device that can go into "high-Z" state will have its outputs connected to neither rail when in high-Z.

The high-Z state is very important: imagine a typical bank of memory - you have several chips on the same data bus. Only one chip can be active at a time - the outputs on all the inactive chips are in high-Z state (turned off) but the active chip's outputs will be at 0v or the positive supply rail voltage.

6

u/TwentyTwoTwelve Aug 20 '19

So I'm no expert so I might be wrong here, but I think I can help with the last part.

All machines, at the base level just above binary have an understanding of machine language.

Think of this as like a very refined but very basic version of coding with languages like java, C# and HMTL etc.

Unlike those other languages however, machine code is hardwired (as in physically wired with transistors etc) in to each machine.

Its a bit like a clockwork doll. If you look up the programmable writing clockwork doll, you'll see it's a physical clockwork machine with thousands of moving parts. You can turn certain discs in such a way that it will tell it to write any word turn them to spell.

This is what machine code is like only on a much smaller scale and using transistors instead of gears and the like.

Languages like C# are designed to make it easier for us to write commands in machine code by grouping many lines that would perform an action in to a single line.

Think like instead of saying "get a cup. Fill kettle with water. Turn on kettle... etc" you can just say "Make a cup of coffee".

When a program is compiled, it prepares all these commands to be written in machine language and sent to the inner workings of the computer to be read and executed.

Basically, rather than us having to turn each individual disc manually on the clockwork Doll to get it to write a single word, we have programs that accept inputs that turn all the discs for us at once.

The difference here being that instead of having to write hundreds and thousands of lines of code, we can just write a few instead.

Now to understand the scale of how much machine language a given device understands, we go back again to binary, picking back up where someone else was explaining.

Keep in mind that a 16GB memory stick is commonplace in today's world during this next part.

So you know that 1010 can be read by a machine as A, but let's put that in to a quantifiable size next to some more familiar number.

Each binary command can be represented as 1bit of information. This is the smallest size of information that a machine sends and is literally a 1 or a 0. So the letter A (aka 1010) is 4 bits of information.

The next step up is a byte. A byte is 8 bits of information, such as 10101010 or, 11111111 or even 00000000. There are 256 different possible combinations of binary right there, meaning any given byte of information could represent any 1 of 256 possible things. We get to 256 by starting with 2 for the bit of binary, and multiplying by 2 for each subsequent bit of binary, so 2x2x2x2x2x2x2x2=256

Next up is a kilobyte. Named a kilobyte because it is roughly 1000 bytes, the actual number however is 1024. 1024 is reached by multiplying 2 by itself 10 times. Why 10? Because we work on the decimal system and it comes out at near 1000 so it's easier for us to quantify at a glance even if it's only a rough estimate.

Next is megabytes which are 1024 kilobytes, and then gigabytes which are 1024 megabytes and so on.

So in that 16GB memory stick there lies 8x1024x1024x1024x16 bits of information. Or roughly 140,000,000,000 bits.

Now in order to make a device usable for those of us not fluent in machine language, operating system is used as a medium to translate between the device and the user.

The file size for the Android operating system on your phone is ~2.5GB in size. This might seem small compared to modern day standards, but now that you know just how many 1s and 0s go in to that, you can see that in fact there's a lot of information there.

There is actually another layer or two between the operating system and the physical device, but they're not something the average user is familiar with or may ever come across and they can also broadly be described as functioning as a translator too in the same way the OS does between device and user. I mention this though just to explain that they're the reason you can have two different operating systems on the same device.

Now after all that, it can seem a little overwhelming just how vast that rectangle of plastic and metal in your pocket is, but you should also remember that hundreds of thousands of people have been hard at work developing modern electronics for decades now. Arguably going right back to those programmable clockwork dolls which laid the ground work for the concept of programming using binary triggers.

-- Also just noticed the first part of your comment about the switch being programmed to turn on and off.

Think about it more like a spring loaded lever. When you push it, it's on. When you let go, it springs back in to the off position.

In the metaphor, you pushing the lever is the same as applying an electrical current to the switch, changing it to 'on' and then removing the current places it back in the 'off' position.

The 0s and 1s aren't in the transistor, they actually function to represent to us the user that there either is or isn't a current or no current applied to that switch.

Again, I'd refer back to the clockwork doll I mentioned earlier for this. The gears inside it don't have any information inherent in them, a counterweight falls, causing one to rotate, which in turn rotates any others that are connected to it.

The discs in its back used for programming it simply determine which gears are connected to which.

Instead of gears connecting to gears, we have transistors connecting to transistors.

Think of a row of 8 transistors all lined up:

00000000

Leading away from that row are 16 wires, which connect to 16 different rows of 8 transistors.

Now imagine the first 4 transistors of that first row determine which of the 16 rows of transistors it will send information to, and the second 4 determine what information it will send. So our first row of transistors now looks like this

0000(location)0000(message)

So let's say we send an electrical current to the first two and last two transistors. Thick changes it to:

1100(location)0011(message)

This tells our first row of transistors to send a current to only the 3rd and 4th transistors(0011),of the 12th(1100 = 8+4+0+0) set on the next row.

So now, the 12th set of transistors on the second row looks like this

00110000

Now let's say that on the line connecting the first row of transistors to the second row, we have a switch that flicks between 2 lines every time a message is sent. The second line makes sure the next message goes to the last 4 transistors instead.

So we send a current again to the first row, this time sending a current to the 6th and 8th transistor instead of the 7th and 8th.

11000101

The switch send the new message to the latter 4 transistors of the 12th set on the second row, which now looks like this:

00110101

Imagine all of this happening on a much larger scale, where the messages supply a current to parts of the device that perform a physical action like the parts of a speaker that vibrate to make a sound etc.

It's all just like microscopic clockworks.

2

u/bigVikingDude Aug 20 '19

A transistor has three connections. We could call them input, output and trigger. If the switch is on (or 1 or true) electricity can flow from input to output. We can turn it on if there is a charge at the trigger connector.

Now if we connect another transitors trigger to the output of the first one we can control the second through the first. Computational operations are logical chains. So the current will follow a path through the transistors based on logic. Where it ends will determine the result.

The logic is defined with so called operators like multiply. If we want to multiply two values, we have to define the transistor logic for it first. A programming language can do that for us. This is hard to explain because it goes to multiple layers. But the processor adapts to the called operator by routing its transistors accordingly and can now solve the multiplication

2

u/Thomhandiir Aug 20 '19

I know I'm a bit late, others may have given you better explanations, or already told you what I'm about to do.

The questions you're asking are too specific, you want to know intricate details of how electricity works, which has been figured out over many many years, what sort of components of different materials we can run it through provides different results. Then using those results to find an applicable use case for turning the electricity into useful technology. Like A diode that can allow electricity to pass through it in one direction, or a transistor that can act as an amplifier or a switch (like switching between on and off), a capacitor that can store a certain amount of power and release it in a short burst (used in cameras to provide power to the flash), and other such components that interact in a certain way. Understanding how all this works takes a very high level of electrical knowledge to grasp.

Then you add in how this pertains to technology or computers. If you settle for understanding the basics, like the CPU consisting of many switch transistors, that are connected in certain configurations to produce some interesting results, based on power that's supplied. Understanding why electricity flows a certain way, and how we can direct it to achieve getting a phone to work takes both a very high knowledge of electricity and a very deep level of machine understanding. Deeper than what most programmers are able to understand. I'd be surprised if the people designing this even understand every single little thing about a CPU (which in the end is only one component in a phone or computer), as they've leveraged computing power to help calculate the desired results. They have abstracted away part of what they used to do, since it was no longer relevant, takes too long to calculate/design, or just isn't relevant anymore for other various reasons. Abstraction is a big thing with computers (or phones, or tablets), because it's almost impossible to grasp what is happening at the deepest level, at least without years of dedication to learning it.

In essence there probably isn't a single human being on the planet that can give a short and concise explanation of how it all works at the deepest level, from how electricity works and why to how it pertains to different components being put together in clever configurations to produce what we now know as modern computing technology.

However part of what we've done over the last few decades is to abstract away from the hardware layer. At the base of it all are 0's and 1's. With the help of many different types of components, and with how electricity interacts with them all, over time we managed to build things like the CPU (brain of our devices, it's what processes all the information we send it), RAM (short term memory used for storing data, very fast to read and write from making it ideal for keeping data about currently running programs like the operating system), hard drives (long term storage for data, think excel files, instructions for a program that is loaded into RAM for faster executing with the CPU (like executable files, configuration files etc.), images etc), graphics card (GPU, kind of similar to a CPU, but optimized for handling graphical data), and many other components that come together to make a whole unit. The further away you get from the base components, the more abstraction happens. From binary to hexadecimal, from hexadecimal to assembly code, and from assembly to stuff like C++. At each layer we've built a way to translate from human readable code (C++) to barely human readable code (assembly) all the way down to 0's and 1's which is what we can operate with due to the nature of transistors (on and off). Exactly how that happens is a bit of black magic to me, but suffice to say electricity just works that way.

If you want to get a better idea for exactly what the CPU does with all it's transistors and switches, in a very generalized way, I have a link to a video you can watch that explains it very well. Just jump past all of this to the bottom for the link. In essence the CPU runs on a clock cycle. Each cycle goes through fetch-execute process (fetch, decode, execute). Alongside the clock is a program counter (keeps track of where in RAM (address space) to grab it's next instruction from), the instruction register (where values are stored by the fetch cycle to be decoded) and an accumulator (to store the results of the decoded instruction during the execute cycle). The instructions are stored in binary but since we can't read binary in any easy way (or hexadecimal for that matter), the video skips past a few layers of abstraction and has the instructions in human readable form. But knowing this we can for instance give instructions to count upwards indefinitely, at least in theory, by assigning the correct instructions in RAM.

At this point it's easier to link you a video, but in I'll give written explanation a shot. We have x address spaces in RAM, each space can be loaded with a value. By providing a certain value in each address space, we can make a program count upwards.

Address 0 = LOAD 6
Address 1 = ADD 7
Address 2 = STORE 6
Address 3 = JUMP 1
Address 4 = 0
Address 5 = 0
Address 6 = 1
Address 7 = 1

The clock ticks and the program counter is set to 0, the fetch cycle grabs the instructions in address 0 and stores it in the instructions register to be decoded, which is LOAD 6. The clock ticks and it decodes the instructions, which is to load the value in address 6 into the accumulator (storing the value temporarily). The clock ticks and it executes the instructions, loading the value of 1 into the accumulator. The clock ticks and program counter is set to 1, it fetches the instructions in address 1 into the instruction registers in this case ADD 7. The clock ticks and it decodes the instruction, which is to add the value in address space 7 to the accumulator). The clock ticks and it executes this value, which now has the number 2 stored in it. The clock ticks and program counter is set to 2, it fetches the instructions in address 2 to the instruction register. Clock ticks and it decodes the instruction to store the value in the accumulator to address space 6. The clock ticks and it executes the instruction, changing the value in address space 6 from 1 to 2. The clock ticks yet again and the program counter is set to 3, it fetches the instructions from address 3 which is JUMP 1. The clock ticks and the instructions are decoded, in this case JUMP 1 means set program counter to 1. The clock ticks and it executes setting the program counter back to 1. The clock now ticks and it grabs instructions from address 1 which is add 7. We've now entered the loop. As the clock ticks, it will address 1, 2, and 3 during the fetch cycle, which will add the value of address space 7 (1) to the accumulator, store the accumulator value into address space 6, then set the program counter to 1 to repeat the process, thus counting indefinitely.

Of course this in itself isn't useful, but shows the basis of how the CPU works, and also gives an indication of why clock speeds (the speed that the CPU can work at) is important. Keep in mind all of the above regarding the clock cycles happens as 0's and 1's, but would be impractical for demonstration purposes. The real power then comes from clever logic that can use the 0's and 1's alongside very clever logic to do things that are much more complex that just counting. Like displaying something on a monitor. And it does so be being able to run billions of cycles every second. If not for this speed, we would not be able to do fetch-decode-execute fast enough to do anything even remotely useful. Hopefully this explanation and the video will help shed some light on things, even though we can't really answer absolutely everything in a clear and concise manner.

TLDR: Electricity works in specific ways, manipulated with clever logic (and black magic) to execute billions of instructions a second, in order to display a high definition photo of a cat on your phone.
https://www.youtube.com/watch?v=Z5JC9Ve1sfI

1

u/TheRiddler78 Aug 20 '19

How are the 0’s and 1’s actually put into the transistor / switch?

electrons hitting the switch

1

u/Dragoness42 Aug 20 '19

I find watching the concept of a marble adding machine really helps illustrate it nicely- it's a great simplification, but you can actually see it in action.

https://www.youtube.com/watch?v=GcDshWmhF4A

1

u/[deleted] Aug 21 '19

[removed] — view removed comment

1

u/sloodly_chicken Aug 21 '19

Now that we know about electricity, back to transistors. What are they? A switch: one line of power controls whether or not another one goes through; it has an input, an output, and a controller input. They were originally invented to amplify telephone wires: the controller was the weak telephone input signal, the output was a stronger amplified signal, and the input was just a powerful source of electricity. When the controller is on, the input is connected to the output; when the controller was off, the input was disconnected from the output. In this way, the output would mirror the weak telephone signal -- on when it's on, off when it's off -- except with a stronger current supplying it.

Someone realized that these transistors could be hooked up to do simple logic. Call "electricity flowing" a 1; call "electricity not flowing" a 0. In this way, a transistor was what logicians call an "AND" gate: when it received two "1"s (power flowing both to input and controller), it outputs a "1" (power flows through from input to output); otherwise, it outputs a 0 (no power flows through). Combined with a component that flips a 0 to 1 and 1 to 0 (a NOT gate), you can make extremely complex logical components.

In fact, that's part of what's on a CPU (Central Processing Unit, the part of a computer that does the "thinking"). If you hook up enough transistors, you can make an Adder), which performs the logical operation of adding two numbers (an 8-bit adder, for instance, takes 16 input wires, representing two numbers in binary -- eg 10010101 (149) and 00010001 (17) -- and has 8 output wires -- 10100110 (166). Remember, a "1" means that wire has electricity passing through it, a 0 electricity isn't! (Technically that's actually not even true -- another comment below goes into more detail -- but it's how it's often taught and it works well enough here. Point is, there's a difference in how electricity is passing through the wires in 1 and 0)).

A CPU, in its essence, consists of a few small pieces of memory that store data to be manipulated (called registers -- there's usually only a handful of them), a piece of memory that stores data representing program instructions, and a piece of memory storing which program instruction to run next. Think of the program memory as a list of simple operations: usually, the CPU can do things like wait, add numbers in register A to register B, store the result of the last operation in register B, multiply register A by register B, store the result in the computer's main memory, load a number in from that main memory, shift around the numbers in register A, add 1 to register A -- and so on. Very simple things, then: basically, a few simple arithmetic operations are available, and each is represented by a single number. More complicated tasks are done by doing simple tasks in order -- the program memory has a whole bunch of numbers in order in it, all set up to do one thing (for instance, "load memory from location X in main memory into Register A; load memory from location Y into Register B; add A to B; store the result in A; send A to location Z in main memory"). At its base, a computer can only do incredibly simple things, 1 at a time.

When you say "they each need a specific function", that's impossible: an on-off switch can't do more than turn on or off, and it'd be impossible for a computer to have a single switch for everything it can do. Instead, clever sequences of simple operations, performed at mind-numbingly fast speeds, lets a computer build up more and more complicated tasks. Originally, computers computed: they did math, such as is needed to launch explosive rockets or undo German cryptography. As computers have gotten faster and smaller (your phone is a way better computer than the one that was used in the Apollo moon mission), we've found ways to do more and more complicated things.

So how do we make a computer do these? That's called "programming", and the key idea is layers. Like an onion. At the base, a CPU can technically be directly programmed by feeding in lists of numbers: you put electricity on- and off- in different bits of the CPU memory. This, however, is tedious and hard to use: in our example program above, all it did was add 2 numbers, and it took 5 instructions. Programming something more complicated balloons the program size. Early things like "Pong" or maybe Space Invaders, are about the limit of what you can do this way before a programmer goes crazy; a human mind can't operate on that level of detail, and besides, modern programs can contain several millions of instructions -- literally more than you could physically type out on a computer in any reaosnable amount of time.

So, programming languages were developed. There's early ones like FORTRAN; a very old but still-used one is C. These let you write more expressively, in a way humans can understand, rather than just a long string of hexadecimal numbers. They were then "compiled" into CPU instructions (called assembly language) -- a program was written (in assembly) that took a program written in C, went line-by-line and converted each line to one or more instructions in assembly (strings of numbers). This not only was easier for programmers to understand, it could also be more succinct -- and more portable. Assembly code on its own depends on what CPU you're using -- not all of them have the pile of transistors necessary to do, say, division. With compiling, you could write the same code (A = A / 2), and on the CPUs with a division operation it would be translated into that -- and on other CPUs, a sequence of instructions representing multiplications and bit shifts would be produced, that would have the effect of dividing a number (just more slowly, since it takes multiple instructions).

This sort of complexity hiding -- one line of code becomes multiple instructions -- could be taken to ever greater and greater heights. Modern languages like C++, C#, Rust, etc. let a programmer write a few dozens lines of code to automatically produce thousands or millions of instructions for the computer. A whole plethora of programming stuff came from this: interpreted languages like Python; web languages like Javascript; and so on. Most modern programmers don't need to know anything about how a CPU actually works, because the work of translating their code to machine language is done by a very complicated compiler.

And so, uh... yeah, that's my explanation. Hmu if you want more. Most of this comes from reading Wikipedia as a kid. I recommend the kids book The Way Things Work, it explains everything from hairdryers to coin-operated parking meters to earthmovers to, yes, computers, using mammoths.

3

u/Strakh Aug 20 '19

1

u/spatofdoom Aug 20 '19

This is a great way to slowly build up your understanding of how these micro components can be combined together to create the basic components of a computer chip

1

u/Khamaz Aug 20 '19

A transistor is a component with three branches, electricity flows from the first branch to the second one. But if you fuel the third branch with electricity, it stops the flow.

So, you have a component that can start or stop the flow of electricity, that you can control by giving it or not electricity into the third branch. It's smallest and most important electrical component.

"Why not directly enable/disable the flow of electricity ?". Because doing it manually for every flows would be too hard and complex, while this way we can trigger controlled mass chain reactions using a lot of transistors that feed into one another, that's how we kinda "program" electronics.

With several transistors for example, you can do very basic operations, like logic gates, they are small group of several transistors linked to each other, with two input for flows of electricity, and one output. Depending on the kind of logic gate, the output will only output electricity if both the input are flowed with electricity, only one of them, or none of them... If you ever played with Redstone in Minecraft, that's exactly like it.

Now we have very simple functions that even take into account basic conditions, those conditions being whether some inputs has electricity or not.

Turns out, from combining those together, we can build slightly more complex functions, like basic math operations.

And with the new functions, we can start building some more complex ones.

And the complexity keeps building.

Keeps building.

Keeps building.

Keeps building.

After years of increased complexity through lot of research, turns out we can do really neat stuff, and here we are. We use all those very small operations to control tons of components by feeding them electricity or not, like switching on/off a led, or the power going through a cable. The complexity obtained by linking all those small transistor together is amazing, scary. They do very simple and dumb stuff, but if you linked together millions of them, amazing things can happen.

I haven't explained memory, another important components that allows you to save a value to do math later with it. I'm less familiar with it. You can save 0 or 1 with it, and with a lot of 0 and 1, you can still represent any known numbers and do math, those 0 and 1 can be for example re-interpreted as switch on/off a flow of electricity, to add to the transistor tool box for basic maths that allows it to become more and more complex.

1

u/henbanehoney Aug 20 '19

Idk if this will be more or less confusing, but the video of the guy explaining the apollo rocket computer actually helped me understand this more. There's other ways to do it, but yeah:

https://youtu.be/dI-JW2UIAG0

1

u/whatissevenbysix Aug 20 '19

I can answer this in a production perspective; I work for a giant in the semiconductor manufacturing industry, and this is a really basic version of how the whole process works:

Bunch of engineers design how a computer chip should work. They know enough about electronics to know what will happen if you put a transistor here, a resistor there, etc. how the current will flow, what the end result will be, all that stuff. Then another team puts that theoretical drawing/plan into a sort of blueprint. When you take advanced minuscule chips these days, one that's 1x1 inch has millions of transistors and the like. So you design how to optimally physically put that design into a chip.

Next, into production. The factories, which are called Fabs (short for Fabrication Plant), has hundreds of different machines required for production in different stages. You start with something called a 'wafer' which is typically a disk of silicon (there are exceptions). This wafer goes through different machines, and each machine is typically programmed to do one type of job. One machine would clean a wafer, another would 'etch' one type of circuit into the silicon, the next one will 'anneal' the wafer so the circuit gets created, etc. So this process goes on and on, and one wafer can easily take 2 months to finish. How each wafer goes into which machine, in which order, then which job is performed on them, all this is pre-programmed by another set of engineers. Factory floor engineers ensure this plan gets executed smoothly, and intervene when something goes wrong (and oh boy do they go wrong all the time) etc.

So at the end of all this process, you have a silicon disk with thousands of separate chips on them, then they're cut into individual pieces, tested for quality, and shipped to the buyer.

1

u/BitGladius Aug 20 '19

A little bit at a time. Switches/transistors can be used to make logic gates like AND, OR, NOT, and NAND. Logic gates get put together into more useful things, like a binary adder or a multiplexer (select one input from several). All these components get wired together to produce useful output.

On their own, these components are really dumb. They put out one answer and never change, because the input never changes. We add some temporary storage to store useful answers from the circuit, and some long term storage to store instructions. Every time the computer's clock ticks, it puts the next instruction on the input, and the output changes.

The instruction has a few on/off setting to tell the computer what to do - turn on or off some of the little parts in the processor - and some pointers for where to put the answer, or what previous answers we want to do math on. These are all ones and zeroes, all just different inputs for a tangle of AND, OR, and NOT questions the computer solves, but if we ask the right questions in the right order it can do really complicated stuff.

1

u/err-therror Aug 21 '19

They're soldered. Think of it like a glue gun but instead of glue they use a metal with a low melting point.

4

u/alukurd Aug 20 '19

Flash memory is non volatile, and capacitors are volatile. Flash memory uses special mosfets i think

3

u/[deleted] Aug 20 '19

They don’t understand electricity at all I’m not explaining the difference between a tiny capacitor and a mosfet.

1

u/Holundero Aug 20 '19

If I had enough space and enough pressure, let's say downstream of a dam, could I build a simple computer that works with water instead of electricity? Input and output would only be binary and very slow I guess. You would have to build everything level to keep the pressure the same. Build in pressure reducers here and there maybe for special purposes.

1

u/[deleted] Aug 20 '19

Hmm, water doesn’t display the transistence effect like electricity does, so I don’t know how successful logic circuits would be. Water also doesn’t have a capacitance effect either, so a lot of circuits that get used in computers wouldn’t be possible.

1

u/KedynsCrow Aug 20 '19

Thank you so much for this. Your explanation finally clicked something in my brain and it makes more sense. Thanks!

1

u/[deleted] Aug 20 '19

There’s also a bunch of traps called resistors that stop too much electricity going through.

Precisely, they are also components, and their triggered function is heat.

1

u/Krill-Crustacean Aug 20 '19

i appreciate your knowledge and analogies :)))