Nolen's Notch's Minecraft Without Locals

July 14, 2014

David Nolen has a cool ClojureScript port of Notch's JavaScript Minecraft demo. Notch's JavaScript is imperative, making heavy use of local variable mutation. David's port adheres fairly close to the original by imitating mutable locals in ClojureScript by bashing 1-element array values.

I was curious as to whether the main render loop could be written without the mutation, and, with a bit of rearrangement, it's possible to ditch the locals! In this fork, the changes are a bit convoluted, but it essentially puts the locals that were in render-minecraft! into loop/recur variables. Here is the output of the forked version:

I suppose this could lead to more effcient JavaScript, but I haven't investigated that aspect—this was really just an experiment to satisfy my curiosity as to whether it was even possible to do.

Tags: ClojureScript