Thought I’d do a short comparison between PunyInform and the Inform 6 standard library, for anyone wondering if Puny is for them.
What is this PunyInform thing?
It’s a library for the Inform 6 programming language, optimized for producing Z-code games playable on 8-bit platforms. It’s very similar to the Inform 6 standard library.
Oh, so it’s the same library, only smaller and faster?
As we’re trying to make people aware of PunyInform’s existence, and new people try it out, we keep getting back to one big snag: “But my existing Inform 6 project doesn’t compile with PunyInform.” Well, that’s true. These libraries are not the same. We actually started writing our own library from scratch, but as we progressed, we saw that we needed more and more of the same features that Inform 6 already provided and, not surprisingly, that pretty much all of Graham’s design choices for Inform 6 came naturally or were very well thought-through and we just got in trouble if we tried to do it differently. Also, we thought it would be beneficial if authors could adopt their existing Inform 6 projects with no more fuss than necessary. So, we adopted the strategy that we copy the Inform 6 library’s way of doing things unless we think there’s a clear advantage in doing it another way, and we keep looking for ways to make the code smaller and faster. Also, we cut out features which are less than necessary and/or require a lot of code and/or are impossible to do in z3 games, since we wanted PunyInform to be 100% functional for z3 games too and as compact as possible. Additionally, some features which we thought would be really nice to have but all game projects may not require them were made optional.
Advantages of PunyInform
- The library produces smaller and faster code.
- Several parts of the library are disabled by default, making the code smaller unless you decide to use them.
- Games can be compiled to z3 format.
- The library creates fewer objects, which matters for z3 games, where the maximum # of objects is 255. With PunyInform, the game author can create 248 objects, vs 230 with the standard library.
Advantages of the Inform 6 standard library
- Very well tested.
- The parser has less rough edges and allows the game author to meddle with the parsing process a bit more.
- Better debugging capabilitites.
- Games can be compiled to Glulx format.
- Handles identical objects, like a set of gold coins where you can pick one up and leave the rest.
- The entire library has been carefully adapted to be easy to translate to other languages.
- Apart from the default 2nd person perspective and present tense, the library also handles 1st person and 3rd person perspective and past tense.
What code has to change when porting a game from Inform 6 to PunyInform?
- The basic code structure of a game is slightly different. You include the files “globals.h” and “puny.h” instead of “parser”, “verblib” and “grammar”. Some routines etc may need to be moved around in the code for everything to work.
- If you use identical objects, change your design.
- The process of replacing library messages is different.
- The Compass object is gone, and all the direction objects have been merged into a single object. For this reason you typically need to change code which handles directions.
- PunyInform doesn’t have the extremely versatile routine WriteListFrom to print what’s in/on an object, but a simpler replacement routine called PrintContents.
- Some library entry point routines are not supported. If you have used such routines, you need to find other ways of getting the effect you want.
- The set of verbs and the grammar tables are not the same. You may encounter actions which are not supported, in which case you need to implement them yourself, or the exact wording the player can use in the standard library doesn’t work in PunyInform.
- TEST, TEST and TEST the game to see what isn’t working the way you want it to work. Remember, you are moving from one library to another, they just happen to be quite similar.
Why would you choose to use PunyInform over the standard library
We can really only see two reasons: You want your game to run on small and slow computers OR you want to compile your game to z8 format and you want a bit more room for game data.
So, this size difference, how big is it?
I have worked with Dave Footitt to adopt his Inform 6 game Calypso to PunyInform. His source code can now be compiled using either library - you just define the constant USE_PUNY at the beginning to compile with PunyInform or leave it out to compile with the standard library.
Using PunyInform v1.5 and Inform 6.12.2 (which is what I had at hand), I compiled the game to z5 format. Using abbreviations, with strict error checking disabled, and unused routines being left out, the standard library version is 80172 bytes (plus padding), while the PunyInform version is 48040 bytes. Thus, the PunyInform version is 32132 bytes smaller. In this case, that means the game is 40% smaller. This, of course, makes a huge difference when playing on computers with 32-64 KB of RAM, like the 8-bit computers typically have. For larger games, you can expect the difference in bytes to be about the same, while the difference in % will of course be smaller.
You can look at the source code at https://github.com/dave-f/calypso and you can download and try the two different z5 files at https://drive.google.com/drive/folders/1aMzMS7Yp37HDHc9n9IQB8rbd4C-3xAhM?usp=sharing