Interest in "DM5"?

They are completely different languages. Graham Nelson himself once said that he regretted calling it Inform 7. Many authors just don’t get Inform 7. (I’m one of them.) On the surface, it looks simple and that appeals to non-programmers, but once you get into the nitty gritty, it’s actually very hard to understand the convoluted syntax. Inform 7 does compile to Inform 6 as a sort of intermediary, but the resultant code is extremely bloated.

Inform 6 also has alternative libraries. PunyInform is probably the most popular. This tries to produce the smallest, fastest code that it can. In this way, compiled Inform 6 games can run on retro computers, whereas Inform 7 games have no hope of ever running on retro computers because they are too large to fit on a floppy disk and those that can fit run far too slow to be bearable to play.

8 Likes

Thanks. I always thought that Inform 7 was an update on Inform 6. I’ll have to look into Inform 6. It is easier to learn? Would it be hard to translate an Inform 7 story to Inform 6?

1 Like

Maybe if you have previous programming experience.

Yes it would, since they are very different.

2 Likes

I looked into Inform 6 (and Twine). I do have previous programming experience but I think I’ll stick with I7 since I have a lot invested. I will also look into TADS.
Thanks much.

3 Likes

As an example from a very early draft, here’s a short excerpt:

Understanding strings in Inform 6

Most people with even passing familiarity with another programming language will understand the concept of a string as a piece of text, i.e. a series of characters in a certain order.

In some programming languages, such as C, storage for a string takes the form of a memory address. The first character of the string is at that address, and each successive address contains the next character in the string. A special terminator character marks the end of the sequence of characters that comprise the string. As an example, consider the string "cat" in C. It would be stored in memory somewhere, say at address 1000. The first character c is stored at address 1000, a is stored at 1001, t is stored at 1002, and the terminator character marking the end of the string is stored at 1003. [diagram here]

Under this storage scheme, if you know the starting address you can access individual characters within the string by adding an offset to the memory address of the string (i.e. the address of the string’s first character). The offset is usually thought of as zero-indexed, so the offset is one less than the ordinal position of the character sought. For example, to find the second character (a) in "cat", the memory position to examine is 1000+2-1 or 1001.

It is important to understand that in the majority of cases this is not how strings are stored in Inform 6.

As discussed in the section on the Z-Machine memory model (see [cross-ref]), memory in the Z-machine is segmented into addressable and packed segments. Most strings found in the source code – such as those used to provide descriptions of rooms and objects and to specify responses to actions – will be consigned to packed memory by the compiler. The running game cannot directly access the memory locations in packed memory; it must rely on the interpreter to do so. As a result, there is no way for the running game to even ask for the second character in a packed string. All it can do is ask the interpreter to print the whole string starting at a particular location (the packed string’s starting point) in packed memory. This is what the “printing rule” (string) does.

As also discussed (see [cross-ref]), packed memory is static and can’t be changed at run-time. This is why it is not possible to modify most strings (being held in packed memory) while the game is running.

However, not every string literal in the source code is destined to become a packed string. If a string literal is used to initialize an array, then the compiler treats the declaration as equivalent to asking for an array to be built with each storage unit (byte or word) of the array populated by the successive characters of the string literal. Note that, unlike in C, no terminator character is included at the end of the sequence in this case, though for some array variants (see [cross-ref]) the number of characters in the string will be stored where it can be easily accessed.

This text will refer to such arrays containing unterminated sequences of characters as “pseudo-strings.” Built-in support for pseudo-strings is limited. The (string) printing rule does not work with these pseudo-strings. The String metaclass does not apply to pseudo-strings. The burden is very much on the author to deal with these constructs… [go on to define some routines that might be useful and/or cite useful extensions or StdLib routines that may exist]

This is the kind of thing I meant about a “sliding scale” of technical detail intended to be useful for both programming newbies and those with programming experience whose expectations have been set by other languages.

Would a whole book of this sort of stuff be useful?

6 Likes

I’d say this starts high on the scale and runs higher. :)

2 Likes

This sounds like a great idea, but it’s also a massive undertaking. As well-written as DM4 is, it relegates some of the important but low-level bits to exercises or just drops in functions without further explanation, and the parser code is virtually unreadable. It goes in with the assumption that the reader already has some experience with programming languages, and it assumes that the reader is approaching the subject as someone who wants to learn how to program a game in I6 (as opposed to almost all of the documentation for I7, where the approach is that the user is primarily interested in interactive fiction as fiction and considers programming to be an ancillary task or an obstacle to be gotten around as quickly as possible). That’s a wonderful approach, but it tends to obscure both the low-level details of Z-machine or Glulx (the latter of which I don’t think was even standard at the time the book was written) and the high-level of details of modifying and extending the standard library. The explanation of verb syntax, for example, is excellent as far as it goes, but it doesn’t go into many details about how exactly parsing is carried out, how precedence for syntax rules is handled, etc.

Syntax is usually the least important part of a language, but the syntax in Inform 7 is aggressively obtuse. As a natural language, English has dozens of ways of expressing the same thing. Inform 7 only accepts one of those, and everything you want to do has a different, arbitrary choice of that one right phrasing. It’s like the guess-the-verb problem for a programming language. Add in annoyances like prohibitions against nesting conditionals in certain places, choosing non-standard names for standard functions and commands (why say instead of print? why rule succeeds instead of return true? why truth state instead of boolean?), a pathological fear of symbols in favor of wordy and nonspecific English terms, a compiler that insists on adding whitespace in print statements wherever it thinks appropriate, etc. and…well, it’s a frustrating experience. I have a lot of programming experience in general and have written a couple of games in I6 and one in I7, and I still haven’t found a better way of predicting what the I7 compiler is going to come up with than trying a bunch of things and seeing which one magically works. I7 is unpredictable, and that’s a damning flaw for a programming language.

Anyway, returning closer to the topic at hand: I6 is a more traditional language with a regular syntax and parsimonious set of keywords. The DM4 did a great job of explaining what had been the state of the language at the time, but the language has moved on since then. A reference that explains the updates to the language with that same level of detail would be a valuable resource.

3 Likes

Yes, it is a huge undertaking. I maintain a very large Word reference document for my own use and refer to it all the time, but it barely scratches the surface. Most of the headings are just placeholders. And now that I’ve been using PunyInform, I notice a lot of differences between the two libraries.

1 Like

Yeah, let’s not turn this into yet another I7 bitching session.

“Parsimonious” may be overstating it. Look at the large list of keywords-in-some-contexts…

6 Likes

On which note, one thing that would be very useful to me in a new reference work is an overview of what syntax gets translated to what veneer code.

I6 has a lot of special syntax for things that really want to be handled by the standard library instead of by the language itself, so the special syntax gets translated into a routine call and the library is supposed to define an appropriate routine to handle it. If it doesn’t, the compiler adds in a very basic routine definition of its own to avoid crashing.

But this isn’t documented in the DM4 (which assumes you always want to let the standard library do it for you), and the ITM is frequently less than clear in its explanations.

It would be nice to see notes on this wherever the special syntax is introduced, along with any limitations imposed on this routine: “the box keyword takes its arguments, turns them into an array of packed strings, then calls Box__Routine with this array and the maximum width of any string in this array as its arguments; if any of the arguments to box are not packed strings, it fails at compile time”.

1 Like

Agreed. This is something that I always have to figure out by looking at the compiler code.

I6 has a lot of special syntax for things that really want to be handled by the standard library instead of by the language itself

And more things that are handled by the veneer, but you can override them in the language.

Also a large category of things that are handled by the veneer in strict -S mode only.

2 Likes

I’ve got a degree in computer science and found it overwhelming!

I think there is a compromise to be made between what is accessible for beginners and more in depth. It isn’t easy to cater for a wide audience. But I do think it’s important not to put some people off.

Then again I’m a former computer scientist who prefers Inform 7 to Inform 6 by a long chalk. Lots of years of Prolog study and programming probably helped!

But yes, thinking about who the varied audience might be is key I think.

1 Like

I like the idea, but I can only put that on the list marked “aspirational.” My exploration of the compiler itself has been quite limited to date.

1 Like

Yes. It cannot be understated the impact and construct that is I7. It’s definitely not anything traditional. But that is why it’s so neat.

This is the kind of thing I (personally) need. I followed right up to the bit about “pseudo-strings”, but I imagine I’d have an easier time if I weren’t (a) half asleep and (b) reading this without the to-be-added cross references. Documentation is fun!

Documentation is not fun. I’m a technical writer (amongst other things), so I should know.

7 Likes

Likewise, so I’m not sure what to do with that remark. :) I have enjoyed it, at least. It can be a pain, but I still like reading a good explanation of something, and trying to write one. Each to their own and all that

4 Likes

No. If you want to do C, do C. If you want to do Inform, do Inform. Don’t mix languages, except if you want to provide comparison at the appendix.

2 Likes

Well, to be fair, that excerpt cross-references material that would have been covered by that point in the text. Truly comprehending why strings work the way that they do in I6 requires knowledge of the Z-machine memory model. I chose it as the example because the strange-seeming behavior of strings in I6 was a major stumbling block for me when I first tried to pick it up (in the days before I7). Knowledge that I had picked up about C didn’t translate into this “C-like” language.

There are very comprehensible reasons for many of the unusual aspects of I6, but these are often left unexplained by DM4. My intended audience would be those who want to understand both the Big Picture and the fine details. My goal would be to condense the journey of reaching that understanding to reading a few hundred pages. A certain density may be unavoidable.

There are already some “easy does it”-style texts for those who aren’t interested in every level of detail. (I would personally recommend starting with Firth and Kesserich’s The Inform Beginner’s Guide for that audience. No, scratch that – I would personally recommend starting with Writing With Inform!)

1 Like