Do you ever hear people discussing computers or technology and think to yourself, “Wow, I have no idea what these nerds are talking about, but they sure do sound smart.”? Or maybe even, “Wow, I wish these nerds were socially aware enough to change the subject.”? If you’ve ever found yourself in those shoes, you might benefit by developing some basic computer literacy.
The computer is incredibly fast, accurate, and stupid. Man is incredibly slow, inaccurate, and brilliant. The marriage of the two is a force beyond calculation.
Leo Cherne
I hope to make this post the beginning of a longer series about learning how to write computer programs. I’m starting out by covering basic computer literacy because it is important to have that foundation in place first. After all, how can we write programs for computers if we don’t really know what they are? Let’s start by tackling a few key terms.
Hardware vs Software
The first important distinction we need to make is the difference between hardware and software. To put it simply, hardware has physical form. You can hold it in your hand and tinker with it. Some examples of hardware include a keyboard, a mouse, a screen or monitor, a graphics card, or a CPU (Central Processing Unit).
Software, by contrast, does not have a physical form. It exists only as information stored inside the computer. Some examples of software include Facebook, Twitter, Gmail, Microsoft Excel, your web browser, my silly JavaScript games, and of course Flappy Bird. As budding computer programmers, our goal is to learn how to produce robust, useful software.
What Is A Computer?
A computer is a device composed of hardware that is powered by electricity. Its purpose is to store, retrieve, and process data. Data is just another word for information. Without data, a computer would just sit there with nothing to do. A computer could be many things, including your smart phone, your laptop, or a web server.
Programmable
One unique aspect of a computer is that it is programmable. This is the property of the computer that we are the most interested in because we want to control how data gets operated on through the programs we write.
Most modern computers are designed based on the von Neumann architecture. Why am I telling you this? Mainly to look smart, but also because this architecture is what allows us to store both data and the instructions for operating on it (programs) in the same memory. This flexibility is what allows for so many awesome programs to run on the same computer. It would be a real shame if computers had to be totally rewired each time you wanted to switch between programs. Before our boy von Neumann came along, that’s what we had to do.
Digital
Computers are digital. What this means is that the data is stored in memory via a very large number of switches. These switches are more formally known as transistors. Each of these transistors represents something called a bit, and can be found in only one of two states, on or off. These bits are then gathered into groups of 8, which we call a byte. Computer memory is just a big pile of bytes. As the number of bytes grows we start using bigger units to measure them, like kilobytes, megabytes, gigabytes, and terabytes.
The two different states of a bit are represented by a 1 and a 0 respectively. You may have heard people refer to “ones and zeroes” when talking about computers. This digital aspect of computers is what they are referring to. Thus, understanding how binary numbers work can be helpful, especially when writing programs at lower levels of abstraction. Every piece of data we deal with, from personal demographic data to the colors you see on the screen, is ultimately represented by a series of ones and zeroes stored in memory. Fortunately, this design detail is usually hidden from us when we are programming with higher level programming languages.
Programming Hello World
That about wraps things up, but first I want to give you a small taste of things to come if you decide to learn more about programming. You are going to write your first program, and you don’t even have to leave this page!
When learning to program in a new language or environment, computer programmers often write a program called “Hello World!”. This is the simplest program you can write. It simply prints out the text, “Hello World!” to the screen. You are going to write your first “Hello World” program directly in your web browser.
If you are reading this on mobile, now would be a good time to switch to your laptop or desktop computer. Once you have done so press the F12 key on your keyboard. This will launch the developer tools for your browser. In the example I used Mozilla Firefox, but this keyboard shortcut should work in whichever browser you are using. You can also get there by right clicking on your browser window and choosing the appropriate option. Next, navigate to the console tab of the developer tools and type in the following: alert(“Hello World!”).
In this case, alert tells the browser to alert the user of something via a dialog box. We are passing it some data, in this case the text, “Hello World!”. This data is what we are going to show to the user.
Once you have that typed out, press the Enter key on your keyboard. You should see something pop up that looks similar to this, minus my shameless plug:
Summary
Congratulations! You have gained some basic computer literacy and you have written your first program in a language called JavaScript. JavaScript is one of the most popular languages in the world, and it is running on almost every website you visit. It’s also a language I have used extensively in my game tutorials.
Leave a comment below if you had trouble with any of this so myself or somebody else can help you out. And remember to subscribe so that you can stay notified of new content and move on from basic computer literacy to an even deeper understanding of how they work. Continue on to the next post in the series to start learning more about data.
First time visiting your website, I like your blog!
Aw, this was a very nice post. Taking the time and actual effort to produce a very good article… but what can I say… I hesitate a lot and don’t seem to get anything done.