"Learn to Program with Minecraft" offers an incredibly user-friendly, intuitive, and innovative approach for learning the Python programming language.
I have to say that I'm becoming increasingly impressed by the offerings I'm seeing from the No Starch Press publishing company.
I really enjoyed Junkyard Jam Band by David Erik Nelson (read my review), and The Maker's Guide to the Zombie Apocalypse by Simon Monk (read my review) caused me to run out and invest in a solar array and a charge controller.
Most recently, I read a very interesting introduction to the Python programming language called Learn to Program with Minecraft by Craig Richardson.
(Source: No Starch Press)
I think it's fair to say that this book is targeted toward younger folks like teenagers and students. I also think it's fair to say that -- in reality -- it's of interest to anyone who wants to learn the Python programming language short of professional programmers.
Now, I don’t wish to wander off into the weeds debating the pros and cons of languages like C and Python here -- that's a separate column in its own right. For the purposes of this article, let's assume that we've already made the decision to learn Python.
Many programmers say that Python is one of the easiest to wrap one's brain around. Even so, learning any programming language can be a daunting task for a beginner. However, Learn to Program with Minecraft offers the most user-friendly, intuitive, and innovative approach I've ever seen for any language.
Just in case you've been living under a rock for the past few years, Minecraft is a game that allows players to create their own worlds -- including landscapes and buildings -- out of textured cubes. There are a variety of gameplay modes, including multi-player worlds in which people can work together (or against each other) online. If you are thinking this sounds a tad trivial, take a look at this 25 'Minecraft' Creations That Will Blow Your Flippin' Mind article on Mashable.com. Trust me -- this will, indeed, blow your flippin' mind.
Returning to Learn to Program with Minecraft, we start in Chapter 1 -- Setting up for Your Adventure -- by installing Minecraft, Python, Minecraft Python API (Application Programming Interface), Minecraft Server, Java, and Spigot on your computer (the combination of Java and Spigot are used to facilitate Python and Minecraft talking to each other). Although this may seem a bit complicated when you read it here, the non-threatening step-by-step guide makes everything easy-peasy.
Chapter 2 -- Teleporting with Variables -- is where things start to get really clever. This chapter focuses on the declaration and use of variables. "How can you teach a language this way?" I hear you thinking. Well, this is where the Minecraft part comes in. Consider the following program from the book:
# Connect to Minecraft
from mcpi.minecraft import Minecraft
mc = Minecraft.create()
# Set x, y, and z variables to represent coordinates
x = 10
y = 110
z = 12
# Change the player's position
mc.player.setTilePos(x, y, z)
The two-line "Connect to Minecraft" part was introduced in Chapter 1. So the only new things here are declaring three integer variables and using them as arguments to a pre-defined function. The great thing is that we already have a pre-created 3D world that's been rendered on the screen. The author shows how to organize the code in the editor on the left of the screen and the 3D rendered Minecraft world on the right. When we execute the program shown above, it causes our player to be "teleported" from his original location to his new x, y, and z coordinates, and the corresponding scene is automatically rendered on the screen.
The end result is that -- although there's a horrendous amount of complicated "stuff" taking place "under the hood" -- we don’t have to worry about any of this. As far as we're concerned, we've moved our player through our 3D world by simply giving him new coordinates.
And so it goes. We have a non-threatening number of cheerfully titled chapters, each focusing on one main topic, like strings, Booleans, if statements, while loops, and so forth. The ability to concentrate on a single topic and use only a couple of lines of code while still performing visually interesting tasks and receiving immediate feedback and gratification in our 3D world really makes things hum along.
Coco the cat enjoying a few moments of quiet contemplation after perusing the chapter on for loops (Source: Max Maxfield / EETimes.com)
The bottom line is that I really cannot speak too highly of this book -- I doff my cap to its author. Just about every teenager I know is familiar with Minecraft. For any of them who has an interest in learning how to program, the possibility of controlling their Minecraft world and learning how to do things like create fabulous structures using a few simple functions -- or construct cunning traps with which to baffle their friends and foes -- may well provide the impetus to get them started on what could end up being a life-changing experience.
— Max Maxfield, Editor of All Things Fun & Interesting