What is Programming?
Writing precise instructions that a computer can follow to solve a problem.
What is it?
A computer is very fast and very literal. It can't guess what you mean. It only does exactly what it's told, one small step at a time.
Programming is writing those steps down. You break a problem into tiny, unambiguous instructions ("add these two numbers", "if the list is empty, stop", "repeat this for every line in the file") in a form the computer can run.
A few words you'll see everywhere:
- Algorithm: a step-by-step method for solving a problem, independent of any language. "To find the largest number, look at each one and remember the biggest seen so far" is an algorithm. - Program: an algorithm (usually many of them) written in a programming language so a computer can actually run it. - Programming language: a strict, small language with exact rules (Python, JavaScript, C, Java, Go…). Each one trades off ease of writing, speed and safety differently, but they all express the same basic ideas: values, variables, decisions, repetition and functions. - Source code: the text of a program as a human writes it.
What a programmer actually does is mostly not typing. It's understanding a problem, deciding what the program should do, splitting the work into small pieces, writing and reading code, testing it, finding bugs, and changing code that already exists. Reading code is a bigger part of the job than writing it.
Explain like I'm 10
Programming is like writing a recipe for someone who has never cooked and takes every word literally. "Add salt" isn't enough. You have to say how much, when, and what to do if the salt is missing.
Examples
An algorithm, then a program
# Algorithm (in plain words):
# 1. Remember the first number as the largest so far.
# 2. Look at each remaining number.
# 3. If it is bigger than the largest so far, remember it instead.
# 4. When there are no numbers left, the remembered one is the answer.
numbers = [4, 17, 9, 23, 8]
largest = numbers[0]
for number in numbers[1:]:
if number > largest:
largest = number
print(largest) # 23The comment describes the algorithm in plain words. The code below it is the same idea written precisely enough for Python to run.
The same algorithm in JavaScript
const numbers = [4, 17, 9, 23, 8];
let largest = numbers[0];
for (const number of numbers.slice(1)) {
if (number > largest) {
largest = number;
}
}
console.log(largest); // 23Different syntax, identical algorithm. Once you understand the idea, switching languages is mostly learning new spelling.
How it works
Every program, in every language, is built from a handful of ideas:
1. Values and variables: data (numbers, text, lists) and names for it. 2. Operations: arithmetic, comparisons, joining text. 3. Decisions: do this if something is true. 4. Repetition: do this for each item, or while something is true. 5. Functions: give a group of steps a name so you can reuse it.
Programs take input (typed text, a file, a click, a network message), process it with those building blocks, and produce output (text on screen, a saved file, a web page).
The usual workflow is a loop: understand the problem, write a little code, run it, check the result, fix what's wrong, repeat.
Problem ──► Algorithm ──► Program (source code) ──► Run ──► Output
▲ (idea) (in a language) │
└──────────── fix bugs, adjust, improve ◄───────────────────┘Why does it exist?
Computers can only follow instructions. Without programs they do nothing. Programming languages exist because the computer's own language (machine code: raw numbers) is nearly impossible for humans to write and read. Languages let people express logic in something close to words and math, and tools translate that into what the machine runs.
When to use it
- Any task you'll repeat many times (renaming 500 files, generating reports).
- Problems too large or fast for a human (searching millions of records).
- Building something people interact with: apps, websites, games, devices.
- Making a process exact and repeatable, so it gives the same result every time.
When not to use it
- A one-off task that takes two minutes by hand. Writing a program for it can take longer than just doing it. - When an existing tool already does the job (a spreadsheet formula, a shell command, an off-the-shelf app). - When the problem itself isn't understood yet. Talk to people and write the steps in plain words first; code comes after.
Common mistakes
Starting to type code before understanding the problem. Write the steps in plain words first.
Expecting the computer to "know what you meant". It does exactly what the code says, including the mistakes.
Trying to learn many languages at once. The core ideas transfer, so learn them well in one language first.
Writing a large program in one go and only then running it. Run small pieces often so bugs are easy to locate.
Treating error messages as failures instead of information. They usually tell you exactly where to look.
Practice exercises
- Easy:
Write, in plain numbered steps (no code), an algorithm for making a cup of tea. Then find one step a literal-minded robot could misunderstand and rewrite it.
- Medium:
Write an algorithm in plain words, then a program in Python or JavaScript, that counts how many numbers in a list are even.
- Hard:
Write an algorithm that checks whether a word is a palindrome (reads the same backwards, like "level"). Implement it in two languages and list what changed between them and what stayed the same.
Interview questions
What is the difference between an algorithm and a program?
An algorithm is a language-independent, step-by-step method for solving a problem. A program is a concrete implementation of one or more algorithms in a specific programming language that a computer can run.
What properties should a good algorithm have?
It should be correct (produces the right answer for every valid input), unambiguous (each step has one meaning), finite (it eventually stops), and reasonably efficient in time and memory.
What is source code?
The human-readable text of a program, written in a programming language. Tools such as compilers or interpreters turn it into something the machine can execute.
Why are there so many programming languages?
Each makes different trade-offs: speed versus ease of writing, manual versus automatic memory management, strict versus flexible types, and fit for a domain (C for systems, JavaScript for browsers, Python for scripting and data). No single language is best at everything.
What is the difference between a high-level and a low-level language?
A high-level language (Python, JavaScript) hides hardware details like memory addresses and registers, so code is shorter and closer to the problem. A low-level language (assembly, and to a degree C) exposes those details, giving more control and speed at the cost of more effort and more ways to make mistakes.
What is a bug?
A mistake in a program that makes it behave differently from what was intended: a wrong result, a crash, or a hang. The program is doing exactly what the code says; the code just doesn't say what the programmer meant.
Name the core building blocks shared by almost every programming language.
Values and data types, variables, operators, conditionals, loops, and functions. Most languages also provide collections like lists and maps.
What is pseudocode and why is it useful?
Informal, language-agnostic notation for describing an algorithm. It lets you reason about logic without fighting syntax, and it's easy to translate into any real language afterwards.
Scenario: you're given a vague task, "make the report faster". What do you do before writing code?
Clarify and measure. Ask what "faster" means (how fast, for whom), reproduce the slow case, measure where time is actually spent, then plan a change. Coding before understanding the problem often optimizes the wrong thing.