Lesson 2 +10 XP

How Computers Understand Programs

How Computers Understand Programs

Before writing C code, it helps to understand what happens inside the machine.

What is a program?

A program is a set of instructions the computer follows, one after another, to do something useful.

The CPU understands machine code

The processor (CPU) only understands machine code: patterns of 1s and 0s called bits. English, C, and everything else need translation.

High-level vs low-level

  • High-level languages (like C): use words people can read. Easier and more portable.
  • Low-level languages (like assembly): close to hardware, harder, but give total control.

C sits interestingly: it is high-level enough to be readable, yet low-level enough to touch memory directly.

Source code

The text you type in an editor is called source code. It is the human-readable version that a tool called a compiler must translate before the machine can run it.

Why do we need programming languages?

Humans and CPUs speak different languages. A programming language is the bridge: we write friendly words, and build tools turn them into the bits the CPU understands.

TL;DR

  • A program is a list of instructions.
  • The CPU only reads machine code (1s and 0s).
  • High-level languages are human-friendly; low-level ones sit close to the machine.
  • You write source code; the compiler turns it into instructions.