If you are planning to skip this page, please don’t. This is not clickbait, nor am I writing it to boost SEO performance or fill space. This topic serves a very important purpose — to build a solid foundation.
Before we define a computer, let’s first establish why we need to understand what it is.
Computers are not magic, although they are pretty magical! As a programmer, you write code. That code — the software — runs on actual physical components — the hardware. Understanding these physical components will make you a better engineer.
Though in this chapter, we won’t define a computer in the traditional sense. We’ll look at it from a different, unique perspective that makes programming intuitive for you.
There are two ways to define anything — one is by its purpose and another is by what it is.
For example, let’s say we wanted to define a chair. A chair is an object that allows convenient seating for humans — that’s its purpose. Physically, it’s an object with legs, usually knee-height, with a horizontal seat, and optionally, it may have armrests, back support, cushioning, wheels, etc.
If we were to define a computer by its purpose, the list would be endless. Everyone uses a computer differently — to watch movies, browse the internet, edit videos, do accounting, write code, and so on.
But at its simplest form, a computer is just the CPU and the RAM.
CPU is the processor — performs calculations and logical operations.
RAM is the memory – holds data and instructions needed by the CPU while working.
Imagine you asked someone who was born in a world without computers, “What is a computer?” Intuitively, they might answer, “A computer is something or someone that computes.” That is absolutely correct.
But now we need to define “computation”. A simple Google search says:
“the action of mathematical calculation.”
Let’s look at a very simple example of computation — the addition of two numbers:
x + y = z
If a machine or a device can add two numbers or perform other complex computations, then that machine would be called a “computer”.
If you expect a machine to perform this calculation, it would need two things:
- a memory that would store the values of x, y and z
- and a processor that would perform the addition.
In the memory, the user would feed the values of x and y. The processor would read those values from the memory, perform addition, and store the computed result back into memory. This memory and processor are essentially your RAM and CPU, respectively — exactly what we discussed earlier.
If you, as a programmer, were to write such a program that performs the addition of two numbers:
- You would need a base software that allows you to write this program and convert it into sequence of instructions that the CPU can understand, and execute it. This base software is the operating system — like macOS, Windows, or Linux.
- To type the program and provide input values for x and y, you would need a keyboard.
- To see the program you are typing, the inputs you pass, and the output you receive, you would need a screen. This is your monitor or laptop display.
- The program itself would be written in a language that computers can easily translate into CPU instructions, but also that is easy for humans to learn and build applications in. This is called a programming language — like C, C++, Java, Python, etc.
What’s truly amazing is that, at the very lowest level, if you go deep inside the CPU or RAM, it’s all just 0s and 1s. They are made up of billions of transistors. If a transistor has an electrical pulse, then it’s “on” which represents 1. If not, then it’s “off” which represents 0. Naturally, all the data stored across every data center and hard drive in the world which is potentially in zettabytes (ZB) is ultimately just — 0s and 1s.
The next most important component of a computer, after the CPU and RAM, in my opinion, is the storage device, i.e. the hard drive. The hard drive is where all the files and folders of a computer are stored.
The hard drive allows read and write operations on data. As we saw earlier in the example of addition, the RAM also allows read and write operations on data. Does that mean RAM and the hard drive are the same thing? Absolutely not. They serve completely different purposes. RAM acts as the working memory. It sits right next to the CPU and only contains data immediately needed by the CPU for the execution of currently running processes. The hard drive is permanent storage. Once data is written to it, it stays there until explicitly deleted by a user or a process.
Let’s say you’ve downloaded two movies — The Shawshank Redemption and Pulp Fiction. These two movies exist as files on your computer’s hard drive. You plan a movie night and decide to play Pulp Fiction. To play it, you need an application, for example, VLC Media Player.
Here’s what happens:
- The media player reads the Pulp Fiction file from the hard drive and loads it into RAM.
- Then the CPU and graphics card together will process this data from RAM and display the movie on your screen.
- While the movie is playing, both movies still fully exist on the hard drive, but only Pulp Fiction is loaded into RAM.
- If your laptop suddenly runs out of battery and shuts down, the next time you power it on, both movies will still exist on your hard drive — but not in RAM.
A couple of notes from the above example:
- A graphics card is a specialized hardware component responsible for rendering images, videos, and animations on a computer’s screen for a smooth, high-quality experience.
- Of course, if the movie file size is, say 1.5 GB, it would be inefficient to load the entire file into RAM. The media player is typically smart enough to load only a small portion of the data from the hard drive into RAM — the part currently playing — and continue loading as playback progresses. You may know this process as “buffering”.
You may be wondering why we haven’t mentioned anything about the motherboard, which is often referred to as the “heart” of the computer. That’s because it doesn’t really do anything by itself. It’s simply a circuit board that connects all the important components together like RAM, CPU, etc. Think of it like the road system in a city.
The CPU is often called the “brain” of the computer. Animals, too, have a heart, but it’s our brain that truly sets us apart.
Personally, I like to think of the CPU, RAM, and hard drive combined as the brain of the computer. This is because a human brain stores memories of the past like a hard drive, stores data received through our senses in working memory like RAM, then processes it and responds accordingly in real-time like a CPU.
In the next chapter, we will look more deeply into certain terminologies like RAM, CPU, operating system, hard drive, etc.