Free

2: The Alphabet and Vocabulary of Programming

⏱️ 50-65 minutes
📊 intermediate

Chapter 5: "Languages for Communicating with Computers"

In the morning, Alice woke up from strange sounds coming from the living room. When she came out of her room, she saw Byte making a series of beeping sounds, and Professor Bit seemed to understand him.

— Good morning, Alice! — the Professor turned to her. — Byte and I were just discussing the topic of today's lesson — programming languages.

— Were you speaking in robot language? — Alice wondered, pouring herself orange juice.

— Something like that, — the Professor smiled. — Byte was speaking in a language called "machine code." This is the lowest-level language that computers use to communicate internally.

Logic, sitting on a bookshelf, spread her wings:
— There are more than 700 programming languages in the world, and each has its own features and purpose.

— Seven hundred?! — Alice was surprised. — But why so many? People get by with far fewer languages for communication.

The Professor sat at the table and showed Alice his tablet:
— Look, programming languages are created for different purposes, just like tools. A hammer is good for driving nails, but not very convenient for screwing in screws, right?

Alice nodded.

— It's the same with programming languages. Some are good for creating websites, others — for analyzing data, others — for controlling robots or creating games.

A colorful diagram with different programming languages appeared on the screen.

Programming languages: Python, algorithms and a program flowchart

— Here, for example, Python, — the Professor pointed to a logo with a snake. — This is a very popular language, understandable for beginners. You can write almost anything on it — from simple scripts to complex scientific programs.

— And this is JavaScript, — the Professor pointed to another logo. — It controls most interactive elements on web pages.

— What language does Byte speak? — Alice asked.

— Byte has several languages, — the Professor replied. — His basic functions are written in C++, which is a very fast and powerful language. And for communicating with us, he uses special Python libraries.

Семьсот путей, семьсот дорог,
Семьсот сплетений точных строк.
Семьсот различных — про одно:
Как в цепь вплетается звено.

Для каждой цели — свой язык,
К которому творец привык.
Семьсот путей на высоту
Рождают в коде красоту.

Один, как флейта, ясен, чист,
Свободен, как летящий лист.
Другой — как молот, крепок, твёрд,
В расчётах точен, строг и горд.

Тот — архитектор важных дел,
Построить прочный свод сумел.
А этот — красочен и жив,
Как акварели перелив.

Вот страж табличной глубины,
Где ритмы строгие точны.
В бездонной памяти сетей —
Хранитель данных и ключей.

На разных языках народ
Творит симфонию из нот.
По-разному всё об одном:
Их код вплетается в геном!

— Professor, how are programming languages different from human languages? — Alice wondered.

— Great question! — The Professor thought for a moment. — The main difference is that human languages allow ambiguity and interpretation, while programming languages must be absolutely precise.

— What does that mean?

— When I say: "Please pass me that thing," — you can understand from context what I mean. If I glance at the TV remote, you'll guess that I need exactly that. But a computer can't "guess." If you don't specify exactly what needs to be done, it will either give an error or do something wrong.

Byte made a series of sounds like laughter:
— When programmers write imprecise instructions, funny results happen! Once I was asked to "go right when you see a tree." I never moved because it wasn't specified WHICH tree!

— Exactly! — the Professor continued. — In programming, extreme precision is important. The computer does exactly what you tell it, not what you mean.

Logic added:
— Human languages evolved over thousands of years, while programming languages were specifically created by people to solve specific tasks.

The Professor pulled several books from the shelf:
— Each programming language has its own syntax — a set of rules that determine how commands should be written. It's like grammar in regular languages.

He opened his laptop and showed a simple program:

python
print("Hello, world!")

— This is a program in Python, — he explained. — It displays the phrase "Hello, world!" on the screen. And here's the same thing in JavaScript:

jsx
console.log('Hello, world!');

— And here's in C++:

cpp
#include
int main() {
std::cout << "Hello, world!" << std::endl;
return 0;
}

— Do you see how differently you can say the same thing? — asked the Professor.

— Yes, Python looks the simplest, — Alice noticed.

— Well observed! — the Professor nodded. — Python was created with readability in mind. It's often recommended for beginners precisely because its code resembles regular English.

— What language should I learn to program? — Alice asked.

— To start, I'd recommend something visual, like Scratch, — the Professor replied. — In it, a program is assembled from blocks, like a LEGO constructor. This helps understand the basic concepts of programming without needing to memorize syntax.

Byte displayed a colorful Scratch interface on his screen:

Scratch: a program of colorful blocks, like a LEGO set

— Look, this is what a program looks like in Scratch. You drag command blocks, connect them, and you get a program!

— Looks like a game, — Alice smiled.

— Programming should be engaging! — the Professor winked. — Many professional programmers say their work is like solving puzzles and creating something new at the same time.

Task

Come up with your own mini programming language for controlling a robot vacuum cleaner. What commands will be in your language? For example, "FORWARD(5)" might mean "move forward 5 steps". Make a list of 5-7 commands and come up with a simple program in your language for cleaning a room.