Programming

What programming actually is

Programming means writing a list of instructions that a computer follows in that order and exactly as written, without guessing what you meant. The real work is not the writing: it is turning something vague in your head into sentences that leave no room for interpretation.

  • Lesson 1 of 14
  • Beginner
  • Free, no signup

The five steps every program passes through

  1. 1

    The problem

    What exactly has to be solved, what goes in and what the output looks like.

  2. 2

    The algorithm

    The steps in your own words, before a single line of code.

  3. 3

    The code

    Those same steps, now under the rules of one particular language.

  4. 4

    Running it

    The first moment you learn what you actually said, not what you thought you said.

  5. 5

    Fixing it

    The step that never finishes and takes the most time of any programmer.

The five steps look linear and are not. In practice you keep going back from fixing to the algorithm, and that back and forth is the work itself rather than a sign of failure.

Last checked: Facts and tool names in this lesson are re-checked against their sources on this date.

What is a program? The simplest definition that is not wrong

A program is a list of instructions a machine carries out in order. The difference from a recipe you hand a person is right there: a person fills the gaps and understands what a pinch of salt means. A machine neither understands nor asks.

Anything you did not say does not happen, and anything you said wrongly happens exactly as wrongly as you said it. It is a simple sentence and the whole difficulty of this craft sits inside it. Most of the errors you will meet do not come from not knowing the language; they come from the sentence in your head being slightly different from the sentence you wrote.

Separate three words from the start. Code is the text of the instructions, the thing you type and save to disk. A programming language is the set of rules that text has to follow so it can be translated. And a program is what happens when that text is translated and run. The text stays; the program comes alive in memory, does its job and ends.

So being a programmer means holding this one ability: writing what you want precisely enough and unambiguously enough that a machine with no understanding can carry it out. The language and the tools come afterwards.

A real program, in five lines

These five lines of Python do real work: they walk a folder full of images and print the names of the files bigger than a given size. The job comes up on every site, because heavy images are the slowest part of most pages.

from pathlib import Path

for f in Path("images").rglob("*.jpg"):
    size = f.stat().st_size
    if size > 200_000:
        print(f.name, round(size / 1024), "KB")

Read it line by line. The first line brings in the tool for working with folders. The second says: inside the folder called images and all of its subfolders, take every file ending in jpg, one at a time. The third gets the size of the file in bytes and keeps it somewhere called size. The fourth sets a condition: only if that number is greater than two hundred thousand. The last line prints the file name with its size.

Three things in those five lines show up in every other language too: a loop that repeats work over each member of a set, a condition that decides, and a variable that holds something temporarily. Understand those three in one language and the next language is mostly a change of appearance rather than a new idea.

And one thing this program does not have: nowhere does it ask whether the images folder exists at all. If it does not, nothing happens and no error is printed either, because the loop runs over an empty set and finishes. A program that does not work yet does not complain is the most confusing state for a beginner, and it is what the section from our own work at the bottom of this page is about.

From problem to working code, in five steps

The first step is the problem, and it gets the shortest write-up: what exactly has to be solved, what goes in and what the output looks like. My site is slow is not a problem statement; I want the list of images above two hundred kilobytes is.

The second step is the algorithm, and it is the one almost everyone skips. An algorithm here means writing the steps in your own words before a single line of code: open the folder, take the files one at a time, look at each size, and if it is over a certain amount write down the name. If you cannot explain a task step by step in plain language, your problem is not Python.

The third step is the code: those same steps, this time under the rules of a language. The fourth is running it, and it is the first moment you truly learn what you said. The fifth is fixing it.

The fifth step does not finish, it repeats, and for every programmer it takes the most time. The common picture is that a professional writes the code correctly and it is done; what actually happens is that a professional works out faster where it went wrong. One small rule makes that loop several times quicker: change one thing at a time. Change three things together and get it working, and you do not know which one it was, so next time you start from nothing again.

The loop where learning actually happens

The fix loopmost of the time goes here
  • 1 Write
  • 2 Run
  • 3 Read what it said
  • 4 Change one thing

This loop has one condition: change one thing at a time. Change three together and get it working, and you do not know which one it was.

Why most of a programmer's time is not spent writing code

What shows from the outside is typing. Below the waterline sit four other jobs that no course makes a video about.

First, reading code that is already written. Code gets read far more than it gets written, whether it is yours or someone else's. Second, reproducing the error: until you can make a bug happen again on purpose, every change you make is a guess, and the thing that appears to fix it may have nothing to do with what you did.

Third, naming things and making decisions. Variable names and the way work is split between functions are not decoration; a bad name turns into a real bug three months later, because you yourself forget what you meant. Fourth, waiting: installing, running, testing, a server coming back up. Time no curriculum counts and every real working day contains.

None of this is said to discourage you. The opposite: if you know the real work looks like this, then the first time you spend an hour stuck on one error you will not conclude you lack the talent. That hour is the work.

What is visible, and the four things that are not

Writing code

The only part visible from outside, and the only part with videos about it.

the waterline
  • Reading code already written

    Code gets read more than it gets written, whether it is yours or not.

  • Reproducing the error

    Until you can make the bug happen again on purpose, every change is a guess.

  • Naming things and deciding

    A bad name turns into a real bug three months later.

  • Waiting

    Installing, running, testing, a server coming back up. Time no curriculum counts.

This split is not a measured ratio and we have no number for it. It is only the order of the jobs that take time and stay invisible in tutorials.

What exactly do you need in order to start?

An ordinary computer, a free text editor, a language, and a terminal. That is all. None of those four costs money and none needs expensive hardware; the program you saw in this lesson runs on the weakest laptop you own.

The terminal is that black window beginners are afraid of, and it is really just the place where you give the computer an instruction without hunting for a button. Learning it takes half an hour, and after that half your work happens there.

Our position, which does not sit well with how most courses are advertised: do not buy a course until you have written ten lines of code. Pick a small real task from your own life first, such as tidying up file names or counting something in a text file, and build that with the documentation and a few searches. If you still feel you need a structured path afterwards, buy the course then, and you will know what you are looking for.

There is also a shorter route that suits plenty of people better: instead of a general purpose language, start by building a web page. You see the output in the browser, the feedback is immediate, and those same three ideas of loop, condition and variable are waiting for you in JavaScript later.

Programming, coding, software engineering: what is the difference?

In everyday talk these three get used interchangeably, and that is fine. To be precise: coding is the act of writing instructions in a language, programming covers the whole business of solving the problem, of which coding is one step, and software engineering starts to mean something when several people work on one thing and that thing has to last for years: versioning, testing, documentation, delivery.

The distinction is useful in practice. If you are learning, you begin with coding, but the thing you actually need to practise is programming, which is that second step everybody skips. Software engineering is not something you practise at home either; you need it once you become several people, or once your code grows big enough that you lose your own way inside it.

The fast path, with AI

What genuinely got faster for a learner today is not producing code; it is having a teacher who never gets tired and answers at two in the morning. The difference between someone who pulls ahead with this tool and someone who falls behind fits in one sentence: the first asks for an explanation, the second asks for code. A frontier model suits this better than a fast cheap one, because it is judgment work rather than mechanical work; our current pick sits in the AI section of this site.

  1. Write in one sentence what you want done, and state its input and its output. This is the only step no model can take for you, because it does not know what you want.
  2. Fill in the recipe below and hand it over. Ask for the smallest program that works, not the most complete one; thirty lines you do not understand are worse than five you do.
  3. Run it yourself. If it errors, paste the full text of the error back verbatim, not your reading of it; your reading is exactly the thing you do not know yet.
  4. Once it works, run the version with one deliberate mistake in it and find the mistake yourself. That is the real exercise, not copying the correct version.
  5. Do not move to the next task until you can say what each line does without looking. It is the only measure on this path that tells you anything real.

Copy-ready recipe

Role: a programming teacher for someone who has never written a line of code.

What I want done:
{describe the task in one sentence}
Input: {what is given to the program}
Output: {exactly what should be printed or produced}
Language: {Python, unless you prefer another}

Rules for the answer:
1. The smallest program that does this job, not the most complete one. No extra libraries and no configuration.
2. Below the program, explain it line by line, one sentence per line.
3. Say in which situation this program silently does nothing and reports no error.
4. At the end, give a second version with exactly one mistake planted in it, and do not say where the mistake is.

Before you trust the output: The model does not run the program unless you gave it the tools to, so do not believe the sentence tested and working until you have run it yourself. And if you did not find the deliberate mistake in step four, that program is not yours yet: ask for the explanation again, not for the correct version.

AI in this kind of work

For someone just starting, the best use of a language model is not writing the program for them; it is explaining. You do not understand a line, ask. You got an error, hand over its text. You wrote code that works but feels bad, ask which part could be simpler and why. Our position is blunt: while you are learning, let it explain and quiz you, not write on your behalf.

Tools that actually help

  • Gemini It carries a separate study mode called Guided Learning that asks questions instead of handing over answers and recaps at the end of a topic; for learning that is exactly the behaviour you want. Google own page says the Gemini web app runs in over 230 countries and territories, and Iran is not on that list.
  • Claude Good at explaining a chunk of code and reading an error message, and when you ask for the shortest version it improvises less. Iran is on neither of Anthropic two supported-countries lists; we read that on Anthropic own page rather than measuring it.
  • ChatGPT The most common choice and acceptable for this job. We do not have an entry for it in our AI section yet, so we make no claim here about its access or pricing.

Where it backfires

The main risk for a beginner is not that the model gives wrong code; it is that it gives correct code. A program that runs while you do not know why it runs has added nothing to you, and the first day it breaks you are empty handed. Two habits prevent it: always ask for the smallest version, and guess the output before every run. The second risk is more specific: the model says something about your computer in exactly the same confident tone when it does not exist, such as the name of a command or the path of a file. Anthropic itself calls this hallucination in its own documentation and explains how to reduce it, which means the vendor treats it as a real weakness rather than a rumour. The rule is simple: anything the model says about your system has to be measured against a real run. For how each of these tools can be paid for from Iran, see the buying guide.

Sources: Anthropic: reduce hallucinations Anthropic: supported countries Google: where the Gemini web app is available Google: how Guided Learning can help you study

Where this advice stops

This lesson gives you a map, not a skill. Nobody becomes a programmer by reading it, the way nobody becomes a swimmer by reading the rules of swimming; all it does is make the first ten lines less frightening. Second, the example on this page is Python and its syntax is Python; loops, conditions and variables exist everywhere but the way they are written differs by language. Third, nothing on this page tells you what to build. That question has no technical answer and its answer has to come from your own work or life.

From our own work

On the day this lesson was checked, we ran those same five lines against this site's own uploads folder. 318 jpg files were examined and 100 lines were printed. The first line that came back was a file at 199 KB, under a program that was supposed to show only files bigger than 200 kilobytes. The program had made no mistake: the condition size > 200_000 counts bytes while round(size / 1024) divides by 1024, so a file of 204,125 bytes comes out as exactly 199. The sentence in our heads was not the sentence we wrote, and that is the whole point of this lesson. If you want to see it for yourself, run the five lines on any image folder and compare the first output line against the condition you wrote.

Real follow-up questions

Is programming hard?

It is not hard, it is slow. No concept in the first week is harder than reading a map, but it settles in only through repetition, and most people who quit do not quit at a concept, they quit at the first error they cannot read. Take error messages seriously and you have passed the hard part.

Do I need English to program?

The words of the language itself are few and get memorised: Python on this server has 35 keywords and you can count them yourself with python3 -c "import keyword; print(len(keyword.kwlist))". What genuinely needs English is documentation and error messages, and machine translation is good enough for that today. So a lack of English is not a reason not to start, though reading technical English multiplies your speed.

How do I know if programming is for me?

Find one repetitive task in your own week that bores you, and write ten lines that do it. If the moment it worked was interesting to you, you have your answer; if you only felt relief that it was over, you probably want a tool rather than programming, and that is a perfectly correct choice.