Computer code may seem complicated, however, it’s actually very easy and intuitive to get started with. Code is like a recipe, or set of instructions on how to get something done. For example, a recipe for cookies might start with getting a list of ingredients, setting the oven temperature, then mixing the ingredients together. This is similar to computer code. When you program, you are essentially telling the computer what to do and where or when to do it, very similar to how a recipe tells you how to make something.
Computer code needs to be written in a very specific way for it to work. The computer does not understand English or any other human language, but a programming language. This is a set of rules and guidelines for the computer to follow when reading your instructions. It’s similar to a normal language, but it includes specific formatting and syntax rules that require very specific instructions to work.
For example: let’s look at an example written in the python programming language. This is one of the simplest languages that a computer can learn. This excerpt of code uses the built-in instruction called “print” to have the computer output text. The argument of the instruction “Hello world!” is the text to output. In this case “Hello world!” will be outputted, or printed to the console.
A simple python program. (Cameron Brian)
This is a more complicated example, but still easy to grasp. This first line of code tells the computer to add three plus four, then store the result in the “number” variable. A variable is just a substitute for a number which can be used later. Then, the if-statement on line three says to only execute the last line if the number variable is equal to seven. Because three plus four is equal to seven, the last line runs, and the statement “three plus four equals seven!!” is printed to the console.
Although the examples may look complicated, that is only because the code is written in a programming language that most people do not understand. However, simplifying this code to the English language can make it a lot easier to understand.
“Think of the number that is equal to three plus four. If the number you are thinking of is equal to seven, print ‘three plus four equals seven!’ to the console.”
This english example is the exact same as the previous example. However, because it is written in plain English instead of a programming language, it is much easier to understand. Looking back at the previous example, see if you can figure out how it works based on the English one.
Just like humans, computers use language to read instructions and to be told what to do. However, computers are better than humans in the concept of repetition. A computer can repeat something hundreds of thousands of times without slowing down or getting bored, but a human can only take so many repetitions before a break or at least a slowdown is needed.
For this reason, programming can be very useful. A program can sort your emails or documents, calculate things fast, and perform many boring everyday tasks for you. All it takes is for you to learn how to program, and take the time to learn and write some code.