Back • Return Home
Computer & Programming Basics
If you are reading this article, chances are high that you are doing so on an electronic device which is a type of "computer" (such as a "smartphone", "laptop", or "desktop"). In the most basic sense, a "computer" is something that "computes" (i.e.: does math). This doesn't tell us much about what is happening inside of that device though! While it might seem like a complicated subject, we will attempt to reduce it to something that is (hopefully) easy to understand. If any of it feels overwhelming, please take a step back and return to it later...
What Is A Computer & What Does It Do?
Generally, a computer is a machine that receives information (or "Input"), alters it according to some set of instructions, and then gives out a result (or "Output").
• "Input Devices" are things like a keyboard, mouse, digital camera, microphone, scanner, etc. They are all ways of receiving information.
• "Output Devices" are things like a monitor, speakers, printer, etc. They are all ways of giving out information.
In some cases, the thing which receives input also conveys output (e.g.: the touchscreen of a smartphone). Therefore, we will often encounter the term I/O (which is short for Input/Output). These are also sometimes called "Peripherals".
The main part of the computer that handles instructions is the "Central Processing Unit" (also known as the CPU or Processor for short). The information that it operates on is usually stored in one of two places:
1. The "Random Access Memory" (or RAM) is where instructions are held for immediate, short-term use
2. The "Hard Disk" is where information that has to be accessed less frequently is held for long-term use
Computers can also be used to transmit information to other computers. This is called a "Computer Network".
What Is Programming & How Is It Done?
"Hardware" refers to all of the physical devices which make up a computer, whereas a "software program" (also known as an "application" or "app") is a set of instructions that tells the hardware how to do some particular task. To write your own software is known as "programming" (or "coding"). In other words, we can get a computer to do pretty much whatever we want so long as we give it the proper set of instructions and the hardware is capable of carrying them out. Let's explore how this is done a little bit more...
All information within a computer is represented as numbers, zeros and ones, or "bits". This way of counting is called "Binary" (or "Base-2"). There is often so much information involved that it is helpful to represent it as larger numbers, usually groups of eight or sixteen. These ways of counting are called "Octal" (or "Base-8") and "Hexadecimal" (or "Base-16"), respectively. No matter what counting system we use, the representation of information as numbers like this is called "Machine Code".
To make the instructions easier for humans to understand, sometimes parts of this information will be represented as short words, abbreviations, or acronyms instead of only numbers. This is "Assembly". Different types of Processors will use a different form of Assembly.
Both Machine Code and Assembly are considered "Low-Level Langauges". By "low-level" we mean that the form that the instructions take is closer to how the hardware actually operates. To make it even easier to understand, and to be able to transfer instructions from one type of Processor to another, we can use a "High-Level Language". By "high-level" we mean that these ways of writing instructions are closer to something that a human would normally use to communicate (i.e.: "Natural langauges" like English or Mandarin Chinese).
The instructions written in High-Level Languages are called "Source Code". In order to work, Source Code must be "translated" into Machine Code through another piece of software. This piece of software is called an "Intepreter" (if that conversion process happens line-by-line), or a "Compiler" (if it happens all in one chunk). An Interpreter or Compiler is simply a set of instructions for altering another set of instructions (Source Code) to make them like another set of instructions (Machine Code). 😄 Yikes! That might sound confusing...
In summary, High-Level Languages are instructions that are "human readable" (i.e.: easy for people to understand), but must be turned into Low-Level Languages in order to be used by a computer (i.e.: made "machine readable").
Tools For Programming
While we could just type it out as a regular textfile, Source Code is often written within a piece of software called an "Integrated Development Environment" (or IDE). This software usually has extra tools that can make programming easier, such as:
• A "Linter", which checks the structure of the code; it might make suggestions as you type or "autocomplete" what you are typing
• A "Debugger", which checks the code for errors or "bugs" that keep it from working properly
• A "Runtime Environment", which allows one to test out code in "real-time" (i.e.: without having to exit the IDE and run the program separately)
• A "Virtual Environment", which allows one to group together all of the settings and extra files (or "Dependencies") that are necessary for the code to run
Sometimes writing code takes a lot of extra research and testing, no matter how "fluent" one is in that language. Thankfully, not all instructions have to be written "from scratch". A "Library" or "Framework" is a collection of reusable bits of code for particular languages to carry out certain tasks. Some related terms include:
• "Software Development Kits" (or SDKs) - These are like Frameworks, but for a specific kind of hardware (e.g.: one type of smartphone, VR headset, videogame console, etc.).
• "Application Programming Interface" (or APIs) - These are ways to connect to some pre-existing infrastructure or service, or for two pieces of software to communicate with one another.
General Concepts & Practices In Programming
In addition to getting a general idea of what each language is usually used for, one thing that I have found helpful is to get an understanding of some basic concepts that are applicable to most languages. For example:
In mathematics, a "Variable" is a way of showing that a whole range of different numbers is possible within an equation. It has a slightly different meaning in the context of programming. In programming, a "Variable" is a name that we choose to assign to some set of instructions. Assigning this name is known as "Initialization". We do this as a kind of shorthand. Anytime that we need that set of instructions, we don't have to type it all out again. We just refer to it by name.
Each programming language does Initialization differently, but it is a core concept within programming in general. Again, these ideas are very helpful to know! Here are a few questions that we can ask ourselves when we first encounter a new programming language to try to uncover them...
• Primitive Data Types
How are different types of numbers represented? Mathematically speaking, numbers can be either "Cardinal" (representing quantities), "Ordinal" (representing a place in a sequence - like "first", "second", "third", etc.), or "Nominal" (used as a name for something).
How do we create "Alphanumeric Strings" (sequences of letters and/or numbers) that can be "Concatenated" or "Parsed" (i.e.: combined or separated)?
• Logical and Mathematical Operations
How do we add, subtract, multiply, and divide numbers? How are decimals or remainders handled?
How do we form "Conditional Statements" (e.g.: "true", "false", "if-then")?
How do we start, stop, and repeat a process (i.e.: "Loops", "For Loops", etc.)?
• Data Structures
How can we organize and fetch information in Memory in different ways (e.g.: what is the difference between "FIFO" and "LIFO")?
How do we represent more complex step-by-step procedures by combining the above concepts?
Once these basics are understood, there are also some "good" practices to follow as we write code. Making it a habit to do these things from the outset will create a solid foundation for increasing one's skills in programming...
• "Pseudocode" is a general outline of what we need a program to do written in basic English. "Wireframing" is to draw out a flowchart of the logic that a program has to follow. It is important that we do this kind of planning before we start coding any detailed instructions in a particular language. This makes it clear what we need to know, and if we are writing code with other people, helps everyone to be on the same page.
• "Commenting" is to type notes directly into our code that give brief, yet clear explanations of what it does. Most programming languages allow us to "comment out" sections of text so that the computer does not interpret them as instructions. Commenting is helpful for refreshing our memory if we have to leave our code alone for awhile. It also helps others to understand our code more easily if they have to look over it. Again, the keys are brevity and clarity. More thorough explanations should be put within their own separate textfile if necessary. This textfile would be known as "Documentation" or a "User Manual".
On a related note, there are also ways of writing the code itself that make it easier to read and to understand. To give a quick example: The name of a Variable should be short, but also give some idea of what it represents within the context of the program. Further, typing these names out in "Camel Case" (i.e.: with a mix of lowercase and uppercase letters) or by separating words with an "underscore" symbol, can make them easy to read at a glance without using spaces.
easy_to_read, instead of
• "Refactoring" is to rewrite code without actually changing what it is doing. This makes it easier to read and to maintain (i.e.: to add more code whenever necessary). Ideally, we want all code to be well organized, structured into small chunks that are simple to follow. A tangled mess of instructions that are difficult to understand is known as "Spaghetti Code". As delicious as spaghetti is, this is something that we want to avoid as much as possible!
• "Version Control" is to periodically save the code as a separate file with a new name. Having different "versions" like this makes it easy to restore code if something gets lost (serving as a "backup"), or to revert back to a previously working copy if something no longer works for some reason (i.e.: for "troubleshooting" purposes). There are various pieces of software that can help with Version Control. Some keep track of code changes "locally" (i.e.: only on our computer), while others are "distributed" (i.e.: helping us to share or collaborate on code with other people through the Internet).
We cannot emphasize enough the importance of using a new name on each version, even if it is simply a larger number added to the end of it (e.g.: "version 1", "version 2", etc.). We have to be able to distinguish each file from one another! Another helpful practice is to put the version number as a comment at the very top of our code (in the "header"), along with a couple of words about what has changed since the previous version.
• "Optimization" is to make changes to code so that it runs more efficiently. By changing how something is done, sometimes we can do it faster and more easily. There is a bit of mathematics called "Big-O Notation" that can help us with Optimization. We won't get into the technical details here, but essentially, Big-O Notation relates the size of a task to how long it takes to carry it out. It is a measure of the "complexity" of an Algorithm. We can use this information to compare Algorithms so that we can choose the one that would be most appropriate for the task at hand.
Resources For Learning
All of the jargon and acronyms associated with computers can be misleading, making it seem like a much more difficult subject than it actually is. We don't need to have a deep understanding of mathematics or electronics to use a computer well or to be an effective programmer. The above concepts are more than enough to get started.
A simple websearch can bring up useful information on specific programming languages (e.g.: Python). Some languages are intended to be easy to use (e.g.: fig, Basic, etc.). We can even learn to create our own High-Level Language with very little prerequisite knowledge!
There are a ton of great resources for learning programming in general, such as (in no particular order)...
• Tech With Tim
• Programming With Mosh
• Neso Academy
• The Coding Train
For those that would like a deeper understanding, be sure to look into the field of study known as "Computer Science". Computer Science goes deeper into why programming languages are structured in the ways that they are, and how the computer hardware that they control works. For example, we might learn to build simple electronic computers "from the ground-up", or design more sophisticated Processors with some fun training in tools like "Hardware Description Languages" (or HDLs).
There are lots of useful websites dedicated specifically to the topic of Computer Science (e.g.: Teach Yourself Computer Science, Geeks For Geeks, etc.), as well as many helpful resources that get into how computers work with varying levels of detail:
Books (Free ones are marked with -$)
• Douglas J. Alford - Computer Come-Froms: The Roots of Real-Time -$
• Douglas J. Alford & Pakaket Alford - Science Inside Computers: Flow, Glow, & Stow Data -$
• Ernie Dainow - A Concise History of Computers, Smartphones, and the Internet -$
• Ernie Dainow - Understanding Computers, Smartphones, and the Internet -$
• David Tarnoff - Computer Organization and Design Fundamentals -$
• Jonathan Bartlett - Programming From The Ground Up -$
• Tom Johnson - The Computer Science Book -$
• J. Clark Scott - But How Do It Know?: The Basic Principles of Computers for Everyone [Accompanying Videos]
• Charles Petzold - Code: The Hidden Language of Computer Hardware and Software [Borrow the eBook]
• Ron White - How Computers Work [Borrow the eBook]
• Jonathan E. Steinhart - The Secret Life of Programs: Understand Computers, Craft Better Code
• Matthew Justice - How Computers Really Work: A Hands-On Guide to the Inner Workings of the Machine
• Clive Maxfield - The Definitive Guide to How Computers Do Math
• H3Vtux - How Computers Work, Basics Explained
• Crash Course - Computer Science
• Domain of Science - Map of Computer Science
• Brian Will
• Sebastian Lague - How Computers Work
• Ben Eater - Building An 8-Bit Breadboard Computer
• Forrest Knight - The Open Source Computer Science Degree
• The MIT OpenCourseWare Playlists have a ton of educational material for free, like...
+ Introduction to Computer Science and Programming (Fall 2008; Spring 2011)
+ Introduction to Computer Science and Programming in Python (Fall 2016)
+ Introduction to Electrical Engineering and Computer Science (Spring 2011)
Computer Science and "Software Development" often overlap. Therefore, some of the general programming resources linked to above may have things related to Computer Science too (e.g.: freeCodeCamp's Introduction To Programming & Computer Science, the Harvard CS50 Course, etc.).
Computers are so ubiquitous that it can be helpful to develop some level of "computer literacy", and if we take the time to learn some simple programming skills, we can get so much more out of our computer use. Computers are incredibly powerful machines. We sincerely hope that this article has assisted you in tapping into that power in a way that is both interesting and enjoyable for you.
Thank you for reading! ❤️