So why don’t we program computers in, well, English?
The obvious answer to this question is: because it’s too difficult. English is complex and ambiguous. Most of the time when we write computer programs we aim for simplicity and clarity. Even so, being able to convey ‘natural language’ instructions to a computer is a goal worth aiming for. Captain Kirk can do it so why can’t we?
One type of program that attempts to make sense of English commands is the good old text adventure. “Pick up the ring”, the player says. To which the game responds, “Do you mean the golden ring or the silver ring?”
It’s all very well that the game player can enter instructions in English. But the game programmer has to write instructions in Java or Ruby, C++ or Python. There are, of course, some languages such as TADS, which are specifically tailored to the writing of games. Even so, most of these are, at heart, traditional types of programming language with ifs, fors and procedure calls.
I was intrigued, therefore, to discover a game-writing language that breaks away from this coding tradition and gives the programmer a way of writing games using instructions that look very like English sentences. Inform 7 lets you create rooms by just writing the room name followed by the assertion “is a room” and its description. You can connect rooms together by entering statements such as “Room One is east of Room Two”. Objects and interactions can be described and expressed in a similar way. I really find this a fascinating approach, not only to writing games but to programming in general.
It’s also remarkably easy to get started. Here, in its entirely, is a game that I wrote in about 15 minutes. it’s not a big or complex game, to be sure, but even so, it is much, much more complex than any comparable game I could have written in that time using a conventional language:
The Gazebo is a room. "A lovely crystal gazebo in the garden".
The Dragon Lair is a room. "A big smelly cave".
The Crystal Dome is a room. "A huge glittering dome filled with exotic plants".
The Dragon Lair is south of the Gazebo.
The Crystal Dome is east of the Gazebo.
The wood-slatted crate is in the Gazebo. The crate is a container.
The ruby is in the crate.
The crate is closed.
The crate is openable.
The wombat is an animal. The wombat is male. The description of wombat is "It is a small, furry animal".
The wombat is in the Gazebo.
The description of the Elvish Sword is "A sword of purest gold that glows in the dark."
The Elvish Sword is in the Dragon Lair.
The description of the Dwarf Sword is "A sword of darkest Dwarf-iron."
The Dwarf Sword is in the Dragon Lair.
On the left you see the ‘program code’ of my game. On the right, I am playing the game.
Inform 7 comes with its own simple editing and compiling environment and it is available for Linux, Solaris, Windows and OS X. It’s a wonderfully eccentric project that is more innovative and ambitious in its aims than many better known general-purpose programming languages. I love it.
Inform 7 Download page: http://inform7.com/download