4 ms·
A Z-Machine in OCaml (2016)
- davidjhall 7y agoI remember following this a while back while working on my implementation of the z-machine. I don't think he finished it though ( neither have I! )
- SeanBoocock 7y agoThis is an excellent series from one of my favorite technical bloggers. It is one of the most accessible introductions to a language I've encountered. It is also a great introductions to creating a VM. Highly recommend for anyone that is curious about OCaml or how older adventure games worked.
- vidarh 7y agoWhile it's true the Z-Machine predated the CLR and JVM by a long time, but similar virtual machines as a general concept predates the Z-Machine by a long time as well. BCPL "O-code" dates to 1966. Pascal P-code, from the early 70's was better known, being a major part in Pascals early success, and popularized in particular with UCSD Pascal from the late 70's. I don't know to what extent the Infocom developers were aware of those forerunners, but it seems likely. I don't know if either of those forerunners supported paging though.
- lpage 7y agoIncidentally, the execution model and abstract machine for OCaml (more accurately Caml Light) is based on Xavier Leroy's paper "The ZINC experiment: an economical implementation of the ML language" [1] - an all time CS classic. Reading that paper and the surprisingly approachable source code for OCaml's interpreter [2] is a great way to demystify functional compilers. [1] https://caml.inria.fr/pub/papers/xleroy-zinc.pdf https://caml.inria.fr/pub/papers/xleroy-zinc.pdf [2] https://github.com/ocaml/ocaml/blob/trunk/runtime/interp.c https://github.com/ocaml/ocaml/blob/trunk/runtime/interp.c