Introduction

Table of contents
Programming powers everything from your morning alarm to late-night Netflix. Yet most people think it's mysterious and complex. The truth? It's simply the art of giving computers clear, step-by-step instructions to solve problems.

The World of Programming

What is Programming?

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.

A computer is basically an electronic device that takes in input, processes it and produces often intelligible output.
Programming is the process of writing computer programs. A computer program is a sequence of instructions that are executed by a computer to complete a particular task.

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.

What are Computer Programs?

Let's break down the definition of a computer program:

A computer program is a sequence of instructions that are executed by a computer to complete a particular task.

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:

  1. Heat water in a pan
  2. Add maize meal while stirring
  3. Continue stirring as mixture thickens
  4. 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.

The Language of Computers

What Are Programming Languages?

Programming languages can be described as languages that are used to write computer programs.

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.

Types of Programming Languages

Programming languages can be classified in 3 categories:

  1. High level languages
  2. Assembly languages
  3. Low level languages

High Level Languages

High level languages are programming languages that are closer to the human language.

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.

Low Level Languages

Low level languages are programming languages that are closer to the way computers understand things.

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 sit between high-level and low-level languages, using symbolic code that represents machine instructions.

Assembly languages are slightly more readable than pure machine code but still much closer to what the computer understands than high-level languages.

Translators: The Bridge Between Human and Machine

Translators are programs that convert code written in high-level languages into low-level languages that computers can understand.

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:

  1. Lexical analysis (breaking code into tokens)
  2. Syntax analysis (checking if code follows language rules)
  3. Semantic analysis (checking if code makes logical sense)
  4. Optimization
  5. 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

Why Should We Care about Translators in Python?

Understanding translators is particularly important when learning Python because:

  1. Python uses an interpreter, which affects how you write and run code
  2. The Python interpreter handles memory management for you
  3. Python's interpreter allows for interactive coding through the REPL (Read-Evaluate-Print Loop)
  4. 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!

Development Environments

To write Python programs effectively, you'll need more than just the language itself. You'll need a development environment.

What is an IDE?

An Integrated Development Environment (IDE) is a software application that provides comprehensive facilities for software development.

Think of an IDE as a workshop with all the tools a carpenter needs, neatly organized in one place.

Components of an IDE

Most IDEs include the following components:

Code Editor

A code editor is where you write and edit your code.

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

A debugger allows you to pause program execution, examine variables, and step through code line by line.

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

Version control systems track changes to your code over time.

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.

Setting Up Your Environment

Before you can start writing Python code, you need to:

  1. Install Python on your computer
  2. Choose and install an IDE or code editor
  3. 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!

Discussion (0)

Be the first to comment

Join the discussion

Share your thoughts and engage with the community

Your comment will appear immediately

No comments yet

Be the first to share your thoughts on this article!