One of the first things people learn when they start programming is how to write a text prompt. It’s a decades-old exercise that teaches new programmers input-output.
In order to inject a little excitement, learners are normally
encouraged to write interactive games using standard IO. This helps
them learn programming by interactively - they will need to learn
conditional logic to handle the “Will you stab the monster with your
sword or run away?
” prompt.
This creative learning process is great but, unfortunately, it’s hard to show the creations to other people. Any players will have to undergo the nuisance of installing an interpreter, libraries, and the game in order to play. These deployment problems are alleviated on the web: javascript can be distributed and executed remotely in a browser with no effort required from the client.
If people wrote their text adventures in javascript, they could be easily be shared with a URL. However, javascript is not necessarily a good teaching language. Enforcing people to write their text adventures in it for the sake of distribution detracts from the learning experience.
An ideal system would allow text adventures (console applications) to be written in any language but also be distributed on the web. This is what my latest project, textadventurer, tries to achieve (gallery).
textadventurer
keeps interaction in the browser while moving
execution onto the server. Communication between those two layers is
achieved with websockets. This makes it easier for people to play the
game. The frontend focuses on presenting games (CLI applications) to
the players and provides a basic UI for sending input (STDIN) to the
server and recieving output (STDOUT) from the server.
Using process forking server-side affords a lot of flexibility: the
server is completely agnostic to the language or framework that the
game is written in. This means I can use textadventurer
to
distribute any standard interactive CLI application. With that in
mind, I plan on deploying historic text adventure games to
textadventurer when I get the chance
so that people can enjoy those games once more without having to faff
around with installers, legacy interpreters, etc.