How does coding physically work?

527 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

The computer can only execute a list of binary instructions. Imagine it like this:

The computer has a bunch of circuits for calculations. A circuit to add two binary numbers, a circuit to multiply two binary numbers, etc. It also has a memory circuit where binary numbers can be stored and retrieved again. All these circuits are connected to each other with switches. Imagine it like switches in a railway, by putting in the correct control signals, the correct circuits are connected to each other in a specific way to e.g. get a number from memory, perform a calculation and store it back into memory.

The control signals are coordinated by a control unit. That unit reads instruction by instruction (an instruction is also just a binary number, but with an assigned special meaning. E g. One number could mean “add two numbers”) from memory and translates it into the correct control signals for the switches. So with the correct order of binary instructions in memory you can tell the computer to do anything you like and the computer executes all of this by switching together the correct circuits.

You could program a computer just by directly putting in those binary numbers as instructions. This is what was done in the earliest days of computers.But that is of course not very easy. The coding you see nowadays with text files is just a convenience for humans to understand the code better. Humans can read text well, but computers cannot directly understand code in a programming language.

Therefore computer scientists developed programs like compilers or interpreters that translate text to binary instructions. They literally go through the text character by character to detect what each line is supposed to mean and translate it to binary instructions that can then be executed like described above.

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