Programming Fundamentals

What is Programming?

**The programmer's paradox:** A computer is the dumbest machine on the planet. It literally understands only 0s and 1s. Yet this "dumb" machine beats world chess champions, drives cars, and generates images indistinguishable from photographs. How is that possible?

The answer: **programming**. The art of translating human ideas into a language machines understand. A programmer is a translator between worlds.

Цели урока

  • Understand what a program and an algorithm are
  • Learn how a computer executes instructions
  • Write a first pseudocode example
  • Understand the differences between programming languages
  • Dispel the myth that "programming is hard"

Предварительные знания

  • Basic understanding of math (addition, comparing numbers)
  • Ability to follow step-by-step instructions

GitHub - 100 million repositories. npm - 2 million packages. Grace Hopper found the first bug in 1947 - literally a moth in a relay of the Mark II computer. The word "bug" never left the programmer's vocabulary. This isn't magic for the chosen few - it's a craft with 80 years of history, and it's accessible to anyone.

  • **Spotify Discover Weekly**: the algorithm analyzes billions of plays - users get a playlist that feels personally curated
  • **Instagram Feed**: code ranks what posts to show - the algorithm decides what 2 billion users see
  • **Uber**: a program finds the nearest driver from thousands in milliseconds and calculates the optimal route
  • **ChatGPT**: a neural network with 175 billion parameters - all code written by programmers
  • **GitHub**: 100 million repositories - all open-source code in one place, built with the same Python/JS beginners are learning

The First Programmer Was a Woman

A hundred years before computers existed, Ada Lovelace wrote the first algorithm in history - a program for computing Bernoulli numbers. She worked with Charles Babbage's "Analytical Engine" - a mechanical device the size of a room that was never built in her lifetime. Ada was the first to realize that machines could do more than crunch numbers; they could process any kind of symbol - music, text, images. She foresaw the future 150 years before it arrived.

What Is a Program?

An alien receives a task: make a sandwich. It is **incredibly obedient** - it will do exactly what is written. But **completely literal** - if it says "put the cheese on the bread" while the bread is still in the bag, it puts the cheese on the bag.

Instructions for the "alien"

This is what a sandwich "program" looks like

1. Open the bread bag 2. Take out one slice of bread 3. Place the bread on a plate 4. Open the cheese package 5. Take out one slice of cheese 6. Place the cheese on the bread 7. Done! Skipped step 1? The alien will try to pull the bread through a closed bag. That's exactly how a computer works - it does **precisely what is written**, nothing more, nothing less.

**A program** is a sequence of instructions that a computer executes one by one. Each instruction is a simple action: add numbers, compare values, store a result.

A computer doesn't understand context. It doesn't know that "bread" is food, or that "cheese" should go on top. It just executes commands. A **programmer** is someone who can break a complex task into simple steps and write them in a language the machine understands. Conway's law: the structure of a program reflects the structure of the team that built it. Cunningham's law: the best way to get the right answer on the internet is to post the wrong one. Programming is full of such patterns.

Why is it important to give a computer EXACT instructions?

Algorithm - A Recipe for Solutions

A program is built from **algorithms**. An algorithm is like a recipe in cooking: a step-by-step instruction for turning raw ingredients into a result.

**An algorithm** is a finite sequence of clear instructions for solving a problem. Key properties: • **Finiteness** - the algorithm must terminate in a finite amount of time • **Definiteness** - each step must be unambiguous • **Input** - the algorithm receives initial data • **Output** - the algorithm produces a result

Algorithm: find the maximum in a list

How is the largest number found?

**Task:** Given a list [3, 7, 2, 9, 5]. Find the maximum. **Algorithm:** 1. Remember the first number as "current maximum" (3) 2. Take the next number (7) 3. If it is greater than the current maximum → remember it as the new maximum 4. Repeat steps 2–3 until no numbers remain 5. Return the current maximum **Trace:** • Step 1: max = 3 • Steps 2–3: 7 > 3? Yes → max = 7 • Steps 2–3: 2 > 7? No → max = 7 • Steps 2–3: 9 > 7? Yes → max = 9 • Steps 2–3: 5 > 9? No → max = 9 • Step 5: Answer = **9**

This simple algorithm works for a list of 5 numbers and for a list of 5 billion. The computer runs it in a fraction of a second - that scaling property is what makes algorithms useful.

An algorithm is code written in some programming language

An algorithm is an idea - a sequence of steps. Code is just one way to express it

A sorting algorithm can be written in plain English, drawn as a flowchart, or implemented in Python/C++/Rust - the logic doesn't change. QuickSort, invented by Tony Hoare in 1959, runs in the standard library of every modern language today. An algorithm is the "what to do"; code is the "how to write it for a specific machine".

Which property of an algorithm is violated by the instruction: "Repeat step 1 forever"?

Variables - The Memory of a Program

In the max-finding algorithm, we said "remember the number". But how does a computer "remember"? That's what **variables** are for - named memory cells.

Variables - Like labeled boxes

A simple analogy

Picture a warehouse full of boxes, each with a label: 📦 `name` → "Alice" 📦 `age` → 25 📦 `height` → 165.5 📦 `student` → true You can: • **Put** a value into a box: `age = 25` • **Look** at what's inside: `print(age)` → prints 25 • **Change** the contents: `age = 26` The box's name (variable name) doesn't change - but its contents can!

In programming, `=` is NOT "equals" - it means **"assign"**. The expression `x = x + 1` means: "take the current value of x, add 1, and put the result back into x". In math that's nonsense, but in programming it's a routine operation!

What will this code print? ``` x = 5 y = x x = 10 print(y) ```

Programming Languages

A computer understands only **machine code** - a sequence of zeros and ones. Writing programs in zeros and ones is like writing a novel using only Morse code. Technically possible, but agonizing.

That's why people invented **programming languages** - a way to write code in something that resembles human language. A special program (a **compiler** or **interpreter**) translates it into machine code.

One task - different languages

"Hello, World!" in several languages

**Python** - simple and readable: ```python print("Hello, World!") ``` **JavaScript** - the language of the web: ```javascript console.log("Hello, World!"); ``` **C++** - fast, but verbose: ```cpp #include <iostream> int main() { std::cout << "Hello, World!" << std::endl; return 0; } ``` **Java** - popular in enterprise: ```java public class Hello { public static void main(String[] args) { System.out.println("Hello, World!"); } } ``` All do the same thing - just differently!

LanguageWhere it's usedDifficulty
PythonML, automation, scienceLow
JavaScriptWebsites, appsMedium
C++Games, systems, driversHigh
SwiftiOS appsMedium
GoServers, cloudMedium

For beginners, **Python** is the recommended starting point - it reads almost like English, forgives mistakes, and results appear quickly. It's the easiest on-ramp into programming.

Why do different programming languages exist?

Your First Code

Enough theory - time to write code. Below is a **real Python sandbox**. The code can be edited and run right in the browser.

Code runs in an isolated environment (WebAssembly). Nothing breaks, even with unusual inputs. Experiment freely!

That was the first program. Now try something more challenging:

Don't be afraid of errors! Every programmer sees them hundreds of times a day. An error isn't a failure - it's a **hint** about what to fix.

What does the print() function do in Python?

Key Ideas

  • **A program** is a sequence of exact instructions; the computer executes them literally, without inferring intent or context
  • **An algorithm** is an idea, not code; the same algorithm can be written in Python, C++, or plain English. The logic doesn't change
  • **A variable** is a named memory cell; `y = x` copies the value, it does not create a reference
  • Programming languages are optimized for different tasks: Python for ML and automation, C++ for games and systems, JavaScript for the web
  • The first programmer in history was Ada Lovelace (1843); the first bug was a moth in a relay of the Mark II computer (Grace Hopper, 1947)
  • Knowing every language is not the goal. Understanding the principles matters: algorithm, variables, control flow

Where this lesson sits in the curriculum

Programming is a stack of small ideas. This lesson is the foundation. The next four lessons turn it into hands-on practice:

  • Development environment — Install Python, pick an editor, run the first file from disk
  • Variables and data types — How values live in memory: int, float, str, bool, and the assignment operator
  • Operators — Arithmetic, comparison, and logical operators turn variables into computations
  • Strings — Text as a first-class data type: concatenation, slicing, formatting

Вопросы для размышления

  • Pick any routine process - making coffee, a morning ritual, commuting to work - and write it down as an algorithm: what are the inputs, what are the steps, where are the conditions and loops, and what is the result?

Связанные уроки

  • alg-01-big-o — After grasping algorithms, the natural next step is learning to measure their efficiency
  • ds-01-arrays — Variables are atoms of storage; data structures are molecules
  • prog-02-setup — Next lesson: setting up a development environment
  • ar-01-natural — Mathematical computation is a direct analogy of an algorithmic sequence of steps
  • arch-04-cpu
What is Programming?

0

1

Sign In