Right now, as you're reading this, you're interacting with a computer program. Whether you're on your smartphone, tablet, laptop, or e-reader, the text you're seeing, the way pages turn, even the brightness adjustment—it's all controlled by programming.
Think about your typical day. Your smartphone alarm wakes you up. You check messages on WhatsApp, scroll through social media, maybe stream some music while getting ready. Your smartwatch tracks your steps. You use GPS to navigate traffic, pay for coffee with a mobile app, and video call a friend during lunch. In the evening, you might stream a movie, play a mobile game, or shop online.
Every single one of these interactions—from the simplest tap to the most complex transaction—is made possible by computer programs. We live surrounded by programming, yet most people think of it as something mysterious and complex, reserved for people in hoodies typing cryptic commands in dark rooms.
To bring into perspective what a computer program is, think of the various applications we interact with daily: LinkedIn app, X app, Facebook app, Chrome browser, Bank app, App Store, GTA 5, Mortal Combat or File Manager/Explorer. All these are computer programs. This means the next time you think of a computer program, it isn't anything foreign.
Let's break down the definition of a computer program:
Sequence means "follow each other." For example, the letters of the alphabet are in sequence, they follow each other from A to Z. The same applies to the Arabic numbers 0 to 9; they follow each other in sequence.
Instructions refer to detailed information telling how something should be done, operated, or assembled. For example, if we were to create a recipe for ugali (a staple food in Kenya), we might include instructions like:
- Heat water in a pan
- Add maize meal while stirring
- Continue stirring as mixture thickens
- Cook until firm
Computer programs function similarly - they're like recipes for completing particular tasks.
Execution by a computer refers to the computer performing the instructions one by one.
A task is simply what we want to accomplish. Examples of everyday computer tasks are sending an email, printing a document, calling a person, sending a WhatsApp message, pausing a YouTube video, or uploading a TikTok video.
Remember that computer programs are sequences of instructions and these instructions must be written in some way and fed to the computer.
Now, programming languages are not that different from our languages be it French, English, Cantonese, Japanese, Swahili, Arabic etc. It's just that this time we are able to communicate with a computer instead of our friend Bob or Mary.
Examples of programming languages you'll meet are Python, C++, C, Perl, Golang, Javascript, Java, Elixir and so on. It is estimated that we have between 700 and 8000+ programming languages in the world.
Warning
Don't feel overwhelmed by the number of programming languages. You don't have to learn all of them. One or two are enough to create meaningful and useful applications.
Programming languages can be classified in 3 categories:
- High level languages
- Assembly languages
- Low level languages
High Level Languages
For instance, Python if very similar to English with use of words such as for, in, while, and, not, or import, from, as, if, else, continue, break, pass, finally and so on.
Examples of high level languages are: Python, Java, PHP, C++, JavaScript, Ruby, and Kotlin.
To make this clearer, let's ask ourselves one question: How do computers understand things? The answer is simple: 0s and 1s aka binary.
Danger
Working directly with binary is extremely tedious and error-prone. The name "mike" is represented as 01101101 01101001 01101011 01100101 in binary. Imagine writing entire applications this way!
Examples of low level languages include C.
Assembly Languages
Assembly languages are slightly more readable than pure machine code but still much closer to what the computer understands than high-level languages.
Luckily for us, we do not have to write code in low level languages since it is super tiring and counterintuitive. We can write our code in high level languages and have translators convert that into low level languages that the computer can understand.
We have different types of translators:
Compilers
Compilers translate the entire program at once into machine code before execution.
The compilation process involves several steps:
- Lexical analysis (breaking code into tokens)
- Syntax analysis (checking if code follows language rules)
- Semantic analysis (checking if code makes logical sense)
- Optimization
- Code generation
Compilers are used by languages like C, C++, and Rust. These languages typically execute faster because all the translation work happens before the program runs.
Important
Compiled programs are usually specific to an operating system or processor architecture. A program compiled for Windows may not run on Linux.
Interpreters
Interpreters translate and execute the program line by line, in real-time.
Interpreters don't produce a separate machine code file. Instead, they read, translate, and execute each line of code on the fly. Python primarily uses an interpreter, which makes it more flexible but can be slower than compiled languages.
Benefits of interpreted languages:
- Easier debugging (errors are reported as they occur)
- Platform independence (the same code runs on different systems)
- Interactive development (code can be tested line by line)
Important
Python actually uses a hybrid approach. It compiles code to bytecode (.pyc files) which is then interpreted by the Python Virtual Machine (PVM).
Transpilers
Transpilers convert source code from one programming language to another programming language.
Unlike compilers and interpreters that translate to machine code, transpilers translate between languages of similar abstraction levels. For example:
- TypeScript transpiles to JavaScript
- CoffeeScript transpiles to JavaScript
- Kotlin can transpile to JavaScript
Understanding translators is particularly important when learning Python because:
- Python uses an interpreter, which affects how you write and run code
- The Python interpreter handles memory management for you
- Python's interpreter allows for interactive coding through the REPL (Read-Evaluate-Print Loop)
- Bytecode compilation helps Python balance flexibility with performance
Important
When you run Python code, the interpreter is constantly working behind the scenes. If you get an error, the interpreter stops at that point - the previous lines have already been executed!
To write Python programs effectively, you'll need more than just the language itself. You'll need a development environment.
Think of an IDE as a workshop with all the tools a carpenter needs, neatly organized in one place.
Most IDEs include the following components:
Code Editor
Good code editors offer features like:
- Syntax highlighting (coloring different parts of code for readability)
- Auto-completion (suggesting code as you type)
- Code folding (hiding blocks of code temporarily)
3.2.2 Debugger
This is crucial for finding and fixing bugs in your code.
Important
Never underestimate the importance of a good debugger! Print statements can only take you so far.
Build Automation Tools
These help automate repetitive tasks like:
- Compiling/interpreting code
- Running tests
- Packaging applications
Version Control Integration
Good IDEs integrate with systems like Git, allowing you to:
- Track changes
- Collaborate with others
- Revert to previous versions if needed
Several excellent IDEs and editors are available for Python development:
PyCharm: A powerful, feature-rich IDE specifically designed for Python.
Visual Studio Code: A lightweight but powerful editor with excellent Python support through extensions.
Jupyter Notebook: Perfect for data science, allowing you to mix code, output, visualizations, and markdown in one document.
IDLE: Python's built-in development environment. Simple but good for beginners.
Thonny: A Python IDE for beginners with a simple interface and built-in debugger.
Important
As a beginner, start with a simpler editor like IDLE or Thonny. As you grow more comfortable with Python, you can transition to more powerful tools like VS Code or PyCharm.
Before you can start writing Python code, you need to:
- Install Python on your computer
- Choose and install an IDE or code editor
- Learn how to run Python code in your chosen environment
Important
Always check that you're installing the latest stable version of Python (unless you have specific requirements for an older version).
With your environment set up, you'll be ready to write your first Python program and begin your journey into the world of programming!
No comments yet
Be the first to share your thoughts on this article!