Coding with Minecraft

I feel like I struck nerd-parent gold with CC: Tweaked, a mod that adds programmable computers, turtles and a bunch more to Minecraft, all controlled using the Lua programming language.

It began with Coding with Minecraft that I picked up from the local library to see if E might be keen and ready to get into programming during the holidays.

The entire programming interface is in Minecraft itself. Coding is performed on “turtle” character. There’s a really basic shell, a file system, a full blown Lua interpreter, and a simple editor to get the edit-run cycle going.

We’ve been working through the chapters, E’s been copying code out of the book, getting it to work, then adding his own tweaks and modifications with some assistance.

Here’s one of the first programs he copied and extended (“Farmer” is the name of his turtle). Printing messages, taking input, concatenating strings to form responses and doing a little math at the end.

It was really nice to share in his excitement when he got the program to run exactly as he wanted after multiple edits and tries. *proud dad moment* Next, we’ll be getting into using for loops to make the turtle dance.

Also, Lua is actually pretty nice as a first programming language 😄.

Mocking Fluent objects in Javascript

Fluent interfaces are an elegant way of expressing functionality in Javascript. Unfortunately, when it comes to stubbing and instrumenting these method calls, one may find it next to impossible to do so – resulting in one or more of the following less-than-ideal outcomes:

  1. Using said library sans fluent interface.
  2. Selecting an alternative on the sole basis of having a non-fluent interface.
  3. Not testing that snippet of functionality altogether.

In this post, we shall mock-up a fluent library called SuperAgent for testing.

Continue reading “Mocking Fluent objects in Javascript”

Combining lists into tuples

Here’s how you can zip up multiple lists into a single list of pairs or tuples using (map vector ).

(def letters [:a :b :c])
(def numbers [1 2 3])
(def fruits ["peach" "tomato" "orange"])

(map vector letters numbers)
; => ([:a 1] [:b 2] [:c 3])

(map vector letters fruits numbers)
; => ([:a "peach" 1] [:b "tomato" 2] [:c "orange" 3])

Cool trick, but how is this useful, you ask?

Continue reading “Combining lists into tuples”

JS frameworks two-way binding comparison

If you’ve been curious about the MV* Javascript frameworks that all the cool kids are fussing over, Marius Gundersen provides a succinct and valuable cross-section comparison between  AngularJSEmber.js and KnockoutJS.

Extracted from his presentation:

  AngularJS Ember.js KnockoutJS
Binding Dirty Checking Explicit Observable Explicit Observable
Rendering Async Async Sync
Computed Properties
Dynamic Dependencies

Some of Marius’ key takeways:

  1. Ember slowest at rendering lists.
  2. Anguler slowest when model is complex.
  3. Knockout slowest when pushing many items.

More importantly, I take this as a reverse pivot table exercise – see what features are being compared to figure out what they’re actually meant to be doing. Far more informative than “A framework for creating ambitious web applications” or “HTML enhanced for web apps!”.

See: Speaker’s original blog post