Joined: 19 Dec 2002
|Posted: Tue Jan 28, 2020 11:38 pm Post subject: Learning to Code is Easy
|Learning to Code is Easy: Hereís How to Teach Yourself
It is a new language but you shouldnít feel discouraged, coding is more accessible than you might think.
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.
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:
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.
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.
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.
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:
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.
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.
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:
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.)
Attend a MOOC. Coursera, edX, MIT, Harvard, Stanford 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.
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:
Learning to code is much easier than most non-coders think, at least to make simple stuff.
The main reason it seems hard is because:
Setting up is frustrating.
There are too many options to start.
Early classes are populated with self-taught whiz-kids who make you feel dumb.
To teach yourself you should:
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.
Start immediately with a concrete project to build something small. Books, courses and tutorials should help you get to that point.
When you get stuck, do what everyone else does and ask Google
But donít copy-and-paste the answers.
And try to solve it for yourself first.
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.
This article was originally published on July 8, 2019, by Scott Young.