What programming is
Programming is exact, step-by-step instructions. Three algorithms from class (tea, a house, a text message), what makes a list an algorithm, and how an idea becomes a result.
Instructions for a computer
Programming (תכנות) is giving a computer step-by-step instructions: what to do, and how to solve a problem. It has three parts:
| Part | What it means | Example |
|---|---|---|
| Instructions | People write commands with words and symbols. Written instructions are called code (קוד). | printf("Hello"); |
| Language | A programming language (שפת תכנות) is a set of fixed rules and words. | C, Python, JavaScript |
| Translation | The computer turns the words into 1s and 0s that its processor (מעבד) can run. | 10110000 |
This course teaches one programming language: C. Before we write any C, we practice the hardest part of programming: writing instructions that are exact enough for a machine.
The video shows how many programming languages there are. All of them do the same job: they give a computer instructions. Watch where C appears and what it is used for.
Algorithm 1: prepare a cup of tea
- Check that the kettle is unplugged.
- Open the kettle.
- Fill it with cold water for one mug, below the MAX line.
- Close the kettle and place it on its base.
- Plug it in and switch it on.
- Wait until the kettle switches itself off.
- Place one tea bag in a clean mug.
- Pour hot water until the mug is three-quarters full.
- Wait for three minutes.
- Remove the tea bag with a teaspoon.
- Ask: sugar or milk?
- Add the requested amount and stir.
- Serve the tea.
Look at how careful the list is. Step 1 is a check (safety first). Step 3 gives an exact amount, and a limit. Step 6 says exactly how long to wait: not "a few minutes", but until something happens. In class, the teacher acted as the computer and followed some of your lists word for word. A list that says "pour the water" before "switch on the kettle" makes cold tea.
Algorithm 2: draw a simple house
- Draw a square 30 cm wide and 30 cm high in the center of the board.
- Draw a triangle above the square.
- The bottom side of the triangle is the top side of the square.
- In the lower half of the square, draw a rectangle 8 cm wide and 15 cm high.
- The bottom of the rectangle touches the bottom of the square.
- Draw one small square window on each side of the door.
- Draw two lines through the center of each window: one horizontal, one vertical.
- Stop when the house has one roof, one door and two windows.
Step 2 alone is not enough: "above the square" could mean 1 cm above or 1 m above. Step 3 fixes that. The same happens with the door in steps 4 and 5. Step 8 tells the person drawing when the task is finished.
Algorithm 3: send a text message
The task: send the message "Hello There" to a classmate.
- Wake the phone screen.
- Unlock the phone.
- Open the messaging app.
- Select New message.
- Search for the contact "First Last".
- Check the contact details: is it the right person?
- Select that contact.
- Type exactly: Hello There
- Check the recipient, the spelling and the punctuation.
- Press Send once.
- Check that the message appears as sent.
You do this many times a day without thinking. Written as exact steps, it has 11 of them, and three are checks (6, 9 and 11). Without step 6, the message can go to the wrong person.
What makes a list an algorithm
The three lists have four things in common:
| Property | Example from the lists |
|---|---|
| Exact | "a square 30 cm wide", "wait for three minutes" |
| In order, one action per step | "1. Open the kettle. 2. Fill it ..." |
| Checks | "Check that the kettle is unplugged." |
| A clear end | "Stop when the house has one roof, one door and two windows." |
A list like this is an algorithm (אלגוריתם): a list of exact steps, in order, that solves a task and comes to an end. The word comes from the name of al-Khwarizmi, a mathematician from Baghdad in the 9th century, whose book taught step-by-step methods for calculating.
Make it exact
A computer cannot follow a vague instruction. Each vague instruction below has an exact version from the lists:
| Vague | Exact |
|---|---|
| Put some water in. | Fill it with cold water for one mug, below the MAX line. |
| Wait a bit. | Wait for three minutes. |
| Draw a roof. | Draw a triangle. Its bottom side is the top side of the square. |
| Send it. | Press Send once. |
The computer does exactly what is written
A computer does not guess what you meant. It does what the instruction says, every time, even when the result is silly.
Suppose the kettle is broken and never switches itself off. The computer reaches step 6: "Wait until the kettle switches itself off." It waits forever. It does not skip to step 7 and it does not ask you, because nothing in the algorithm tells it to.
From an idea to a result
Every program goes the same way:
Human idea → instructions → computer actions → result
For the text message: the idea is "say hello to a classmate", the instructions are the 11 steps, the computer actions are signals and bits inside the phone, and the result is "Hello There" on your classmate's screen.
A computer is an electronic machine. At its lowest level it responds only to patterns of bits (ביטים), 0s and 1s. It does not understand words like calculate, repeat or temperature. A programming language gives us a practical way to write instructions that can be translated into bits. How that translation works is the next lesson.
Key words
| English | Hebrew | Meaning |
|---|---|---|
| programming | תכנות | giving a computer step-by-step instructions |
| instruction | הוראה | one step the computer carries out |
| algorithm | אלגוריתם | exact steps, in order, with checks and an end |
| code | קוד | instructions written in a programming language |
| programming language | שפת תכנות | fixed rules and words for writing code |
| processor | מעבד | the chip that runs the instructions |
| bit | ביט | a single 0 or 1 |
| binary | בינארי | written with 0s and 1s |
Practice
More questions, with answers, are on the unit 1 practice page.