<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>tag:blog.danieljanus.pl,2019:category:z-machine</id>
  <title>Daniel Janus – Z-machine</title>
  <link href="http://blog.danieljanus.pl/category/z-machine/"/>
  <updated>2014-09-13T00:00:00Z</updated>
  <author>
    <name>Daniel Janus</name>
    <uri>http://danieljanus.pl</uri>
    <email>dj@danieljanus.pl</email>
  </author>
  <entry>
    <id>tag:blog.danieljanus.pl,2014-09-13:post:happy-programmers-day</id>
    <title>Happy Programmers’ Day!</title>
    <link href="http://blog.danieljanus.pl/happy-programmers-day/"/>
    <updated>2014-09-13T00:00:00Z</updated>
    <content type="html">&lt;div&gt;&lt;p&gt;Happy &lt;a href="https://en.wikipedia.org/wiki/Programmers&amp;apos;_Day"&gt;Programmers’ Day&lt;/a&gt;, everyone!&lt;/p&gt;&lt;p&gt;A feast isn’t a feast, though, until it has a proper way of celebrating it. The &lt;a href="https://en.wikipedia.org/wiki/Pi_Day"&gt;Pi Day&lt;/a&gt;, for instance, has one: you eat a pie (preferably exactly at 1:59:26.535am), but I haven’t heard of any way of celebrating the Programmers’ Day, so I had to invent one. An obvious way would be to write a program, preferably a non-trivial one, but that requires time and dedication, which not everyone is able to readily spare.&lt;/p&gt;&lt;p&gt;So here’s my idea: on Programmers’ Day, dust off a program that you wrote some time ago — something that is just lying around in some far corner of your hard disk, that you haven’t looked at in years, but that you had fun writing — and put it on &lt;a href="https://github.com/"&gt;GitHub&lt;/a&gt; for all the world to see, to share the joy of programming.&lt;/p&gt;&lt;p&gt;Let me initialize the new tradition by doing this myself. Here’s &lt;a href="https://github.com/nathell/haze"&gt;HAZE&lt;/a&gt;, the Haskellish Abominable Z-machine Emulator. It was my final assignment for a course in Advanced Functional Programming, in my fourth year at the Uni, way back in 2004. It is an emulator for an ancient kind of virtual machine, the &lt;a href="https://en.wikipedia.org/wiki/Z-machine"&gt;Z-machine&lt;/a&gt;, written from scratch in Haskell. It allows you to play text adventure games, such as &lt;a href="https://en.wikipedia.org/wiki/Zork"&gt;Zork&lt;/a&gt;, much in the vein of &lt;a href="https://davidgriffith.gitlab.io/frotz/"&gt;Frotz&lt;/a&gt;. It’s not very complete, and supports versions of the Z-machine up to 3 only, so newer games won’t run on it as it stands, but Zork is playable.&lt;/p&gt;&lt;p&gt;It probably won’t even compile in modern Haskell systems: it was originally written for GHC version 6.2.1, and extensively uses the FiniteMap data type, which was obsoleted shortly after and is no longer found in modern systems. I should have Linux and Windows binaries lying around (yes, I had compiled it under Windows, using MinGW/PDCurses); I’ll put them on GitHub once I find them.&lt;/p&gt;&lt;p&gt;My mind now wanders ten years back in time, to the days when I was writing it. It took me about three summer weeks to write HAZE from scratch, most of that time on a slow laptop where it took quite a lot of seconds to get GHC to compile even a simple thing. I would do some of it differently if I were doing it now — for one, the state of a &lt;code&gt;ZMachine&lt;/code&gt; is a central datatype to HAZE, and you’ll find a lot of functions that take and return ZMachines, so a state monad is an obvious choice; I didn’t understand monads well enough back then. But I still remember how I had the framework in place already and I was adding implementations of Z-code opcodes, one by one, to &lt;code&gt;ZMachine/ZCode/Impl.hs&lt;/code&gt;, recompiling, rerunning, getting messages about unimplemented opcodes, when all of a sudden I got the familiar message about a white house and a small mailbox. Freude!&lt;/p&gt;&lt;p&gt;I hope you enjoy looking at it at least half as much as I had enjoyed writing it.&lt;/p&gt;&lt;/div&gt;</content>
  </entry>
</feed>
