Gamasutra: The Art & Business of Making Gamesspacer
View All     RSS
October 31, 2014
arrowPress Releases
October 31, 2014
PR Newswire
View All
View All     Submit Event

If you enjoy reading this site, you might also want to check out these UBM Tech sites:

A Better Way to Learn How to Program
by Alexander Jhin on 09/02/11 02:12:00 pm   Featured Blogs

The following blog post, unless otherwise noted, was written by a member of Gamasutra’s community.
The thoughts and opinions expressed are those of the writer and not Gamasutra or its parent company.


Teaching Programming: A Better Way

Learning how to program can be a nightmare. An aspiring coder has to jump through many unpleasant hoops and mysterious error messages just to get "Hello, World!" printed on the screen. Then, she's left wondering, "OK, now what? How do I actually build something?"

As game developers seeing someone struggle through this, we should be screaming, “NOOOOO!” The whole thing reeks of bad game design: a lot of work with no reward, unclear failure cases, advanced features pushed on new players, etc. If we simply apply some simple game design principles, learning how to code can be much more fun and educational.

So, what would a programming game look like?

The Programming Game

A game that teaches programming concepts is not a new idea. An acclaimed short list of programming games includes: RoboRally, Robozzle, Robot Odyssey, and Light-Bot. But these games focus on the abstract concepts of programming, rather than teaching real world programming. It’s similar to how a first person shooter captures the feeling of shooting without training someone how to actually shoot. 

So, how can we use gaming to teach someone how to really code? 

Key Features of a Real World Programming Game

Below are a list of key, game-influenced principles to make learning to code more fun. I've created a playable example of these principles that can be played in browser here: YouCode. (The game is still in Beta, requires Flash Player and teaches Actionscript 3.0.)


 0) Choose a Real Language.
 Many previous attempts at programming games use toy languages with toy interfaces in toy environments. While these may be suitable for young children, any mature gamer will quickly begin to notice the limitations of the language and feel they are learning a skill which only works in the toy domain. This makes tranferring to the real world daunting.

The obvious solution is to use a programming language used by professionals. This guarantees the language will be full featured, giving the player room to grow while also teaching them an immediately real world usable language. The trick is to break down the language into easily digestable bites, which will be discussed next.

1) Easy to Start. Like all games, programming games must have a low barrier to entry. Traditionally, the first step to learning programming was to install and set up a build environment, which is not a fun way to start. To remove this barrier, the user should be able to enter code directly into the main game UI, run it from there and receive error messages there. 

Getting started quickly and easily also requires hiding advanced concepts like namespaces and main function entry points. While these are necessary for complete programs to run, they are boring and simply require too many advanced concepts. Most traditional code teaching techniques will simply tell students to type this required code, but basically ignore it. No good game would ever tell the player to do something they don't understand! 

Make coding easy through in game interfaces. Consider having your game write entry points and error handling for the player or simply hide it from them. 

2) Give Obvious Feedback. The code that a new programmer writes should make the player feel powerful by triggering animations and sounds. 

Most code runs invisibly. "int a = 4 + 3;" doesn't do anything the user can see. Good games have actions whose outcomes are obvious -- programming games should too. Ideally, the example line above would run in a special compiler which overrides the + operator to output, say, a graphic of 4 adding to 3, becoming 7 and being stored in a variable called "a". Of course, this is not possible in every language, so maybe having the user write a function which displays the outcome, such as store("a", add(4, 3)); may be be an adequate solution. No matter what, programming assignments should have obvious, detectable outcomes.

 3) Help on failure. A beginning coder can fail in multiple ways: syntax errors, exceptions, infinite loops and incorrect logic. Ideally, the game should detect the most common coder mistakes and offer guidance about how to fix them.

 4) Clear, Attainable Goals. One of the hardest parts of starting programming is deciding what to program. Deciding what to program depends on the programmer's skill. Unfortunately, most beginning programmers aren't advanced enough to know what they can't yet program (how many beginning programmers do you know who want to write a First Person Shooter engine from scratch?) A programming game should track what skills the programmer has already mastered and choose goals that are known to be attainable. For example, if a programming game has taught the user loops, it's fair to use loops in the discussion about arrays. In fact, forcing a player to use previous patterns helps reinfoce the older concepts while teaching a new one.

The game should present problems which are known to be solvable given the user's knowledge.

Other Examples

There are some other programs that use similar techniques. For example, Code School is a commercial website that interactively teaches topics such as "Ruby on Rails" via a web
based coding interface. (Note: I haven't actually tried Code School as it costs money.)


Designing and creating good code teaching games should be a subject close to our hearts. After all, without programmers, there wouldn’t be many games. But beyond the substantial utility to our industry, this design exercise shows the value of game design when applied to the “real” world. While games may exist in enclosed universes, they all reveal something about the nature of people. And this knowledge can be invaluable when applied to the real world.

Related Jobs

Rensselaer Polytechnic Institute
Rensselaer Polytechnic Institute — Troy, New York, United States

Assistant Professor in Music and Media
The College of New Jersey
The College of New Jersey — Ewing, New Jersey, United States

Assistant Professor - Interactive Multi Media - Tenure Track
Next Games
Next Games — Helsinki, Finland

Senior Level Designer
Magic Leap, Inc.
Magic Leap, Inc. — Wellington, New Zealand

Level Designer


jin choung
profile image
i'm not a programmer (computer graphics guy) but i've probably read 3 books on programming C++ as well as an additional 3 books on python programming.

but probably the best educational tool for me regarding programming is actually the computer graphics app, MAYA.

by making every button press a user viewable bit of code, you really quickly start learning to cut and paste that kind of code together to create rough batch functions and "hack" together code that is ugly as hell but actually does something useful.

and in dipping your toe and getting familiar by hacking like this, you start spreading your wings a little bit and maybe do a for loop or a while condition and all of a sudden, you're writing useful, simple programs.


and having gone through those books and my maya hacking, i would say that the obstacles that still keep me from being a programmer are:

- HARD TO START - you're DEFINITELY right about that. when i start the learning process by installing and IDE, making sure all the directory stuff is correct and then swimming through a list of libraries, it starts to look like everest.

- it's REALLY hard to make a useful program... especially in a world where the web can get you a small free app that does pretty much anything you need. as an adult, it's the equivalent of being unable to do stupid senseless drills in order to get to the better stuff later.

- it would be interesting to have a programmer speak anecdotally and non technically about the general issues confronting programmers and programming. just the sheer lack of knowledge regarding what issues are involved, what the common issues are, makes programming probably more theoretical to me than it needs to be.

i've got a philosophy where pretty much i can get a general grasp of any subject matter after reading 3 books from 3 separate authors and do about 2 months of magazine and web site reading on the topic. the books give you the technical knowledge of the details. but the magazines clue you in on the zeitgeist of what's going on in the field and what are the kinds of things people are thinking about wrestling with.

with coding, i feel like i mostly got a grasp on the technical details but it's the every day nuts and bolts concerns that totally elude me.

actually, one of the best magazines for giving me some of that has been game developer magazine. even as a graphics imaging guy, i've read the coding articles and while most of them have been way over my head, there have been moments of insight and epiphany - especially since the coding tasks at hand pertain to fun topics like ai, render engines, etc.

i guess i just need more of that and in a more structured way.

- i think it might be fun to have lesson plans based on programming a PART of a larger program - just like in the real world. as you said, that part will be such that you have knowledge to tackle it and you know how to interface it into the larger program (which may actually be far beyond your current skill level itself)... but in creating an exercise that is actually useful and yet limited in scope, i think a lot of value can come from that.


anyhoo, i've bookmarked the programming game. thanks so much for addressing this topic because i do think it's valuable to try to rethink programming education.

rock on.


Alexander Jhin
profile image
Thank you, yes, my proposal is only part of a larger programming education. Thank you for pointing out that a lot of people learn from hacking sample code -- I learned a lot that way too. I'll have to think if there's a way I can work that into the "game". Do you have any ideas how that might work?

jin choung
profile image
btw - this alone from your game is gold:

1) Understand the goal.

2) Find useful existing code and language features.

3) Simplify goal steps until it is codable.

4) Write code.

5) Test code and fix it until the goal is achieved.



Adam P
profile image
This is a great game!

Coding has come a LONG way since the days of old! I'm not saying it's easy, but it's certainly has come a long way. Take a look at coding a windows app in C vs C++ vs .NET Perhaps some day coding will be easier, but it has already come a long way!

Alexander Jhin
profile image
Thank you.

Coding is getting easier and easier. Maybe one day, interactive tutorials like mine will be a lot shorter. My goodness, compare assembly to .NET. It's funny, so much of programming languages are about making it easy for people. Programming is a people problem, an HCI (human computer interface) problem as much as it is a technology problem. The "gaming" approach to teaching programming doesn't make a language better -- it just makes it easier for the people, which is 50% of the equation.

Jonathan Jou
profile image
I've been thinking a lot about this problem myself, and this means that there are at least TWO self-hosting Actionscript interpreters in the world now with the goal of finding the fun in programming! I'd be interested in sharing ideas and experiences with you at length on this topic. I'll be following your progress closely, so consider me a huge fan!

Alexander Jhin
profile image
Absolutely! I've been working alone so far, testing the game on my programmer friends. I'd love to bounce some ideas around. I'll send you a PM. I have some more advanced ideas around making programming fun (think Sierra game but you use code instead of text commands.)

Jonathan Jou
profile image
That's certainly one idea; I've been working/toying with a prototype that's trying to motivate common algorithms and data structures as puzzles for a programming game. I've searched high and low for some semblance of a PM system and found nothing of the sort on this site--do you have a personal website or something with your email on it?

Alexander Jhin
profile image
The domain name of my website minus dot com at gmail. Hopefully that's enough to fool the spam bots. =)

Robert Bevill
profile image
The coding game you showed was a neat concept, but to a beginner, there are still a lot of things confusing about it. Specifically, I was stuck when it asked me to write code that would give three different cats the correct number of hats.

Alexander Jhin
profile image
Thank you. I know people are going to get stuck and it will be very frustrating. I'm thinking about adding a hint system that slowly gives more and more hints until it basically gives you the solution.

This mission you're speaking of is missing a reminder to check the library. I'll add the reminder. Specifically, look at the function countCats() which evaluates, or becomes, the number of cats currently needing hats. So, if there are currently two cats, countCats() becomes the integer 2. If there are three cats, it becomes the integer 3. countCats is the key to solving this problem.

Ryan Salway
profile image
Indeed, as Mr. Bevill stated this program is not yet that friendly to non programmers. Testing on programmer friends is great but you need to test on true beginners and non programmers. The first twelve or so lessons work well but once your teaching game gets to Functions and Operators. you don't give enough feedback or help to the player. (point 2 and 3 in your article).

Its a good start and I think you are onto something here. I hope to see the tool improved as I would love to test it on my high-school students and see how they do with it.

Alexander Jhin
profile image
Thank you. While it's hard to hear that one's passion project isn't quite working for the intended audience, I needed to hear it. =) I'll keep working on it.

I did rush a bit when I got to functions and operators (I assume you mean function return values?) I'll slow it down and explain more thoroughly.

Thanks for the feedback.

Ryan Salway
profile image
My Pleasure. Keep up the good work. I am excited to see the final product.

Gary Dahl
profile image
Great topic! Another difficulty with learning to program is that so many of the most valuable concepts are organizational in nature. Once you have assignments, conditions, and loops you're Turing compatible. Your game reminds me a bit of Logo which was targeted at teaching kinds to program.

Alexander Jhin
profile image
I've been putting off writing the missions about assignments. It's kind of hard to show, but I think I've got some ideas.

Well organized code is by far the hardest thing to learn... unfortunately, it matters most with a huge code base -- something I don't think my program will ever touch on. Hopefully, programmers will be able to pick up the concepts elsewhere.

It is meant as kind of a replacement for Logo but maybe for older students and with a full featured, Turing Complete language. I'd love hear people describe it as the new Logo!