Skip to content

What Is Code?

Understand what source code is, how it differs from machine code, and why we use programming languages.

What you'll learn

  • What source code is and what it looks like
  • The difference between source code and machine code
  • Why humans invented programming languages
  • How a compiler or interpreter turns code into action

Concept

What Is Code?

Code (or source code) is the text a programmer writes. It is a list of instructions written in a programming language — a precise, unambiguous language that both humans and computers can work with.

Source Code vs. Machine Code

A CPU only understands machine code — raw binary numbers like 01101000 10111000. Writing programs directly in binary is nearly impossible for humans. So we write source code in a readable language like JavaScript or Python, and a tool translates it into machine code for us.

  • Source code — human-readable text (what you write).
  • Machine code — binary instructions the CPU executes.

Compilers and Interpreters

Two kinds of tools perform the translation:

  • A compiler reads your whole program and converts it into machine code *before* it runs. C, Rust, and Go are compiled.
  • An interpreter reads and runs your program line by line while it executes. JavaScript and Python are interpreted.

The end result is the same: your instructions become actions. The difference is *when* the translation happens.

Why Many Languages?

Different languages are optimized for different goals. Python prioritizes readability; C prioritizes speed; JavaScript runs in every browser. The concepts you learn in this course — variables, loops, functions — exist in nearly every language, so once you learn them, you can switch languages with ease.

Example

              // Source code (what you write):
const score = 95;
if (score >= 90) {
  console.log("Grade: A");
}

// The interpreter reads this line by line:
// 1. Create a variable named score with value 95
// 2. Check: is 95 >= 90? Yes.
// 3. Print "Grade: A" to the console
            

The comments describe how the interpreter processes each line. The computer never sees the comments — they exist only to help humans read the code.

Try it

  • Case Converter

    A real tool built from source code. It takes text (input), applies a transformation (process), and returns converted text (output).

Common mistakes

The mistake

Confusing source code with machine code.

The fix

Source code is the human-readable text you write. Machine code is the binary the CPU runs. A compiler/interpreter bridges the two.

The mistake

Thinking one language is 'the best'.

The fix

Languages are tools for different jobs. Learn the concepts first — they transfer between languages easily.

Related Cheatsheets

Look up unfamiliar terms

A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.

View glossary

Build real projects

Apply what you learned by building guided projects with starter code and solutions.

View projects

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors