What is Programming?
Programming is the skill of telling a computer exactly what to do, one clear step at a time.
Instructions, Like a Recipe
Think about how Ayesha's mother makes chai. She follows steps in order:
- Boil water
- Add tea leaves
- Add milk and sugar
- Boil again, then pour into cups
A computer program works the same way. It is a list of steps, and the computer follows them in order, from top to bottom. The big difference is that a computer does exactly what you write. If you forget a step, it will not guess. If you write a step in the wrong order, it will happily do it in the wrong order.
What is a Programming Language?
Computers do not understand Urdu or English. Deep inside, they only understand numbers. A programming language is a middle ground: it is easy enough for people to read and write, and strict enough for a computer to follow without confusion.
There are hundreds of languages. Some popular ones are:
| Language | Often used for |
|---|---|
| Python | Automation, data, AI, beginners |
| JavaScript | Websites and web apps |
| Java / Kotlin | Android apps, big business systems |
| C / C++ | Games, fast software, hardware |
| PHP | Websites such as WordPress |
In this tutorial we use Python and JavaScript, because they are friendly for beginners and used everywhere.
Your First Program
The classic first program just shows a message on the screen.
In Python, you use print():
Example
print("Hello, World!")
print("I am learning to code.")Hello, World! I am learning to code.
In JavaScript, you use console.log():
Example
console.log("Hello, World!");
console.log("I am learning to code.");Hello, World! I am learning to code.
Each line is one instruction. The text inside the quotes is called a string. The computer shows it exactly as written.
In JavaScript, a semicolon ; at the end of a line marks the end of an instruction. Python does not need it. Both languages ignore extra spaces at the end of a line.
Code, Programs and Programmers
A few words you will hear a lot:
- Code: the text you write in a programming language
- Program: a complete set of code that does a job, like a calculator
- Programmer or developer: a person who writes code
- Run or execute: asking the computer to follow your code
- Output: what the program shows or produces
Comments: Notes for Humans
Sometimes you want to write a note in your code that the computer should ignore. This is called a comment.
Example
# This line is a comment. Python skips it.
print("Shop is open") # a comment can also go hereExample
// This line is a comment. JavaScript skips it.
console.log("Shop is open"); // a comment can also go hereShop is open
Python comments start with #. JavaScript comments start with //. Good comments explain why you wrote something, so you (or a classmate) can understand it later.
Where Can You Run Code?
You do not need anything special to start:
- Python: install it from python.org, or use a free online Python editor
- JavaScript: every web browser already has it. In Chrome, press F12 and open the Console tab to type JavaScript
Do not worry about choosing the "best" language right now. Learn the ideas first. Once you understand variables, conditions, loops and functions in one language, a second language is much easier.
Exercise
Exercise
Which line shows a message on the screen in Python?
