Natural language programming. An interesting thought. The sort of thought that can make a programmer feel a bit queasy. Lets face it, the reason we like programming languages for programming is that they are non-ambiguous. English is ambiguous. Computers dont like ambiguous, its a no brainer.
However, the one place natural language programming might work is interactive fiction – the one area of programming that is almost completely concerned with natural language processing. Its a logical next step some would say.
I wouldn’t have believed it could be done in a non-trivial way but it looks like the Inform team have pulled it off. I havn’t had time to get right into it obviously, but heres some source comparisons to tide you over. Sample code extracts taken from Roger Firth’s IF Language comparison page. Check it out to see the rest of the code listing.
An inform 6 room description
Object foyer “Foyer of the Opera House”
“You are standing in a spacious hall, splendidly decorated in red
and gold, with glittering chandeliers overhead. The entrance from
the street is to the north, and there are doorways south and west.”,
“You’ve only just arrived, and besides, the weather outside
seems to be getting worse.”,
The same room description in Inform 7
Foyer of the Opera House is a room. “You are standing in a spacious hall,
splendidly decorated in red and gold, with glittering chandeliers overhead.
The entrance from the street is to the north, and there are doorways south and west.”
Instead of going north in the Foyer, say “You’ve only just arrived, and besides,
the weather outside seems to be getting worse.”
These aren’t entirely identical, as the w_to cloakroom and s_to bar definitions are taken care of in the descriptions of the bar and the cloakroom respectively (ie The Cloakroom is west of the Foyer. ) but it should be enough to show you the incredible difference in layout and coding style.
Interestingly enough, rather than compiling to z-code or gluxe assembly code, as previous versions did, inform 7 code compiles to inform 6 code. It’s not obvious at first glance what the potential ramnifications of this are, but it is interesting.