Technical Education Post

News and Information for Technical Educators

Learning to Code is Easy: Here’s How to Teach Yourself

Few skills scare people away like coding. Television portrayals make it seem like writing computer code is a genius-level activity, as weird symbols race across the screen and techno music blares in the background. By Scott Young.

But the truth is that coding is actually pretty easy.

I’m not saying this to dismiss the work of brilliant programmers. A skill can simultaneously be fairly easy to get the basics in, while also being really difficult to master. Everyone learns to write, few people learn to write well. There’s no contradiction, therefore, in saying that basic literacy is an “easy” skill to acquire (in that the vast majority of us are able to do it), without dismissing the efforts of talented writers.

Nor am I saying this to mock people who are trying to learn programming and find it frustrating.

Rather, I say coding is easy because I believe that almost all people, even if they don’t see themselves as particularly smart, have the ability to learn to write simple programs. That they don’t is mostly due to some structural barriers than any intrinsic difficulty with the skill itself.

My Experience Coding

I’ve been writing programs for over half my life. I’ve taken a couple university classes. I even worked through the content of a CS degree online (which is totally unnecessary if you want to learn to code, by the way).

In some ways, my background may seem to disqualify me about making statements on the ease of coding. However, I can say, without a doubt, that subjects like engineering, accounting, physics and law are more difficult than programming. Most math you learn in high-school is more difficult too, although you usually get waaay more practice with algebra than code, which often leads to a misperception as to which is more difficult.

Why Coding Feels Hard

Learning to code is hard for a couple reasons:

  1. Installing new languages is super frustrating. This is the first activity for a would-be programmer and, to this day, the thing I hate most about programming. This can create the misperception that programming is really hard because newbies extrapolate the difficulty of getting set up to how it will be every moment after.
  2. There are waay too many languages, tools, libraries and plug-ins. Starting programming is super overwhelming because there are a bajillion things to learn and you have no idea where to start.
  3. Early classes tend to be populated with people who have taught themselves programming before. Thus, you may think you’re not smart enough to program because of an unfair comparison. (I once knew a woman who got a masters in civil engineering, which is much harder than intro coding, and she told me she wasn’t smart enough to code because of her first class. This is bananas, and yet people fall for it because some nerdy kid has like ten years of experience before the class starts.)

The first moments of programming are the hardest. Getting set up is annoyingly difficult and often requires learning a new way of working with computers even before you write a single line of code.

Consider the instructions for installing most languages. Open the terminal or command prompt. Type in a case-sensitive exact set of instructions to download and install the language. Use GitHub. Homebrew. Versions matter too. Are you running 32 or 64 bit? ‘Cause if you’re not sure it will crash with a cryptic error message and you’ll feel like an idiot.

These tools are learnable, like everything else, but they reinforce the impression given by television that coding is mostly using esoteric tools with weird, unfriendly user interfaces. When people see coding they imagine parsing the green-streaming letters of the Matrix, whereas the truth is a lot more like following a recipe along step-by-step.

How Do You Get Over the Initial Difficulties?

There’s a few ways you can do this. My favorite is to just buy a book that will tell you exactly how to set up a language step-by-step. Most ones from the bookstore will teach you the installation process, and if you can be meticulous at following them you’ll usually be successful.

Alternatively, you can dive into internet tutorials, but recognize that sometimes they are aimed at already-proficient programmers, who know what Homebrew and GitHub are, and are fluent with writing commands into Terminal. If you get one of these, you can try to follow it, but don’t feel bad if you screw it up. It’s frustrating and it doesn’t mean all coding will be like this.

Another option is to avoid setup at all. Just use some coding tutorial website that teach you to code without needing any installation. I like this too, but sometimes you can’t actually build the thing you want to build with these apps. However, if you hate the setup, that’s where I’d start.

Most important, however, is to remember that I told you this. When you try to learn to code, it will be frustrating to get set up, and just accept that this is a small price to pay. Soon it will be easier and you’ll do stuff that is cool. Don’t feel dumb because you get stuck here, I still do and I’ve been writing code for years.

What Language/Tool Should You Start With?

This seems like a good question to ask, but, I’d argue, it’s actually the wrong way to think about learning programming.

First, despite the fact that programmers often boast about how many languages they know, recognize that most languages are only superficially different. Yes, I know all about language design, so don’t tell me about the importance of scripting versus compiling, or whether a language is strongly or weakly typed. Those things matter, but they’re details.

The basics of nearly all languages and tools are the same. Variables. Loops. Functions. Pointers. Stack. Trees. Hashing. Recursion. These concepts exist in most languages. If you pick a mainstream language, you’ll learn these in mostly the same way, so it doesn’t matter if you pick Ruby, Python, C++, Java or PHP.

The place languages do matter is what you want to use them for. Want to write iPhone apps? Swift or Objective C are the languages of choice. Need to create web pages? JavaScript is going to come in handy. Yes, you can use almost any language for any task if you tinker with it and get the right plug-ins. However, some languages are easier to get started with certain types of projects than others.

Therefore, the first question to ask is not: which language should I learn, but, which project should I start with?

What Should Be Your First Project?

I recommend starting your programming adventure, even before you write a single line of code, with a decision about a concrete programming project you’d like to create.

This serves a couple purposes:

  1. It narrows down the language/tool choices considerably. Once you know you’re building a website, you’re already leaning towards tools that were designed with that goal in mind.
  2. Everything you learn is connected to a destination. As I document extensively in my book, transfer of learning is notoriously difficult. Learning directly works better than learning something and just hoping it will help you later.
  3. You can work on something you think is cool. If you think it would be cool to make an interactive website, do that. If you’d prefer a game, do that. If you’d prefer to automate your accounting work so you’re done in half the time as your colleagues, do that instead. Do what you feel is cool and you’ll be motivated to stick to it.

In general, smaller is better when it comes to projects. Deciding to start with making the next Google is ambitious, but probably will get you stuck in the weeds before you make much progress.

If your true ambitious are huge, it’s often best to work on a toy project first. Many experienced programmers still do this when they are entering a new territory of programming. Toy projects take the essential ideas of programming, but turn it into something you can do in a few days or weeks, instead of years.

Examples of good projects include:

  • A basic text-adventure game. No graphics, but still requires learning concepts like loops, variables, input-output processing.
  • A simple website. Start with just displaying a static page. Maybe add in comments, users, photos or interactive elements as you learn more.
  • A simple app. What’s something dead-simple you’d like to have on your phone? It can be stupid to start, don’t worry.
  • A script for automating a tedious task.

In general, programs are easier when they involve no multimedia content (websites are a bit of an exception), so if you’re making a game, for instance, a text game tends to be easier than one with graphics, if only because making all the graphics can take time.

Similarly, different core activities have different difficulties. Arithmetic and simple calculations done repeatedly are easiest. Processing text for exact patterns is a bit harder. Processing text for vague patterns is harder still. Processing, speech, photos and video is even harder.

If you do end up picking an initial project that turns out to be super difficult, it’s okay to scale back. “Make an application that calculates my mortgage payments” is much, much easier than “Make an application that can tell you what someone’s hairstyle is from a photo.” It’s often not obvious that this is the case in the beginning, so don’t worry if you accidentally pick a “hard” problem to start with, you can adjust it later to something easier.

Which Resources Should You Use?

Once you’ve picked a project, the next step is to get some resources to help. This is a step many people worry over endlessly, but like the language choice, it’s a lot less important (and depends more on your goals) than you think.

I won’t list specific resources, because there are so many good ones that my suggestions are going to leave out some of the best. Instead, here’s three strategies for finding good resources:

  1. Get a book that teaches you the language + project you want. There should be a computer section in your local bookstore or library, you can just pick any of those. I like O’Reilly, but there are lots of good ones. (If you haven’t figured out which language yet, just Google your type of project and look for suggestions.)
  2. Attend a MOOCCourseraedXMITHarvardStanford and others all teach computer programming online. Once again, the thing that matters most isn’t the exact class, but whether it teaches the language/project domain you care about.
  3. Take a tutorial program/website. Again, there are tons of these. I used Google’s for Python the first time I wanted to learn Python.

Stressing over which book or course to pick is the wrong thing to worry about. The main thing to do is to use the book or course to learn enough to start tinkering on your project, not to master programming on its own. Starting your project before your ready is definitely the way you should feel about it.

Do What Real Programmers Do and Ask Google

Once you actually get started writing code, you’re going to encounter many, many situations where you either don’t know how to do something, or you learned how to do it before and you’ve forgotten.

In these situations, you should do what real programmers do: ask Google. This isn’t a shameful activity, but a part of real programming. I’ve been coding for years, but I always forget silly syntactical things and so I find myself googling regular expressions over and over again. It’s not bad, it’s just part of the process.

Once you’ve gotten yourself installed, you’ve learned a bit with your book to know the basics and have started working on your first project, you’ll learn the rest by googling and adding to your library of programming knowledge. Computer science theories, detailed understandings of the language you’re working with or advanced design patterns can wait until you’ve finished a few real projects and feel like you can code something.

Caveat #1: Don’t Copy-and-Paste

A first piece of advice when it comes to this step is to never copy-and-paste. Copy-and-pasting is bad because you don’t try to understand the code you’re copying. If you have to transcribe, in contrast, you naturally ask yourself, “why this? why not something else?” Even if you don’t have a great answer immediately, typing things for yourself will open your mind up to the answer whereas copy-and-pasting shuts down thinking.

Caveat #2: Try it Yourself Before Looking for a Solution

A second piece of advice is to always try to solve something yourself before looking up how someone else does it. Most problems have many, many ways they can be solved. The challenge is that expert programmers often know a particularly concise, clever way, but that often isn’t the “obvious” way. This can lead to a trap where you see a clever solution that employs tricky syntax, think that there was no way you would have guessed that solution, and believe you couldn’t have solved it on your own. That’s usually not true, yet it’s an unfortunate side effect of looking up solutions before trying to find your own.

Should You Bother Learning Computer Science?

Computer science tends to be equated with programming, but in practice the two tend to be rather different. Comp sci tends to be a lot more discrete math, complicated algorithms and fundamental issues of computation. Programming is a lot more practical and hands on.

A lot of computer science professors, for instance, aren’t great programmers. This may sound like a professional failure, unless you realize that their job is mostly to prove things with a pencil and paper using math, rather than write usable code.

I did a whole project to learn computer science, so I happen to really like it. However, if your goal is mostly practical, I would not spend much time with it in the beginning. If you have done programming for a little while, and finished some real projects, then diving into advanced algorithms, theories of computation and discrete math topics can be really fascinating. But if you start with these, it can be easy to get overwhelmed.

Summary of Advice

This has been a longer post, so let me reiterate the final points before I go:

  1. Learning to code is much easier than most non-coders think, at least to make simple stuff.
  2. The main reason it seems hard is because:
    1. Setting up is frustrating.
    2. There are too many options to start.
    3. Early classes are populated with self-taught whiz-kids who make you feel dumb.
  3. To teach yourself you should:
    1. Decide what kind of thing you want to make (website, app, game, script, etc.) first, pick the language that fits best with what you want to make.
    2. Start immediately with a concrete project to build something small. Books, courses and tutorials should help you get to that point.
    3. When you get stuck, do what everyone else does and ask Google
      1. But don’t copy-and-paste the answers.
      2. And try to solve it for yourself first.
  4. Learn computer science classes only after making some things on your own.

If you can get through the initial frustration and build a little confidence, anyone can learn to code. What’s more, it’s a skill you can use throughout your life, even if you never become a full-time programmer.

Leave a Reply

Your email address will not be published. Required fields are marked *