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

1.25K 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

Read this all in Jeff Goldblum’s voice, because I’m watching his stupid Disney documentary so that’s how I wrote all this. I think it will be the most fun but accurate to read without being overwhelming out of these answers. If English is not your first language, let me know and I can post it again but more simple and still fun.

Good lord, there seems to be a bunch of computer scientists in here. These answers are generally all right but I don’t think they get down far enough to the physical level of what you’re wondering. You’re asking for bottom up but you’re getting top down. Electrical guy here. I’m not a very good electrical engineer but I would be worth dogshit if I couldn’t explain how we get from atoms to Youtube videos. My electronics professor loved to say “digital is just a special case of analog”. So with that in mind:

The basic building block of all electrical circuits is the **transistor**. If you hear about “tubes” with old electronics, originally transistors used to be giant glass tubes with the air sucked out. Today we have **MOSFETs** — Metal Oxide Silicon Field Effect Transistor. You don’t need to know what it means, it’s just fun to know, like knowing what DNA stands for.

MOSFETs are tiny tiny tiny microscopic pieces of silicon and other stuff. Very very complex. Centuries of engineering and math and physics and chemistry and quantum mechanics and manufacturing and ingenuity have all led up to it. It has to do with molecules with too many electrons, and molecules with not enough electrons, and then building a sort of, I guess, cake out of them. Layers and pieces constructed just right to do what you want at a microscopic level so electrons move as you guide them.

The entire modern world is made of these, built on clever tricks by an Egyptian and Korean American scientist at AT&T’s Bell Labs in just 1959. Not that long ago really, Hayao Miyazaki and Bernie Sanders wouldve been 18 around then. What’s nice is that these guys (the scientists, not Miyazaki) had never worked with this stuff before but quickly gained a knack and somehow solved problems scientists could only dream of. Never underestimate a fresh pair of eyes. Look up Heaviside or Ramanujan when you get the chance.

A transistor is a switch, but instead of needing to press or flip it physically you apply a voltage, which is like water pressure for electricity. You use electricity to control electricity. Think of it like a stop light. It’s actually almost exactly like a stop light. You make the light red (low voltage), traffic stops. That’s a “0” (cutoff for the MOSFET). You make the light green (high voltage) and traffic goes. That’s a “1” (saturation for the MOSFET). Yellow light puts the MOSFET in linear mode, which has its use, but not for computers so we’ll skip it. Pretend they’re the cars from the Bee Movie, they stop and start perfectly. It’s a metaphor whatever.

Now it turns out, you can hook up a few transistors together and make some neat logic happen, what we call Boolean logic. Like okay, traffic can only go if this light is green AND this light is green. We’re not thinking in voltages and currents anymore, we’re thinking in 1’s and 0’s already.

Let’s go further, more abstract. If you get a 0 here, a 1 there, we want this to happen. Or a 0 here and then a 1 at the same light and then another 1 and another 1 but then a 0, we want this specific thing to happen.

You can use this idea to build simple blocks, like addition and subtraction. Soon multiplication, or shifting various things. You put all this functionality into something called an **ALU. Arithmetic Logic Unit**. You have to store the numbers for it to use somewhere so that we can do more than one calculation at a time. You build memory, which is transistors feeding themselves so they stay put. You devise a system so you say okay if this is 1 and this is 0, that means add the numbers. Which numbers? Oh well check these switches, if it’s 111, pull it from here, if it’s 110 pull it from here. That is called **machine language**.

We don’t want to keep saying 1’s and 0’s. What a pain. What if we could assign a mnemonic to each operation? Shorthand for what you want it to do, what you want it to be done to, and where to put it after? That is called **assembly**.

Soon machine language also became a pain. We’re still dealing with circuits and transistors without saying we are. We’re fooling ourselves. We’re babbling. Instead of instructing word by word, let’s make sentences. Why not? Or hell, pictures. We’ll make a dictionary for a language we speak (English of course because much of this is built on work by Americans and British, sorry), and a manual that says how to use the dictionary. That dictionary is a **programming language**, and that manual is a **compiler**. You build an **operating system** that handles stuff like talking to the CPU directly and moving memory around so you can focus on higher level apps like a video game.

And now, we are where you are. Writing programs in a language using words from that dictionary. But in the end you’re applying voltages to create conductive channels on a photolithography substrate. The words you type make trillions of molecules move *exactly* the way you specified at literally light speed without ever needing to think of them, so someone can send a funny joke to their friend.

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