[HN Gopher] Advent of Code on the Z-Machine
       ___________________________________________________________________
        
       Advent of Code on the Z-Machine
        
       Author : todsacerdoti
       Score  : 91 points
       Date   : 2025-11-11 11:34 UTC (11 hours ago)
        
 (HTM) web link (entropicthoughts.com)
 (TXT) w3m dump (entropicthoughts.com)
        
       | meindnoch wrote:
       | Oh. From the title I thought it would be the Z machine at Sandia
       | labs: https://en.wikipedia.org/wiki/Z_Pulsed_Power_Facility
        
         | ricksunny wrote:
         | Sandia loves their references to Z division
         | 
         | https://en.wikipedia.org/wiki/Sandia_Base
         | 
         | https://en.wikipedia.org/wiki/Z-Division
        
       | jhbadger wrote:
       | "First off, it is really low level. From what I understand, not
       | even the people at Infocom wrote raw zil. Instead, they used Lisp
       | macros that generated zil."
       | 
       | Is there any evidence of this? The standard guide to ZIL (written
       | as an in-house document at Infocom for new programmers [1])
       | presents it very much as if people would be writing it directly.
       | It's also not _that_ low level, only slightly more low level than
       | Inform 6.
       | 
       | [1]
       | https://archive.org/details/Learning_ZIL_Steven_Eric_Meretzk...
        
         | ndiddy wrote:
         | The source code for most Infocom games is public, they did
         | write them in ZIL. https://eblong.com/infocom/
        
           | kqr wrote:
           | The way I understand it, ZIL at Infocom was a _subset_ of
           | MDL. More specifically, a subset that was easy to compile to
           | the Z-machine. This means that during development, they 'd
           | mainly write ZIL code, but they'd do it _in MDL_ , giving
           | them access to the full powers of the Lisp during
           | development. (Since MDL is an early Lisp.)
           | 
           | Sometimes during game development they'd make use of MDL
           | macros that were not available in ZIL, and they'd then have
           | to either macroexpand manually, or hard-code those macros as
           | language features into their ZIL compiler (because ZIL is not
           | quite a Lisp and does not have support for custom macros).
           | 
           | Again, this is the understanding I've pieced together in my
           | head from various sources. I don't have the full picture!
           | Maybe I should try to get in touch with the people who were
           | there to ask them...
        
             | KerrAvon wrote:
             | Yes. If you look at the ZILF compiler in particular, which
             | is capable of compiling the original sources, there's a lot
             | more MDL in there than you'd expect would be required for
             | ZIL proper.
        
               | taradinoc wrote:
               | Right - that's because ZIL was more or less a _superset_
               | of MDL.
               | 
               | ZILCH (Infocom's compiler) provided all the functions of
               | MDL, _plus_ a bunch of new ones that manipulated data
               | structures which were then used to generate assembly code
               | for the Z-machine.
               | 
               | One of those new functions, ROUTINE, accepted code
               | written in a domain-specific language resembling a
               | stripped-down MDL, which was then translated into
               | Z-machine instructions. But that domain-specific language
               | isn't synonymous with ZIL: other functions that were
               | inarguably part of ZIL, like OBJECT and SYNTAX, are not
               | part of that domain-specific language.
               | 
               | IMO, the only reasonable definition of ZIL is "the
               | language accepted by a ZIL compiler", which (depending on
               | whether you look at ZILCH or ZILF) is either a superset
               | of MDL or an overlapping set.
        
             | taradinoc wrote:
             | Author of ZILF here. I wouldn't say that ZIL "does not have
             | support for custom macros", because ZIL never existed in a
             | form independent of MDL. There's no such thing as "MDL
             | macros that were not available in ZIL", because there was
             | never a version of ZIL that didn't have macros.
        
       | busfahrer wrote:
       | The article mentions the Z-Machine as the earliest fantasy
       | console. I'm wondering whether CHIP-8 would qualify?
       | 
       | https://en.wikipedia.org/wiki/CHIP-8
        
       | verytrivial wrote:
       | Another worthy mention in this space is Linus Akesson's dialog
       | language[1]. From its description:                   Dialog is a
       | domain-specific language for creating works of interactive
       | fiction. It is heavily inspired by Inform 7 (Graham Nelson et al.
       | 2006) and Prolog (Alain Colmerauer et al. 1972).         An
       | optimizing compiler, dialogc, translates high-level Dialog code
       | into Z-code, a platform-independent runtime format originally
       | created by Infocom in 1979.
       | 
       | Development seems dormant at the moment, but it feels more like
       | Inform 7 'done right' to me. If my brain was a little bigger and
       | calmer I'd be all over it. It has excellent documentation too.
       | Very portable -- I compiled it locally under Termux on my phone
       | with nothing but Clang.
       | 
       | [1] https://www.linusakesson.net/dialog/index.php
        
         | kqr wrote:
         | Author here. I agree. It does seem like "Inform 7 done right"
         | and I really like the Prolog evaluation model.
         | 
         | I didn't know about Dialog when I wrote this article (learned
         | of it just yesterday!) but unless life gets in the way I will
         | explore it in a future article.
        
           | macintux wrote:
           | While poking around I found this side-by-side comparison of
           | Inform 7 & Dialog. Seems instructive.
           | 
           | https://www.linusakesson.net/dialog/craverly/craverly_side_b.
           | ..
           | 
           | https://www.linusakesson.net/dialog/craverly/index.php
        
             | KerrAvon wrote:
             | This is great illustration of the brilliance of Inform 7.
             | 
             | I understand the appeal of Dialog -- Inform 7 can be really
             | awkward for traditional programming constructs -- but I
             | think I'd rather write ZIL if I'm going back to the usual
             | control structures and OOP-style messaging.
        
         | 1313ed01 wrote:
         | There has been some Dialog development in the last year or so,
         | after others picked it up (with Linus' blessing) and started
         | work on a Community Edition:
         | 
         | https://github.com/Dialog-IF/dialog
        
       | dyates wrote:
       | Interesting read! A lot of AoC challenges involve navigating 2D
       | grids, which can map quite nicely onto the text adventure model
       | of connected rooms with compass direction exits (a grid of
       | straightforward little passages, all alike). This insight led me
       | to attempt Day 6 from last year's Advent of Code in Inform 7[1],
       | though I ultimately admitted defeat on the second half. I've
       | always found Inform 7's Mathematics Textbook English syntax quite
       | charming, though perhaps I would have a different perspective if
       | I'd ever attempted to build anything substantial with it.
       | 
       | [1]:
       | https://davidyat.es/2024/12/23/aoc-2024-part2/#day-6-python-...
        
         | CheeseFromLidl wrote:
         | Last year was my first participation and did everything in
         | javascript in the browser. It's high level enough to not lose
         | your time in details, you have a graphical output if needed
         | (canvas), text output, threading, parsing, ...
        
       | Marazan wrote:
       | I was secretly hoping they would write solutions in Inform 7.
        
       | varenc wrote:
       | I thought this was about the _other_ Z-Machine at first:
       | https://en.wikipedia.org/wiki/Z_Pulsed_Power_Facility
       | 
       | (used at Sandia for inertial confinement fusion)
        
         | lbeckman314 wrote:
         | This Z-Machine is also featured in 'Firing the Lorentz Plasma
         | Cannon' [1] by Lightning on Demand [2]!
         | 
         | [1] https://youtu.be/lix-vr_AF38?t=3m12s
         | 
         | [2] https://lod.org
        
       | PaulHoule wrote:
       | I think I gotta try it with AVR-8 assembly or something like that
       | this year.
        
       ___________________________________________________________________
       (page generated 2025-11-11 23:01 UTC)