This strand is at the core of how computer science gets done. Programming is how humans give instructions to the computer, directions are encoded into commands that the computer follows. Everything a computer does is encoded.
This idea of encoding directions is not unique to computer science. Throughout human history people have used encoded information to collect and transmit step by step instructions. The industrial revolution moved production from handmade items, to the use of machines. This eventually became the modern assembly line, where following exact steps produces predictable results in terms of product quality.
This examples highlight central elements of the practice of computer science. Larger problems need to be broken down, or deconstructed, so that the steps can be repeated and produce consistent results. These steps can be encoded as specific instructions. In the case of a factory each stage represents a small step in creating the final object.
In other examples these step by step instructions are encoded using some type of written instructions. In music composers write out the notes for musicians to follow that include information about how fast or loud to play. Written musics also includes information about repeating sections. We will see this same structure in programming, called loops.
It is helpful to remember computers are basically dumb boxes (despite all the buzz about artificial intelligence). They need exact instructions, in the right order, to produce correct results. All software used, from a web browser to an app on a phone, is written by a person or team of people using programming languages.
Encoding is changing information from one form of information into another. Writing letters to represent sounds is a form of encoding, just like elevator buttons represent the floors of a building. Writing programs includes creating the steps we need a computer to follow, then encoding them using a programming language. These commands must be exact, they have to do the exact same thing every time. This predictability is what allows us combine commands to design algorithms.
Algorithms are step by step instructions that produce a result. Humans use algorithms to decompose processes into step by step instructions, and often algorithms are used to create processes that can be automated.
In the context of computer science algorithms must:
- Use a common set of instructions that are clearly defined and produce consistent results.
- In the context of programming these are the commands. They are precise and understood both by the human programmer, and the programming environment (like Scratch or Python) that translates them into commands the computer will run.
- The instructions are carried out in the correct order to produce the desired result.
- Think about putting the ingredients of a cake in the oven without measuring and mixing them first. The steps may be correct and clear, but the order will not a cake.
- Produce a result and eventually end
- If you have ever had a mobile phone or a laptop freeze and need to be rebooted, you have likely experienced an algorithm not ending correctly.
Programming languages are created by people and used for different purposes. For example Python is meant to be an easy to read language that can be used to create application for computers and on the web. On the other hand R was created specifically for doing statistical programming, and is often in the sciences to process data. These are both examples of text-based languages, where the commands are typed into the computer.
Another interface for programming are the block based languages where the programmer drags blocks and puts them together in a specific order to create programs. There are several advantages at the elementary level, including the ability to quickly create interactive graphical programs and avoiding typos and spelling mistakes. While many of these were developed to be teaching tools for students, some university classes now also use them for computer science courses. Examples include Scratch, Code.org’s AppLabb and StarLogo Nova for Project GUTS.