Best PC games New PC games 2020 Deals Best graphics cards Best free PC games Best Minecraft shaders for 1.16.3 Best Warzone loadout for Season 6


Can Videogames Teach You Programming?

And which games might do it...

Featured post

Hack ‘n’ Slash

Difficulty: Intermediate – Advanced

Maybe, though, you want to prep a little more before plunging into the world of programming. This is where Hack ‘n’ Slash comes into play. At first glance, it seems like a typical Zelda-style action-adventure game, but instead of cutting down enemies you ‘hack’ them, using your sword-cum-USB-stick to reprogram their behaviour. Nearly all objects in the world can be reprogrammed this way, to the point where you can actually cause the game to crash by rewriting its code. This is both to the game’s benefit and its detriment; on the one hand, you have an incredible amount of freedom in approaching every puzzle, but at the same time, it can be terribly intimidating if you don’t understand why your solution simply didn’t work. To be fair, though, that’s pretty much programming in a nutshell.

The main problem with Hack ‘n’ Slash is that it’s effectively two different games, one being the Zelda-style puzzler that explores concepts like variables and routines in greater depth than Human Resource Machine, and the other being a full-on code debugger that drops you into raw code without so much as a plank to float on. This difficulty spike makes Hack ‘n Slash a rough game to play, but if you can get past that, there’s a lot of good stuff to learn.

Concept: Advanced Variables

What are they?

As mentioned earlier, variables are ways of storing and referring to data in a program. In Hack ‘n’ Slash, they are used to store much more than the single letters and numbers of Human Resource Machine, and their role in defining a program’s behaviour is made far more apparent.

How are they taught?

Hack ‘n’ Slash develops the concept of variables by introducing what are known as ‘typed’ variables. These are variables that can hold only a certain type of value, for instance only numbers, or only the values ‘true’ or ‘false’. When you hack an enemy, a list of variables that you can mess with pops up, but you can only change their values according to their type: you can’t store letters in a number variable, and you can’t increase a number beyond its defined limits. Thanks to these unwritten rules, you gradually learn the difference between Booleans, integers, and strings, even if you don’t know them by name.

The crux of Hack ‘n’ Slash’s lesson in variables, however, is seeing how their values dictate a program’s behaviour. Trial-and-erroring your way through a variable’s range of values is good mental practice for any programmer, especially when testing and debugging. A program needs to be capable of handling all possible data thrown at it, even if that means discarding the data that would cause it to act funky. Realising just how easy it is to break Hack ‘n’ Slash’s enemies by setting their Damage variable to -1 serves as an invaluable lesson in the importance of proper testing.

Concept: Syntax

What is it?

Just like the languages we use to communicate with each other, programming languages have rules for how their words come together to form sentences. This grammar is known as syntax, and though it can be unique to each language, most modern programming languages follow the conventions established by C some four decades ago.

How is it taught?

Hack ‘n’ Slash introduces the concept of syntax in its second half, when it moves past messing with variables and confronts you with naked code. Based on the Lua programming language, the code takes a number of liberties with its syntax, presumably in an effort to make it easier to understand. In practice, though, the made-up terminology only trades one flavour of confusion for another, limiting its real-world applicability in the process. Fortunately, the most common syntactic elements remain intact, familiarising you with the general structure of modern code.

Such grammatical rules include the dot syntax used in terms like Port.Value, which refers to the Value variable of an object called Port, and the structure of if… then statements for decision making. To help you decipher these oftentimes bewildering rules, Hack ‘n’ Slash drops you into a visualised version of the code, where variables are represented as colour-coded crystals that get fed into machines which process them into actions. Coloured lines trace the flow of the program between machines, although the machines are stacked so close together that it’s often hard to follow the order of operations.

Concept: Functions/Methods

What are they?

There’s an old adage in programming that 90% of a program’s execution time is spent running 10% of its code. In other words, programs spend a whole lot of time repeating the same operations. To take advantage of this, we split the most common code out into discrete functions, and whenever the program needs to run that code, we just call the function with a command like funFunction(). This saves us from re-writing the same code multiple times throughout a program, and more importantly, it means we only need to change one chunk of code if an oft-used function needs tweaking.

How is it taught?

Taking the form of the largest machines in the visualised version of the code, functions themselves can be hacked just like enemies and other objects, making for an Inception-esque scenario of diving into the code within the code. Changes made to a function’s code will propagate through the entire game, potentially leading to unexpected consequences later down the line. This is an all-too-common danger in programming, especially in bigger projects, and learning to be wary of the grander effects of even small changes is just good programming practice.


As a game, Hack ‘n’ Slash has a lot of problems. As a programming tutorial, it’s markedly better. By emphasising the impact of tweaking variables, and visualising functions as physical machines, it covers concepts invaluable to all aspiring programmers. So long as you’re prepared to learn the hard way just how much trial, error, and frustration goes into coding, you can come away with a firm grip on the systems and processes that underpin all languages of the modern era.

On page three, the scary world of assembly language in TIS-100.

Page 1Page 2Page 3
Please enable Javascript to view comments.

Comments are now closed. Go have a lie down, Internet.