Topic 15

From Code to a Running Program

Concept

Code, as the last two topics showed, is text a person wrote — a list of instructions in some programming language. A program, on the other hand, is something the computer actually runs. Those are not the same thing, and getting from one to the other takes a step that is easy to miss.

The gap is real: a computer can't run human-written text directly. The instructions have to be translated into something the machine itself can carry out. That translation happens in one of two common styles, and knowing which one a tool uses explains a surprising amount of everyday tech behavior.

From code to a running program
Source codetext you wrote
Translatecompile or interpret
Running programit does its job

Why a translation step is needed at all

The CPU — the part of the computer that does the actual work — understands only its own very simple set of instructions, made of numbers. Human-written code, even when it reads almost like English, means nothing to it. Something has to stand in the middle and convert one into the other.

That converting is the whole subject of this topic. There are two long-standing ways to do it, and they differ mainly in when the translation happens: all at once, before the program runs, or bit by bit, while it runs.

Compiling: translate the whole thing first

In the first style, called compiling, a tool reads all of your code at once and translates it into a finished, runnable file before anyone runs it. That step is the "build." Once it's done, you have a program the machine can run on its own, with the original code no longer needed to start it.

Think of a book translated from one language to another. A translator works through the whole book once, and afterward anyone can pick up the translated copy and read it freely, as fast as they like, without the translator in the room. Compiling is that up-front translation: do the work once, then run the result as often as you want.

The trade-off is that you pay the translation cost before the program can run, and you have to redo it whenever you change the code. In return, the finished program tends to start fast and run fast, because all the translating is already behind it.

Interpreting: translate while it runs

The second style, called interpreting, skips the up-front build. Instead, a tool called an interpreter reads your code and translates it line by line, on the spot, every time the program runs. There's no separate finished file — the original code is what runs, with the interpreter doing the translation as it goes.

This is the live interpreter at a meeting, rather than the translated book: someone listens to each sentence and renders it into the other language right then, every time the meeting happens. Nothing is prepared in advance, which is convenient, but the translating work is repeated on each run.

So an interpreted program usually starts without a build step and is quick to change and try, but it carries the translation cost every time it runs, which tends to make it a little slower than a compiled one. This is the simplified picture — real tools blur the line, and the deep-dive language courses fill in the rest.

Why this matters to you

The split explains why some programs arrive as a single file you just open, while others need extra tools installed before they'll run. A compiled program often ships as that one ready-to-run file; an interpreted one needs its interpreter present on the machine to translate the code each time.

It also explains the word "build," which turns up constantly later. When you hear that software was "built," or that a Docker image is "built," that's this compile-style translation step producing a runnable result ahead of time — the same idea you've just met, under a name you'll see everywhere.

Common Confusions
  • "The computer runs my code exactly as I wrote it." It can't — your written code is first translated into instructions the CPU understands, either ahead of time or as it runs.
  • "Compiling and interpreting are just two words for the same thing." They differ in timing: compiling translates everything up front into a runnable file; interpreting translates line by line each time the program runs.
  • "The source file is the app I downloaded." For compiled programs, what you download is the translated, runnable result — the original source code stays with whoever wrote it.
  • "Interpreted means slower, so it's worse." Slower per run, often — but skipping the build makes it quicker to change and try. Each style trades one thing for another.
Why It Matters
  • The word "build," which you'll meet in Git, CI, and Docker, is this ahead-of-time translation step producing a runnable result.
  • It explains why a Docker image is "built" before it can run, and why building again is needed after the code changes.
  • It's why some programs install as one self-contained file while others ask you to install a separate tool first.
  • Knowing compile-time happens once but run-time happens every time is the start of reasoning about why software feels fast or slow.

Knowledge Check

Why does written code need a translation step before it can run?

  • The CPU only understands its own simple instructions, not the human-written text
  • Written code is encrypted and the translation step is what decrypts it for safety
  • The step exists mainly to find and remove every mistake in the code automatically
  • It is only needed on slow computers; fast machines can run the text directly

What is the main difference between compiling and interpreting?

  • Compiling translates the whole program ahead of time; interpreting translates it as it runs
  • Interpreting translates everything ahead of time; compiling translates each line during the run
  • Compiling produces a working program, while interpreting only checks the code for errors
  • Compiling is used for one language and interpreting for a completely different one

A program was compiled into a single finished file. Why can you often run it without installing extra tools?

  • The translation was already done during the build, so the file is ready to run on its own
  • The file quietly contains a whole interpreter that translates its code over again on every single run
  • Compiled files are so small that the computer can skip translating them entirely
  • It still runs the original source code, which every computer understands by default

You got correct