![Game Developer Logo Game Developer Logo](https://eu-images.contentstack.com/v3/assets/blt740a130ae3c5d529/bltb8149045ecc9add6/664670498df30a26f54d5ed4/GDBlogs_Logo_FINAL.png?width=700&auto=webp&quality=80&disable=upscale)
Featured Blog | This community-written post highlights the best of what the game industry has to offer. Read more like it on the Game Developer Blogs or learn how to Submit Your Own Blog Post
A Better Way to Learn How to Program
Using game design principles, we can make learning how to code a lot more compelling.
![](https://eu-images.contentstack.com/v3/assets/blt740a130ae3c5d529/bltba62518415cda0e2/652fe6ddbc479f8697ef691f/default-cubic.png?width=1280&auto=webp&quality=95&format=jpg&disable=upscale)
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.)
CodeHero
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.)
Conclusion
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.
Read more about:
Featured BlogsAbout the Author
You May Also Like