Feature: The Basics of Coding

Not a month goes by without someone writing a thinkpiece stating that kids need to learn to code. Even Obama said, “everybody’s got to learn how to code early,” in an interview with Re/code. But why do people need to learn to code? How can they get started? And, more importantly, what is code anyways?

What is code?|

It’s hard to learn how to code if you don’t even know what it is. Code is what makes a computer do things. If you’re reading this online, there is code that makes the text show up on the webpage. There’s code that runs the browser you’re using, whether it’s Chrome or Firefox. There’s code telling your operating system – OS X, Windows, iOS, Android, etc. – what to do. There’s really low level code telling your computer’s processor how to handle the information it’s receiving from everything else.
People wrote that code. They wrote code for your computer, phone, car, watch, TV, and probably a million other things you interact with daily that you don’t even think about. Code is everywhere. Of course, when someone says everyone needs to know how to code, they’re probably not talking about coding your car. Please don’t try to mess with your car’s computers. 

Why learn?|

It’s easy to think of coding as only being useful for programmers, software developers, engineers, and other high-tech jobs. But coding should be viewed like writing. Sure, there are professional writers, but many other jobs can benefit from writing skills. If you’re applying for any office job, adding programming skills to your resume can help you stand out. They imply that you know your way around computers and that you can solve unique problems to speed up the work process.
As an example, when I was The Gateway’s photo editor, I found that I was repeating the same steps for every photo I edited. This could be 40 or more photos per press night. Editing them for print required a specific series of steps for every shot to look great on the page. The process didn’t just take long, but was prone to errors if I missed any of the steps, which was bound to happen due to interruptions at our busy office. Luckily, you can write scripts for Photoshop, tiny pieces of code that run within other programs. I wrote a script that stepped me through every part of the editing process, improving my efficiency and decreasing the amount of errors I made.
Apart from job skills, you might also just find that you like coding for fun. Tinkering with things is satisfying, and programming is no different. You’ll learn a lot about computers and the new, modern world we live in. You’ll start to realize why programs you use sometimes crash, or why they get slower the longer you have them open. Or you could just pick up an Arduino or Lego Masterminds kit and build your own robots.

Why not?|

We’ve heard all about how everyone needs to code, and like I said before, I think it’s beneficial for a lot of people. But it’s not a necessary life skill. Some people don’t like or aren’t good at writing, taking photos, music, etc. The same goes for coding. Nobody should feel pressured to get into it, or inadequate if they can’t, just because Obama said they should.

How do I start?|

First you should decide what kind of programming you want to do. A lot of people get stuck here because they’ve never done it before, so they can’t decide where to start. I don’t recommend starting with Java, C, or C++ because they can be overwhelming for beginners. Instead, you can learn the basic concepts and branch out when you feel the need to. That’s why I would recommend Python, which is also what the University of Alberta’s Computing Science department starts with in their introductory course, CMPUT 174.
If you’re interested in taking a course at the U of A, CMPUT 174 is a good place to start.


To actually start writing code, you’ll need a text editor. I don’t mean Microsoft Word; you need a program that saves only the text, not any of the formatting. Your computer probably comes with one, whether it’s TextEdit on Mac or Notepad on Windows. These aren’t the greatest, so I recommend downloading Brackets or Sublime Text. A good text editor will make coding much more enjoyable, can sometimes catch mistakes you make, and most importantly, colours the text based on what it does.
Now you can start writing Python scripts. But you won’t be able to run them without knowing how to use the Terminal in Mac, or PowerShell in Windows. You’ll also need to install Python itself if it’s not already on your computer. The online book called Learn Python the Hard Way at http://learnpythonthehardway.org/book/ex0.html has a good tutorial on getting set up with Python.


Following through the rest of Learn Python the Hard Way is a good way to get started and really learn to code. But if you just want to give the coding a try without any of the other overheard, you can try the tutorials on Codecademy http://codecademy.com. Their tutorials don’t just cover Python; you can learn basic to advanced web development skills by following them.
It’s easy to find tutorials by using Google. But whenever you follow them, make sure you type the code yourself instead of just copying and pasting. You’ll be able to remember what you typed better than if you just read it.
Also, if you ever get stuck, just search the language and how you got stuck. You’ll likely find a link somewhere, but more often than not, you’ll end up on Stack Overflow. This site is a good place to ask questions, but make sure you’ve tried everything and looked everywhere else first — otherwise, the community will tell you to go find out yourself.


Here are some basic terms that you might encounter as you start learning about code.
Language: Used to communicate to a computer. Different languages can do different things, and all have pros and cons.
Compiler: Understands the language, deciphers the code, and turns it into a program that does what the language told it to do. Some languages don’t need compilers. They usually do some level of error-checking to make sure the program will work.
Variables: Variables are used in language to represent values. So if you say “x = 10”, x can be used anywhere to represent the number 10. If “y = 5”, then “x + y” would equal 15.
Type: Type refers to the type of variable. Some languages need variables to be defined as numbers such as integers, characters, or strings, such as “int x = 5” or “string name = “bob””. Other languages are dynamically typed, meaning the programmer doesn’t have to specify which type a variable is. This can be convenient, but can introduce issues that would’ve been caught by a compiler.
If Statements: If statements are used to control whether things happen. They are usually in the format: “if (something happens) { do this thing } else { do something else }”. The “something happens” part is called the condition.
While Loops: While loops also have a condition. They’re in the format: “while (something happens) { do these things }”. They’ll keep doing whatever they’re supposed to do while their condition is true, so make sure there’s a way out if you use one of them.
For Loops: For loops are similar to while loops, but have a built in escape condition based on counting. They’re good for doing something a certain number of times. They’re in the format: “for( starting number; until; increment) { do these things }”. Every time the for loop completes, the starting number goes up or down based on the increment. The for loop stops doing it’s thing when it hits the until condition.
Functions: Functions are pieces of code that you want to be able to run over and over again. They’re in the format: “function name(parameters) { do things }”. They can then be called with “name(parameters)”. This means you could define, for example, a function that multiplies numbers, then call it anywhere else in your code. The parameters would be the numbers you want to multiply. Functions can be hard to understand, but once you start using them, you’ll see why they’re one of the fundamental parts of programming.


  • What’s the difference between computer science and programming? Computer Science – or Computing Science at the U of A – also teaches logical concepts beyond practical programming skills. It’s like the difference between math and accounting.
  • Do I need a comp sci degree? You don’t need a degree for anything to learn how to do it, but if you want to do something professionally, a degree will help you prove you can. Coding is no different. Get a degree if you want a job as a software developer.
  • Can I get a programmer job by just knowing how to program? It depends. Many jobs will have a technical interview component to determine if you know what you’re doing beyond just hammering out code. So you’ll have to know some basic algorithms and then be able to apply them.
  • What are some resources to learn about those algorithms? Cracking the Code Interview and Programming Interviews Exposed are good books to learn from. I also recommend going to reddit.com/r/cscareerquestions to get career help.
  • How do I get into game development? Coding is one way to get into game development. The U of A offers a great course called CMPUT 250, which is part of the Computer Game Development certificate. Also check out GameCamp Edmonton for their hackathons, where people come together, form teams, and build games in a few days — or even a few hours.

Python Code Example|

You can try out the following sample code by pressing Run in the below window. Click Code to go back to the code. You can also edit things in the code to see what happens. Try reading the comments to figure out what things do.

Be careful of what you change things to. If you change the value of “a” to a different value without changing the while loop, the script might crash your web page because the loop will never exit.

One Comment

  1. As someone who has just introduced themselves to programming and learning languages in general, I find this article just brilliant. Thank you Kevin Schenk, and thank you Gateway!

Related Articles