Learning to Code Online

Programming With Biscuits

Last week I wrote about the benefits of working on programming fluency. But before a programmer can work on fluency, they need to learn to program in the first place. Until recently, prospective programmers had to go through a complicated setup process to get their compiler and environment up and running. There’s something to be learned from that process, but it can be a stumbling block for beginners. These days, it’s possible to skip that initial setup process completely. Over the last few years, dozens of sites have sprung up to teach programming in the browser. You can open a web site, and write your first line of code in a few seconds. Free options include Codecademy, Khan Academy Computer Programming, Code.org, and numerous others. There are also paid sites like CodeSchool and Treehouse. For a more do-it-yourself approach, or for those following a tutorial in a book, there are online compilers such as Coding Ground (formerly CompileOnline) and Ideone. You can find many more of these by searching online compiler. Online compilers are less likely to have built-in tutorials, but they do allow programmers to skip the compiler setup step, or write a quick program from someone else’s computer.


A competitive programming practice site like uHunt might be overwhelming for a complete beginner, since it’s not structured as a programming tutorial. But after some time with an online or offline tutorial for the appropriate language, a motivated beginner could start to work through historical competitive programming problems. UVa Online Judge, the source that uHunt draws from, has numerous easy problems that require only basic knowledge of a programming language. As I wrote in 12 Reasons to Study Competitive Programming, there are quite a few benefits to using competitive programming as a way to get better at programming. There’s no reason why a beginner couldn’t take advantage of those benefits starting almost from their first program.

Spaced Repetition

As revolutionary as the online programming e-learning trend is for beginning programmers, programming sites avoid one particular technique that would make them even more helpful for those training for programming fluency. It’s especially surprising that Khan Academy doesn’t use the technique for their programming subjects, since they are masters of it in their mathematics curriculum. The technique I’m talking about is spaced repetition. If you have tried Khan Academy math, you know that when you first select a skill — for example, prime factorization — you are presented with a set of several problems related to that skill. If you get enough consecutive problems correct, the software awards you with a proficiency level for the skill. After a period of time elapses, you can attempt harder problems related to the same skill. Eventually, you reach a level where you are considered to have mastered the skill. However, problems related to the skill still appear in your regular practice, to ensure that you haven’t forgotten it. Over the years, the Khan Academy team has adjusted the implementation of the spaced repetition process. But it has always applied the same fundamental principles: Require the student to answer several questions correctly to demonstrate knowledge of a particular skill, and periodically insert questions related to that skill into the student’s practice sessions, to make sure they maintain proficiency in it.

Khan Academy Computer Science

In August 2012, the Khan Academy team introduced Khan Academy Computer Science, and they have continued to enhance it since then. I just tried out the first couple of lessons in the current Computer Programming and Computer Science subjects. They’re a great introduction to programming using JavaScript. The Computer Programming subject is geared more towards visual learners or younger kids, while the Computer Science subject jumps right into searching algorithms. This is a great way for a wide range of people to get started with programming.

Clearly the Khan Academy team made an intentional decision to teach their programming subjects differently from their math subjects. There are some good reasons for that given the differences between the two topics. But let’s imagine what it would be like to use a programming e-learning site based more directly on spaced repetition. In the programming sites listed at the beginning of this article, the emphasis is on progressing sequentially through a curriculum, from basic through advanced skills in one topic, then on to another topic. In Khan Academy Math, in contrast, once you have tried a skill once, it keeps popping up. The curriculum as a whole is still based on the idea of starting with $1+1=2$ and working your way to $e^{x} = \sum^{\infty}_{n=0} \frac{x^n}{n!} = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \cdots\quad\text{ for all } x$, but along the way, the software ensures that you’re reviewing earlier concepts as you’re learning more advanced ones. I haven’t seen a programming e-learning site that does that. You can always manually return to a previous exercise and repeat it, but you have to schedule that on your own. The software could improve on this manual step by making a prediction (using spaced repetition formulas) of when you’re about to forget an important piece of syntax or the name of a library function.

Knowledge Map

Another Khan Academy Math feature that I think would translate well to programming practice is the Knowledge Map. The Khan Academy Math knowledge map shows what a student needs to know as a prerequisite for a given math concept. For example, the first trigonometry subject requires unit circle intuition, which requires knowing how degrees and radians are related, which requires knowledge of congruent triangles, and so on. In the programming world, a puzzle involving palindromes might require knowing how to extract characters from strings, test for string equality, evaluate Boolean expressions, and other more basic concepts. An e-learning site that combined competitive programming puzzles with more basic drills could make use of a programming knowledge map to present problems in the right order based on the language features required to solve them.


I mentioned earlier that there are a lot of sites for learning programming using a browser interface. Another free option is CodingBat. Unlike the flashy sites run by startups with a lot of venture capital, CodingBat focuses on no-frills coding practice. Nick Parlante of the Stanford Computer Science department started it years ago (as JavaBat) for his students to use. What I like about CodingBat is the focus on short snippets of code, and the brief problem statements, free of extraneous details. It’s the perfect way to solidify the fundamentals of a language (Java and Python exercises are available) while separately working through more complex problems like those on uHunt. Like other programming e-learning sites, it uses a sequential progression model. Once you solve an exercise, you get a green checkmark and you aren’t prompted to solve it again unless you navigate back to it manually. However, there is this tantalizing quote on the badges page:

I’m thinking about a “challenge” feature where CodingBat could present a series of blank problems (ignoring if you’ve solved it before) over a few minutes to practice or show mastery of a particular badge.

So we may yet get a feature that encourages repetition of previously-learned concepts. Until then, each problem has a “Forget It! — delete my code for this problem” feature. Another approach for extra practice is to open the site in your browser’s private mode and use the site without creating an account. This means no progress is saved, so it’s easy to repeat questions as often as necessary.

One feature that distinguishes CodingBat from similar sites is its support for problem authoring by users. Since CodingBat was created to help beginning computer science undergraduates, it makes sense that computer science instructors other than Professor Parlante might want to author exercises for their own students. But he has gone even farther, opening up authoring to any interested user. I authored a couple of sample problems, which show up on my CodingBat home page. If you’re maintaining a reference program of code snippets, as I recommended last week, CodingBat Authoring can bring it to life. You can essentially create a custom online judge that you can use to master any idioms that are inhibiting your coding fluency.

Mastering the Fundamentals

The deliberate practice system that I’m working on is based on learning to solve short, well-defined programming problems taken from the repertoire of competitive programming. Doing that proficiently depends on having an excellent command of the programming language you’re using. This is important even for experienced programmers who may be unfamiliar with the process of solving programming puzzles from scratch without the benefit of a helpful IDE. By taking advantage of the online coding sites that are available, you can more quickly achieve the benefits of coding fluency.

(Image credit: fdecomite)