MyLeoNes™

Compilation — Computing, 11–13

People write programs in languages designed for humans, while processors need much more precise instructions. A compiler translates the first into another form that the computer can run or prepare to run.

From code to a runnable program

When you write code, you are giving instructions in a language made to be readable by people. Compilation changes that text into lower-level instructions, checks some rules, and produces something the computer can use.

Why translate code

Processors are fast but unforgiving: a small ambiguity can stop an instruction from working. Human-friendly languages let you name ideas and organise a solution, while compilation builds the exact form needed by a particular computer or system.

A tiny translation

Suppose you write `score = 2 + 3`. The compiler checks that the names and symbols are allowed, works out that the addition gives 5, and creates instructions for storing that result; if you write an unknown symbol, it reports an error instead.

Compilation is not proofreading everything

It is reasonable to expect a program that compiles to be correct, because the compiler has already rejected some mistakes. But it mainly checks whether the code follows the language’s rules; it cannot know that you meant 5 instead of 50.

Why some errors appear before running

When an app or game is built, compilation can catch missing punctuation, unknown names, and other rule-breaking code before anyone opens it. This saves time, though the finished program still needs tests for mistakes in its behaviour.

Keep exploring

Other languages

Loading MyLeoNes™…