JOSHUA HOLBROOK github : twitter

ecstatic 0.3.x: SO GOOD WE SKIPPED A MINOR VERSION (posted 18 Nov 2012)


(0.1 + 0.2 = 0.3?)

Today, I released a new version of ecstatic, a static file serving library for node.js that works with express, flatiron and the core http module.

On the face of it, this probably sounds pretty boring. But, for me, this is a bit of a serious milestone. The first commit to ecstatic was, coincidentally, a year ago almost to the day. Looking through the commit history, you’ll notice that there was a flurry of activity by substack and myself to hack together a reasonably well-working version. This was mostly driven by two things:

  • Connect’s static middleware kinda sucked. It worked, sure, but it didn’t have a ton of features and it wasn’t being actively developed.
  • There weren’t any static fileserving libraries that supported Flatiron at the time (afaik ecstatic is still the only one).

This left us with a reasonably well-working library with a few warts. For example, until yesterday there wasn’t a way to mount your static files on any path other than /.

So, 9 months ago, I decided to give ecstatic a rewrite. Which, as it turned out, was a gigantic mistake.

Development of the 0.2.x branch of ecstatic went something like this:

  1. Reorganize all the code in a way that’s perceived as being “better organized” but does pretty much the same stuff.
  2. Add a bunch of sugar for using ecstatic as a director route and as a flatiron plugin, which increased entry point complexity significantly
  3. Flirt with rewriting the tests to use vows because I didn’t like tap’s t.plan, eventually give up (later, I would realize that I could just delete t.plan and have my tap tests still work. Why I didn’t do this the first time I do not know.
  4. Tell people that I’m “totally going to release the 0.2.x branch” and encourage them to make pull requests against that branch
  5. Get mired in trying to figure out why the Hell the tests weren’t passing
  6. Try to sucker coderarity into making my tests pass, with limited success (thanks coderarity)
  7. Let the codebase sit around for something like 9 months without a single commit

There are a few lessons here. One is something I’m still trying to teach myself, which is that I have a tendency to bite off more than I can chew in a moment of optimism. Aside from that, thow=ugh, I think the biggest lesson is:

it’s better to have low complexity than to be well-organized.

The 0.2.x codebase involves a lot of concerns-separating, which seemed good at the time. However, I found that I had to make a trade-off towards more complexity, which made the 0.2.x codebase much more difficult to debug (which is what killed it in the end).

About 3 months ago, Isaac wrote his own static fileserving library, st. His API was nice and simple, had a lot of the features I wanted in ecstatic, and was presumably being more actively maintained than my own library (remember, by this time the wasted time on the 0.2.x branch had crushed my morale). In response, I almost deprecated ecstatic.

So why didn’t I? Honestly, due to you guys. I had a whole bunch of people (okay, maybe like 3 or 4, but it FELT like a “whole bunch”) tell me that they were still using ecstatic, that they had good experiences with it (what was there was apparently pretty rock-solid) and that they didn’t want it to go away. So, with the encouragement of my internet friends, I hacked on the 0.1.x codebase to bring in the good features and api changes of the 0.2.x branch and polish the leftover rough edges, and ecstatic 0.3.0 was born. Kinda like winamp 5.

In case you were wondering what exactly changed, here’s a quick rundown:

  • gzip support (thanks to Ryan Fitzgerald)
  • separation of “autoIndex” and “showDir” concepts
  • one options hash with a “root” argument instead of a string path and separate hash (happens to be backwards compatible)
  • serve files off a path other than ‘/’ with the “baseDir” option
  • 302 redirects for requests against ‘/someDirectory’ to ‘/someDirectory/’ (technically a fixed bug)
  • Travis tests (remember that travis4all bot? yeah.)

Finally, I gave direct commit access to three people other than myself, to ensure that ecstatic stays well-maintained even if/when I become flaky: Christian Howe, Colton Baker and Maciej Malecki. Big ups to all three of them!