Why This Matters Before You Write Code
A lot of beginners skip this part and jump straight into writing code. That works for a while but at some point things stop making sense. Why does a program slow down when memory is full? Why do some operations take longer than others? Why does a computer need an operating system at all?
When you understand how a computer works under the hood, these questions stop being mysteries. You start writing code with awareness, not just intuition. You understand what your instructions are actually doing to the machine and that makes you a significantly better engineer.
Think of it like learning to drive. You do not need to be a mechanic but knowing that pressing the accelerator sends fuel to the engine, that the brakes create friction to slow the wheels and that the steering links to the tyres gives you a much better understanding of why the car behaves the way it does. The same applies here.
The Big Picture: Input, Process, Output
Every single thing a computer does follows one simple pattern. Something goes in, something happens in the middle and a result comes out. This is called the IPO model and it applies to everything from the simplest calculator to the most complex artificial intelligence system.
When you type a search query into Google, the input is your text. The process is Google's servers searching through billions of pages to find the most relevant results. The output is the list of results displayed on your screen.
When you take a photo on your phone, the input is light hitting the camera sensor. The process is the phone converting that light into digital data and applying enhancements. The output is the image saved to your gallery.
Understanding this model helps you think about any software problem more clearly. Before you build anything, ask yourself: what is the input, what process needs to happen and what should the output be?
The Hardware: Physical Parts That Make It Work
Hardware refers to the physical components inside a computer. You cannot change hardware with code but your code runs on top of it, so understanding what each part does helps you write better software.
The CPU, which stands for Central Processing Unit, is the brain of the computer. It is responsible for executing instructions. When you run a program, the CPU reads each instruction one by one and carries it out. Modern CPUs can process billions of instructions per second. The speed at which a CPU can do this is measured in gigahertz. A 3GHz processor can perform roughly three billion cycles per second.
RAM, which stands for Random Access Memory, is the computer's short term memory. When you open an application it gets loaded from storage into RAM because RAM is much faster to read from. Everything currently happening on your computer is being held in RAM. When you close a program or restart your computer that information disappears. RAM is temporary by design.
Storage is where information lives permanently. Your files, your operating system, your installed applications. All of it sits in storage even when the computer is off. Traditional hard drives store data on spinning magnetic disks. Solid state drives, which are faster and more common today, store data on chips with no moving parts.
The GPU, which stands for Graphics Processing Unit, handles visual output. It takes the data your programs produce and translates it into the pixels displayed on your screen. GPUs are also used heavily in machine learning and data processing because they are designed to handle many tasks simultaneously.
The motherboard is the main circuit board that connects all these components together. Every part of the computer communicates through the motherboard.
The Software Layer: Instructions on Top of Hardware
Hardware on its own does nothing. It needs software to tell it what to do. Software is simply a set of instructions written in a language the computer can eventually understand and execute.
There are different layers of software and understanding how they stack on top of each other is important.
At the lowest level is the operating system. This is software like Windows, macOS or Linux that manages the hardware and provides a foundation for everything else to run on. The operating system handles memory management, file storage, security, input and output and much more. Without it every application would have to manage all of that itself which would be enormously complex.
On top of the operating system sit applications. Your browser, your text editor, your music player. These are programs written by developers that use the operating system as a platform.
When you write code you are working at the application layer, building software that runs on top of the operating system which in turn runs on top of the hardware.
How Computers Think in Binary
Here is where things get interesting. Computers do not understand human language. They do not understand words, images or sounds the way we do. Everything inside a computer is represented as numbers and specifically as binary, a number system that uses only two digits: 0 and 1.
Why only two digits? Because computers are built from billions of tiny electronic switches called transistors. Each transistor can be in one of two states: on or off. On is represented as 1. Off is represented as 0. Every piece of data your computer processes is ultimately a pattern of these on and off switches.
A single 0 or 1 is called a bit. Eight bits grouped together form a byte. From there the units scale up. A kilobyte is approximately one thousand bytes. A megabyte is approximately one million bytes. A gigabyte is approximately one billion bytes.
To see how this works in practice, consider the letter A. In a system called ASCII, which is a standard for representing text as numbers, the letter A is assigned the number 65. In binary, 65 is written as 01000001. So when you type the letter A your computer is actually storing and working with the pattern 01000001.
Every image on your screen is a grid of pixels and each pixel is a combination of red, green and blue values stored as numbers. Every sound in a music file is a series of measurements of air pressure captured at thousands of points per second and stored as numbers. Everything is numbers. Everything is binary underneath.
How a Program Is Executed
When you write code and run it a specific sequence of events takes place that is worth understanding.
The code you write in a programming language like Python or JavaScript is called source code. Computers cannot read source code directly. It needs to be translated into a language the CPU understands called machine code, which is essentially binary instructions.
This translation is handled either by a compiler, which translates the entire program before running it, or an interpreter, which translates and runs the program line by line. Python uses an interpreter. Languages like C use a compiler. There are tradeoffs to both approaches which we will revisit in later sessions.
Once translated the program is loaded from storage into RAM. The CPU then reads the instructions from RAM and executes them one by one. As the program runs it might read input from the user, perform calculations, store results in memory and produce output on screen. This entire cycle, fetch an instruction, decode it, execute it, is called the fetch-decode-execute cycle and it is the heartbeat of every computer.
A Closer Look Through Examples
Example one. Opening a web browser. You double click the browser icon. The operating system loads the browser application from storage into RAM. The CPU begins executing the browser's instructions. The browser draws its interface on screen using the GPU. All of this happens in less than a second.
Example two. Sending a message. You type a message and press send. Your input is captured as text. The application converts that text into data, packages it and sends it over the internet to a server. The server processes the data and delivers it to the recipient's device. At every step data is being represented as binary, moved through memory and processed by CPUs.
Example three. Running a calculation. You open a calculator app and type 200 divided by 4. The CPU receives the instruction to divide the number 200 by 4. It performs the operation at the hardware level using binary arithmetic and returns 50. The result is then displayed on screen. Simple to you, but a precise sequence of binary operations to the machine.
Checkpoint
At this point you should understand that computers follow an input, process, output model for everything they do. You should know the key hardware components and what each one does. You should understand that everything inside a computer is represented as binary and you should have a clear picture of how a program moves from code to execution. If any of these feel unclear go back and reread the relevant section before continuing.
Assignment
This assignment has three levels. Work through as many as you can.
Level one is for understanding. In your own words explain the difference between RAM and storage. Why does a computer need both? Use an analogy that makes sense to you to explain the difference.
Level two is for applying. Open your computer or phone settings and find the following information. The processor model and speed, the amount of RAM installed, the total storage capacity and the operating system version. Write these down and reflect on what each one means based on what you learned in this session.
Level three is a stretch. Do some research on what binary is and try to manually convert the following numbers from decimal to binary: the number 2, the number 5 and the number 10. There are many free tools and guides online that explain how binary conversion works. This exercise gives you a deeper feel for how computers represent information at the lowest level.
Leave a comment
Your email address will not be published. Required fields are marked *