How do I learn to write code?

Can I learn to code?

Absolutely! Saying somone can't learn to tell a computer what to do and how to do it, or learn any other skill for that matter, is selling them (or yourself) short. Natural abilities might affect the starting line and the pace, but marathons are won with fortitude, time, and patience. And learning to code well is definitely a marathon.

What's the best way to learn to code?

There isn't one! If that's disappointing to hear, there are plenty of sites with their own magic formulas. Take it all with a grain of salt. No two people have the exact same talents or ways of absorbing knowledge, internal drive or tolerance for roadblocks. That being said, some ways are more fruitful than others.

Where do I begin?

If you've never written a line of code before, try copying the following text into a file, name it "hello.html", and open it in your browser. Click the button and watch your alert message pop up. Voilà, you've coded! Empowering, huh?

        <title>Hello world!</title>
        <button onclick="javascript:alert('Greetings!')">Hello!</button>

Be patient; give yourself credit

Writing code is easy. Learning to write code is not. Understanding the simple example above means learning about markup language, event handlers, and some basic JavaScript. There may be times you'll wonder whether you really know anything, or at least whether you know the right stuff.

We're always in between what we already know and what we'd like to know, and both sides are growing all the time. There's always going to be a new language, framework, or methodology to learn (especially with JavaScript), but you'll find that the fundamentals don't change much.

Take a step back once in awhile to think about what you've accomplished, so you don't get overwhelmed with what you want to learn. I occasionally write about my small wins for the week. For you, maybe it's a journal, or finding someone to talk to.

Oh, and one more thing. Remember that sites like StackOverflow do not represent all that you must learn. It's a repository, like Wikipedia or Quora. Thinking that anyone on there is knowledgeable in everything, and that you must be too, is a recipe for mental disaster.

Break down the problem

So, back to that problem you're trying to solve. What is it? A small process to automate? A problem your friend mentioned? Some societal or environmental issue? Greenfield development in a new project at work? A bug in an old codebase? Do you know what the problem is? What a solution might look like? How you'll get there?

I've been writing code for over a decade, and I still regularly get overwhelmed with projects that are out of my depth. I've gotten better at catching myself staring at the screen with a vague sense of "where the @#$% do I begin??", and realizing when I need to break down the problem.

It doesn't matter if you're working on a huge app with a team at a large company, or your own project in your spare time. Break down what you're trying to do into smaller steps, then rinse and repeat until you feel like you've got something you can actually dig into and start attacking.

If you can't get there, well.. that tells you something too. Maybe you're not exactly sure what the problem is, or what the required solution should look like.

  • Can you describe the problem in a single sentence, or a few?
  • Can you describe what a solution might look like in a few sentences? How would it fix the problem? How do you envision someone using it?

Don't worry about the details at first - just think about where you'd like to end up, then break the 50 mile journey into short jogs, then individual steps.

Pick a direction and run

Doing something isn't the frustrating part... figuring out what we're supposed to be doing and the best way to do it is.

If it's a small problem, find a decent tutorial and dig right in.

Making Your First Chrome Extension
We all have our favorite web browser with our favorite extensions loaded, but have you ever considered writing your own? In the past few months I’ve created a couple extensions to suit my own needs. Here’s what I’ve learned!

The problem you're trying to solve usually dictates the tools you need to learn to use. You wouldn't build a car with wood (well, not anymore) or a bookshelf

Hello world.

Don't sweat the small stuff - tabs vs spaces

Like anything else, programming can be hugely satisfying one moment, and incredibly frustrating the next. As time goes on though, things that used to trip you up won't anymore. You'll see patterns and similarities, and one day you'll even find yourself helping someone else who's struggling to learn too.


Grant Winney

I write when I've got something to share - a personal project, a solution to a difficult problem, or just an idea. We learn by doing and sharing. We've all got something to contribute.