All that glitters
Mustache: hero in a distributed data world

GameChanger is a data business.  Our primary visible product is a suite of apps & a website, but we live to collect piles of raw scoring data and build it up into live streams, text messages, automatic recaps, and crazy stats.

A reality of doing all this is that at various points along the lifecycle of that data, from mobile device to server to user, we need to perform consistent calculations & formatting.  We can’t always hit a central server to do the work, and duplicating all of the logic across tiers creates inconsistencies and a maintenance nightmare (trust me). The first step, which is fundamental to how we work, is that our data is structured uniformly across all tiers.

What we’ve done is build a series of tools to make our data manipulation algorithms portable.  For statistics, we have a platform-independent markup that we call “stat engine”.  By implementing a pretty simple processing engine in each language, we can work on one central configuration document that any end-point can work with.  That means the boxscore a user sees live on a phone while scoring is identical to the one our server calculates.

I had little choice with stats (our algorithms are our own, and it’s a very domain-specific problem), but not so with text formatting.  Enter Mustache.  It’s a super-simple templating markup, and has implementations in all our favorite languages (Javascript, Python, Obj-C).  Since our data stays uniformly represented as it passes through these layers, I can apply the same set of templates at any point in the lifecycle: on the device immediately after it’s created, server-side when I have to, and in the browser during live-streaming situations.

Mustache is also letting me start to unify templating languages.  Currently, we use Django templating for server-side page rendering, and then use a combination of TrimPath and raw Javascript string manipulation to do browser-side rendering.  My new goal is to start moving all of our HTML templating to Mustache, because then I can render components seamlessly in either tier, which makes for much easier development of dynamic page generation, “ajax”-y partial page refreshes, etc.

These two tools let me destroy bottlenecks by moving processing to wherever it’s convenient, and offer features cross-platform with very low development cost.  And that’s pretty awesome.

(afterthought: my one hurdle thus far is dealing with the “logicless” nature of Mustache- I’ve found myself making some changes to data formats to support this better, but I’m still learning how to get the most from the markup)

  1. aurum posted this
blog comments powered by Disqus
blog comments powered by Disqus