I believe in the importance of practicing programming fundamentals, especially through programming puzzles. But puzzle learning works best when you already have some experience with the programming language you’re using to solve them. By prompting you to exercise a core set of programming fundamentals, puzzles help strengthen basic coding skills. To get those basic skills in the first place, you need a starting point for learning. For a few years now, coding instruction in the browser has been a convenient option.
The Pros
There are a number of sites that offer browser-based interactive coding instruction, and I list a few of them in the post I just linked to. In this post, I’m going to use Codecademy as an example, because of its dominant presence in the online programming instruction space. Codecademy has several advantages over the traditional way of learning programming, some of which it shares with its competitors:
It’s low-friction: There is no setup required. Just open a browser and go. You don’t have to provide a credit card or even create an account to use it (though finding a Codecademy lesson without creating an account is not as intuitive as it used to be).
It’s interactive: Lessons are broken up into small chunks, often individual lines of code. You can run your code as soon as you write it and get feedback from the learning framework.
It’s gamified: Badges and streaks are a fun way to keep track of progress (unless you’re grumpy about it).
The Cons
As useful as Codecademy’s interactive approach can be for moving the learning process along, it also has some disadvantages. Because each step in a lesson is so specific, the standards for completing the step correctly are also very narrow. If the lesson content isn’t written carefully, students can have a hard time figuring out exactly what the lesson is asking for. They may eventually get help in the forums, but it’s not clear how effective that is for beginners. Unlike a forum for a Coursera-style online class, where students are usually progressing through the same material at the same time, getting an answer about a Codecademy problem requires that someone with the answer stumble on it before the student gives up and goes somewhere else. Since that’s less likely to happen on the Codecademy forums, it puts more of a burden on the problem authors to be clear about expectations.
A more serious problem with the interactive approach is that students can become accustomed to being told exactly what to do next. A typical Codecademy lesson step tells the student what code to write and which line to write it on. Sample code is usually provided, so that the student only has to copy, paste, and change a few characters. Sometimes even the character changes are optional. This example from The Zen of Ruby is not unusual.
Given that Codecademy’s target audience is everyone with access to a computer, it’s understandable that they want introductory lessons to be very easy. Developers soon learn that no matter how simple it is to use a software program, some users will find a way to break it — or in this case, fail to progress through a lesson.
While easy lessons make sense at first, the goal of a programming instruction site is for students to move on to become more independent in their problem-solving ability. To facilitate that process, Codecademy occasionally presents a more open-ended exercise. But these one-off exercises are not common.
Practical Skills
Serious Codecademy students ultimately want to put their skills to practical use to build a web site or some other type of software. That’s where the interactive approach really breaks down. Even someone who has completed one of the Codecademy projects from beginning to end will likely get stuck when they start an independent project. Consider a student who is familiar with JavaScript based on some Codecademy lessons. They now want to use their new skills to publish an interactive web site. Though they may have enough JavaScript language skills to accomplish what they have in mind, Codecademy doesn’t cover much infrastructure details, like where to put a .js file, or even that JavaScript code should be saved in its own file. What about hosting a web site so that other people can use it? Not having to worry about such things is useful for getting started, but eventually a programmer has to learn them. Some of the newer classes are starting to cover these topics, so this is a step in the right direction.
Spaced Repetition
As I wrote in Learning to Code Online, one feature that no interactive coding site yet offers is spaced repetition drills. Codecademy’s “tiny block of code” approach would be ideal for practicing the type of language features that I’m keeping track of in my Java reference class (though in a different language, since Codecademy doesn’t support Java). Codecademy CEO Zach Sims has said that they are thinking about that type of feature. In the meantime, CodingBat offers a minimalist look at how it might work.
Learning vs. Instruction
Is it even possible to learn programming effectively using an interactive learning site? This question is related to Keith Devlin’s learning vs. instruction distinction that I wrote about in Building Mathematical Thinking Skills. There are some undeniable benefits to learning programming from a live human. And to work on a large software project, it is essential to be able to learn from your peers. However, generations of programmers have figured things out with the help of books and the natural interactivity of the edit-compile-test cycle. So there is some hope for scaling out programming instruction using online tools.
Here’s one way to approach independent programming study using the resources we have available today:
From the ground up: Codecademy
Interactive sites like Codecademy are useful for getting started from scratch. They can lead you through the early part of the language learning curve, and give you some experience using the syntax of a new language. Even if you’re an experienced programmer, they can help familiarize you with the style and conventions of a language you haven’t studied. Just recognize the limitations of interactive sites, and don’t stay on this step for too long.
Problem-solving and fluency: Puzzles
Once you have the basics of a language down, using it to solve programming puzzles can solidify your skills and increase your language fluency. You can spend a lot of productive time on this step, depending on how interested you are in getting good at problem-solving and programming fundamentals. Competitive programming becomes a hobby for some programmers. If you want, you can work on this step indefinitely in your spare time.
Targeted practice: Drills
This step is closely tied to the programming puzzle approach, but is more targeted. If you feel like you’re wasting too much time thinking about syntax during coding sessions, or relying too much on your IDE, targeted practice may be the answer. Until the major interactive sites figure this one out, CodingBat is the best approach. It focuses on very small programming puzzles that target a specific language feature, and it doesn’t worry about constructing an elaborate back-story to explain why you’re writing each section of code.
Full Stack: Projects
If you’re working as a programmer, then you’re working on projects. The skills from the previous steps are useful here, but they’re not enough. Projects require that you combine several skills, and also deal with real-world difficulties like software that doesn’t work as advertised and customers who don’t know what they really want. Some of theses issues come up even in programming puzzles. For example, you may encounter ambiguous problem statements, or discover that your online judge is giving you a TLE because Java I/O is slow. But projects give you much more practice on non-coding issues. Some days, you can find yourself spending more time on infrastructure than you spend writing code. That’s one reason to keep a programming puzzle habit going: no matter what is going on in your day job, you’ll at least get regular programming practice.
Team Projects
Just as project work exposes you to difficulties that you don’t encounter with programming puzzles, team projects introduce even more new and exciting challenges. You’ll need to learn tools like source control systems, and how to split up work among team members. But more importantly, you’ll have access to people with difference levels of experience to collaborate with and learn from.
Using Codecademy
I really want interactive coding instruction to work. Of all the subjects that you might want to learn on a computer, programming is the most natural. If a problem is expressed with clear requirements, an online judge can be written to provide definitive feedback about whether a student’s code submission is correct or incorrect. The tricky part is how to turn this framework into a series of problems that can make a non-programmer into a productive programmer without too many redundant steps. Until that process is perfected, we can observe changes as they happen, and use the interactive sites for the value they provide. Personally, I’m keeping my Codecademy streak going (one exercise submission per day), and looking out for new features. But to make the most efficient use of my coding practice time, I’m mainly betting on Project 462.
(Image credit: Tilemahos Efthimiadis)