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

A computer’s brain, the central processing unit (CPU), is a machine that can perform a limited number of operations. Collectively these operations are called “machine code” and include things like reading from and writing to memory (RAM), adding or subtracting numbers, comparing numbers to see if they’re equal, and running instructions from a particular place in memory.

For example, a simple CPU might read instructions from memory and map instruction number 1 to the add operation, number 2 to subtraction, number 3 to comparing two numbers, and number 4 to branch / run future instructions based on the results of a comparison. Since raw numbers don’t mean very much to humans, we assign names to the operations to make them easier to read. This is called “assembly code” and typically you’ll see operations like MOV, ADD, SUB, BRA.

Writing programs in assembly code is still pretty tedious, so some smart people came up with newer languages that are more readable to humans along with a special program called a compiler to convert the human-readable text into machine code. That way programmers can use familiar mathematical notation like `let x = 10` or `let y = x + z` rather than several lines of assembly code.

It’s important to note that the computer doesn’t really understand anything like a sentient being. It simply performs whatever operations are fed into it very quickly. Everything builds from that premise.

One of my favorite professors walked into my Digital Logic class the first day carrying a 5 pound metal object called a “flip flop”, an early form of computer storage. He slammed it on the desk to get our attention. “This is a flip flop”, he said. “It stores one bit of information.” He then took a tiny CPU out of his breast pocket. “This is a Motorola 68000,” he continued. “It contains 30,000 flip flops. We’re going to learn how it works.” And we did.

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