How does coding physically work?

126 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

Harvard’s CS50 is available free on YouTube and openEdX.

The first video/class in that series does a great job explaining this question including some demos of how binary code works. I highly recommend watching it even if you stop after that first video.

Anonymous 0 Comments

Coding from the human perspective is using some language different from our own to give instructions to the computer. We need programming languages because the computer is a machine and must receive instructions in a *very* specific way.

Computers are built by exploiting a few key things.

Firstly, transistors. (It’s possibly to build computers from the precursors to transistors, but they are large and slow and have little memory or processing power.) A transistor is a special circuit device that acts much like the way a water spigot or valve works: if you turn a handle on a valve, you can open or close the valve, allowing water to flow, or not. A transistor does the same with electrical current, and you can control that flow by using electricity as well.

Secondly, some kind of pre-wired circuit with “memory” of some kind. You need a physical location for every piece of information, the smallest unit being called a “bit.”

Thirdly, binary language. 1s and 0s.

A “bit” is either a “1” or a “0”. That’s all it can be. Physically a “1” is a “high” voltage stored in a memory location, while a “0” corresponds to a “low” voltage. High voltage is usually 1V or less with 0V being low, though you can design circuits for those voltages to be whatever you like, if you wanted to. Using transistors, you can then design circuits that will behave differently if they are provided different inputs.

So if you have two different bits, and you want to see if ***BOTH*** of them are a “1”, you can send them into a logic gate (a special transistor circuit) called an AND gate. If both of the memory locations have a “1,” then it will provide an output of “1,” otherwise it will provide a “0.” Now you’ve created a very simply logical circuit.

This is one way to think of the basic building blocks for a computer.

The purpose of programming languages is to translate our user-inputs, keyboard strokes, mouse clicks, and the display on the screen, all down to a very well-defined and ordered sequence of 1s and 0s which have special circuits already designed on the chip for the computer to do things with, like that simple AND gate test I described above, although obviously there is a great deal more complexity.