[nolan@nprescott.com] $>  cat blog archive feed

Layers, like an Onion


I've been working on improving my knowledge of plain-old, vanilla, JavaScript recently. Avoiding frameworks and libraries (yes, that means jQuery) so that I might better appreciate what they provide and the rough edges they mask.

I've decided to give Clojure, specifically ClojureScript, a rest for a while. Not only do I find that I don't enjoy the language much, but all of the problems it purports to solve are problems that I haven't yet faced. It's no use reading about the virtues of immutability and a language-level focus on coherent data structures when there's no context in which to frame it. I've been tepidly working on and off with a single page application for months now and failed to make much progress, I think because I am only making tentative stabs at the thing, rather than putting in the time necessary to really grok the whole system. Any thorough understanding of web development seems to require a thorough understanding of the peculiarities of JavaScript.

So in rethinking my approach, I'm working on the absolute minimum system for templating, routing and AJAX for what will hopefully be a bare-bones basic single page application. Rather than calling $.ajax I'm trying to work through what exactly an XMLHttpRequest entails. Instead of pulling in a library like Secretary for routing, I'm reading up on implementing client side routers.

Once again I've found the particulars of the language or implementing a certain feature isn't quite so difficult as the rest of the ceremony around them. In this case, actually testing that I was making requests properly was more difficult than framing the requests themselves. Launching a local development server had me facing issues with the same-origin policy. Which is surely solvable, but at the moment is just one more thing in the way of what I was trying to do. In looking for a solution I came across an interesting service that proved helpful: RequestBin. It generates a temporary URL that logs all requests made to it, as such:

        http://requestb.in        application/json; charset=UTF-8        12m ago
        POST /14vi7vs1            13 bytes                    From _____________


        Via: 1.1 vegur
        Pragma: no-cache
        User-Agent: Mozilla/5.0 Gecko/20100101 Firefox/36.0
        Connection: close
        Connect-Time: 1
        Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
        Cache-Control: no-cache
        Content-Type: application/json; charset=UTF-8
        Total-Route-Time: 0
        Host: requestb.in
        Content-Length: 13
        Accept-Language: en-US,en;q=0.5
        Accept-Encoding: gzip, deflate

        RAW BODY


It's such a simple idea for a service I'm surprised I haven't come across more of the same sort. It's a nice reprieve to fire off a request and if (or more appropriately when) it fails, I can focus on the JavaScript, client-side rather than the development server and everything in between.

I haven't wrapped up the JavaScript work, but I have made progress on a set of minimal AJAX functions now that I have the means to test them. As I work through these things I have to wonder at how homogenized web browsers have become, relative to even a few years ago. There's a disparity in the most modern features, but core functionality like XMLHttpRequest seem pretty well supported. I'm not sorry I don't need to develop my own shims for IE 6, but I do wonder about the future for libraries like jQuery, which has stood the test of time better than most already.

[nolan@nprescott.com] $> █