Could you use Minecraft to teach programming?

Tags:

There are two mods (that I’m aware of) for Minecraft which let you build computers inside the game.

ComputerCraft allows you to have Lua-programmable computers and robots, with basic wired and wireless networking capabilities. RedPower 2 on the other hand has a 6502-like CPU based computers, which are programmable either using 6502 Assembly or FORTH.

What if you used Minecraft and one of these mods as an environment to teach programming?

Why Minecraft?

I’ve been playing Minecraft lately and using ComputerCraft to automate and create things. I found it very fun and easy to learn, but why would it be a good environment to teach a beginner?

I’ll concentrate on ComputerCraft, since RedPower 2’s computers are much lower level and thus harder to use for anything practical in-game.

As an environment for buildings things, Minecraft is quite intuitive I think. You can mine blocks and place them in many kinds of formations. With mods, you get even more variety, such as automatic mining machines, automatic crafting tables, engines for generating electricity using fuel pumped into them which in turn is refined from oil with a refinery…

So as a sandbox for creating and adventuring in the autogenerated land, it’s quite nice, especially with some modding.

Why does this make for a good environment to learn programming in?

Let’s look at what ComputerCraft offers:

  • Computers which can render basic text-based UIs, they come with a simple UNIX-like shell
  • Robots which can dig and place blocks just like players, which share the OS with the computers
  • External monitor blocks which can be combined to create big info screens or other things
  • Computers can be connected to machines or each other via wires
  • Wireless network modems for computers and robots which can be used for communication between computers or robots
  • Small base library of useful programs to get started
  • Everything is programmable using Lua. You can even replace the OS by replacing its Lua scripts

ComputerCraft computer with Turtle robot
A computer with a floppy drive and a mining robot

This is quite a lot of things.

This offers a variety of things you can do, like creating machines in Minecraft which you then automate using a computer, building computer operated doors, building servers for data storage, creating networked applications, creating robots which can mine automatically or build structures…

Although the built in applications allow you to do some basic testing, for most things you will need to write a custom program.

There are many aspects to learn:

  • Basic programming: Lua is a full featured scripting language and seems easy to learn
  • Networking: Computers and robots can communicate with each other over networks
  • Automation: Machines, doors, lighting etc. can be automated
  • Robotics: Although simple, the robots can be programmed to do complex tasks and AI
  • High-level systems programming: Replace the OS in the computers with your own

If adding RedPower 2 computers to the mix, low-level systems programming with assembly could also be added to the list above.

ComputerCraft terminal output
Computer terminal with basic commands and output

But what makes it a particularly engaging environment to learn in my opinion is that everything is very much your own creations.

You first build it yourself from the ground up. Then set up the wiring necessary for connecting it. Then you write the program, and watch it come to life. It gives you feedback very quickly and seeing it work is very rewarding.

Considering you don’t need a lot of code for basic applications and basics of Lua are easy to pick up, it makes it very easy to use.

The inclusion of easy to program robots only adds to the possibilities. For example, there’s a video on YouTube highlighting using the robot as a makeshift bomber, dropping TNT as bombs.

The fact that the options are almost endless really makes this something where it’s a very personalized experience. The community is also creating further modifications to ComputerCraft itself, and it’s possible to combine the computers with many other mods’ additions, so the only limitation is really what you can imagine. And, unlike with a bucket of Legos, there is no limit to resources in Minecraft.

Downsides

Of course there are some downsides as well.

You can teach the general aspects of programming though, such as variables, functions, object oriented programming, and the things mentioned earlier like networking things (albeit a bit simplistic model).

However, besides this, it’s probably a bit impractical due to Lua not being a very commonly used language. So while you can do a lot of things and learn a lot of programming, you will very likely need to learn another language for anything that you do outside Minecraft – which may or may not be a bad thing depending on how you look at it.

Secondly, it’s Minecraft. You could easily get sidetracked with building some megaproject… but you probably would use the computers to automate that afterwards.

Conclusion

As is demonstrated on YouTube, teaching programming with Minecraft could be very viable. Although the video doesn’t really go into much details, it looks like something which could work.

If nothing else, I think it’s at least a very interesting idea and I’d love to see it taken further. Infact, a comment on Twitter from ComputerCraft creator dan200 would indicate there could be some further plans for education using ComputerCraft.

There’s really a lot of things for all skills levels, from simple password protected doors and keycard systems, to centralized user management servers with networking, and nuclear powerplant control systems, or robots which dig tunnels for you or even build houses.

And everything has a very quick feedback loop, so you will always have a feeling of achieving something.

If you want to try this yourself, the mod pack I’m using is Tekkit, with general documentation available in the Tekkit Wiki, computers and programming docs in the ComputerCraft wiki, information on building machines in the IndustrialCraft wiki and BuildCraft wiki, and computers and machines info in the RedPower 2 wiki.

Let me know your thoughts in the comments, I’d love to hear from you especially if you have used Minecraft in teaching or are planning to.