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

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

The computer’s built so that coded patterns of 1’s and 0’s physically open / close different paths for electricity, to make it do different things. These coded patterns are called “machine code.”

The details of exactly what patterns are available, and what they mean, can be different for different models, brands, or kinds of computers. A CPU manufacturer typically publishes a manual with a complete specification of the patterns.

Working directly with the coded patterns the computer actually uses is inconvenient for human programmers. It would also be more efficient if the same program could be used on multiple models / brands / kinds of computers.

So people created programs (compilers, interpreters, shells, JIT’s) that allow the computer to “understand” English-like commands. This involves a “translation” process, sort of like translating from German to Italian. (Except the computer is, well, a computer, so it expects programmers to use perfect spelling and grammar, but will happily translate a buggy or completely nonsensical program as long as it’s grammatically correct.) It can be done in a few ways:

– A compiler works like translating a novel. A long program’s translated all at once, then the result’s saved in a file that the computer can run.
– An interpreter analyzes one “sentence” (line of code) at a time, runs that one, then moves on to the next. Sort of like translating a novel out loud as you read it.
– A shell lets you type a line of code, immediately runs it, then shows you the result. Sort of like when a businessman or government official goes to a foreign country, they might bring a human translator who translates each sentence immediately when they say it.

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