Software & Sandwiches: Basics Pt. 2

Alright, so we’ve been over the major hardware components that make up a computer and how it stores and executes instructions.  Now, let’s talk about what those instructions are.

Let’s go back to what the MS-DOS manual1User’s Guide and Reference for the MS-DOS Operating System Version 5.0, copyright 1991 Microsoft Corporation says a computer is:

Your computer is made up of many parts called hardware.  Your hardware runs software – programs that translate the instructions you send to your computer into a language it can understand.

So software is the translator between human intention and specific processor commands.  When you hear the word “software”, you might think of things like the Operating System (OS), drivers, runtimes, and programs.  How do they fit together?

To answer this, let’s go make a sandwich.

Level 3: Programs

Ah, the top seems like a good place to start; big-picture ideas without having to worry about the tiny details.  With our sandwich adventure, the Program layer will be whatever recipe we’re trying to follow.  Sandwiches are pretty simple, so it really only consists of tasks like “Select Meat”, “Get Ingredients”, and most importantly, “Assemble Sandwich”.

This layer is the interface between you and your computer.  Your web browser, games, apps, word processor, and video editor all make up this level.  Programs are designed to work across any computer (with the right dependencies, of course).

Now, just like you can’t make every recipe in every kitchen, you can’t run every program on every computer.  If you’re missing an important instruction set, then the whole program fails.  Say your recipe calls to sous vide a steak.  Well, unless you’ve got the required appliances, you can’t follow the recipe any more.  And, sure, while you might be able to make do with simply frying it in a pan, you’ve changed the entire recipe now, something a computer can’t do on its own.  So when Solidworks2i.e. the best 3D CAD suite around needs some instructions found only in Windows, well, I guess I’m not getting it running on my Linux machine.

Level 2: High-Level Operating System

One step lower, this is where the building blocks of kitchen activities live.  This layer will include tasks like “Get item from fridge” with a list of ingredients {“Cheese”, “Ham”, “Lettuce”}, and “Get item from pantry” with ingredients {“Bread”}.  Other recipes you make use these same building blocks, and no matter what kitchen you go to, these building blocks are going to be there.  Every kitchen has different appliances available, so when a recipe calls for frying something in a pan, this can mean either “gas stove”, “Electric Range”, or “Induction Cooktop”.  This layer knows what’s available in the kitchen and knows what to ask of the low-level.  This layer also can see the instruction “Cook Rice on the stove” and realize the kitchen has an appliance that does this more efficiently, the Rice Cooker.

The High-Level OS handles the background tasks that the Program level uses.  This includes things like connecting to wireless networks, sending and receiving data from the internet, routing audio, and keeping a searchable index of the files on your hard drive.  These are called services and they break down the high-level commands from the programs into executable chunks3If you’re on Windows, you can see all the services running on your computer by calling up the Task Manager (CTRL + SHIFT + ESC) and clicking the “Services” tab on the right..

You may have heard of programming languages like Java, C#, python, etc.  These languages are nothing more than a collection of commonly-used building blocks that are bundled together into something called a runtime.  Now, technically, these runtimes are not part of the Operating System because they often use the services themselves.  But as far as explanations go, they work pretty much on the same sort of level as the services.

Level 1: Low-Level Operating System

While the High-Level OS just needed to know what appliances were available in the kitchen, the Low-Level needs to know how to use them.  This level knows exactly how many steps it takes to get from the countertop to the fridge, what shelf the cheese lives on, and just the right amount of force needed to shut the fridge door again.  This information is specific to exactly the layout of and the appliances in your kitchen.

Made up of buzzwords known as the Kernel and drivers, this is the lowest level that interacts directly with the hardware.  This translates the general commands from the higher levels into the 0s and 1s that form the explicit instructions for the processor.  This part of the OS handles the nitty gritty communications protocols needed to get all the pieces of hardware to work together and keeps track of the actual locations of data in the memory.

This code is compiled specifically for your hardware, meaning that the instructions stored are the strings of 0s and 1s that flip the right transistors in your CPU.  This means that this code generally cannot be run on other hardware.

Putting it all together

In general, program is a recipe of a bunch of different tasks that are defined for the specific system you’re using.  These tasks are then broken down into the 0s and 1s that make the right electrical signals happen in your computer’s actual hardware.

XKCD comic # 1349

So the next time you find yourself screaming “Why won’t this computer juST DO THIS SIMPLE TASK!!1!”, just remember, there’s a ton of interpretation between what you want and what the actual hardware is able to do.  And more importantly, the fact that any of this works at all is nothing short of a miracle.

TL;DR

  1. Modern computer software can be divided into 3 levels
  2. Each level gets progressively more specific to your computer
  3. Each level depends on the ones below it having the expected building blocks
  4. Making a sandwich is harder than it looks on the surface
  5. Related: There’s a reason we don’t have robot butlers yet

Leave a Reply

Your email address will not be published. Required fields are marked *