this space intentionally left blank

August 15, 2013

Filed under: movies»television

Summer Streaming

It's been a beautiful summer, even by Seattle standards, and Belle and I have gotten at least some good out of it. We've been camping, traveling, and lately we even broke out the grill. Take that, state-wide burn ban!

Indoors, of course, a lot of the broadcast TV we watch takes the summer off. We've been picking up a few shows via Netflix and Amazon instead. I'm not quite ready to write off our TiVo yet, but I'm impressed with the choices we've had.

Orange is the New Black

Surprisingly good. Shockingly good, even. There's none of the lazy writing and faux-transgressiveness that marked Jenji Kohan's previous show, Weeds. It's got a rich cast of characters without feeling contrived, it's funny without going broad, and it's comfortable mining a deep vein of dark humor from its setting. There have been a few comparisons between this and The Wire. Orange is the New Black isn't quite that good--what is?--but it's not an inapt pairing. Like its predecessor, Orange features a diverse cast filled with actors of color. Both shows also lack marquee names (but feature stellar performances from little-known actors). And of course, the subject material in both cases is fascinating in and of itself.

Beyond the confines of the show, it's interesting to see Netflix so clearly taking a page from HBO's book. Lots of networks have halo shows--it's only thanks to Mad Men that I can differentiate between AMC and A&E--but it was really HBO that realized shows were "stickier" than movies. And unlike HBO, Netflix doesn't force you to haggle with your local cable overlords. If they can put out more material at this quality level, their constant battles over licensing big film titles for streaming look a lot less troubling. I could definitely see keeping a Netflix subscription just for a couple of shows like this.

Alphas

A show that never really found an audience on the SciFi channel, Alphas folded after a couple of seasons, and Amazon snagged it as one of their early exclusives. It's not groundbreaking television: the special effects are decidedly bargain-basement, the writers can't decide if they want to steal from Heroes or X-Men, and the direction ranges from competent to not terrible. It's a good summer show, though, with a more thoughtful core than either of its inspirations would lead you to believe.

Alphas has three things going for it. The first is David Strathairn, an actor who is way too good to be doing a superhero show on basic cable. The second is a genuine rapport between the actors, who really sell the workplace chemistry--especially between Gary, the autistic electro-telepath and Bill, the temperamental bruiser. Finally, Alphas does manage a single clever twist on its formula: the idea that its superpowers are basically neuroses, for which most of the cast are in therapy (if nothing else, this is a wry joke at the expense of the Xavier Academy for Gifted Youth). I'm not sure it ever really embraces that fully--there hasn't been a single hero-on-a-couch scene that I remember--but it does make me feel better about my own psychological tics.

The Fall

The Fall doesn't try to hide its villain: you'll know whodunnit by the end of the first episode. Instead, it serves as a kind of character study for its chilly detective, Stella Gibson, played by Gillian Anderson. In many ways it reminds me of the BBC's prototypical female detective drama, Prime Suspect: Gibson spends as much time fighting a sexist bureaucracy as she does hunting the actual murderer.

When it's good, The Fall is very good, but it takes its time getting there. It's odd that, for a season that's only six episodes long, so much of it feels like padding. But I think part of that comes down to the delivery method. Streaming (and DVD, as well) makes it easy to burn through a show in a matter of hours. That's great for hook-driven puzzlers like Fringe or monster-of-the-week shows like Doctor Who, but it might not work so well for atmosphere-driven dramas.

It makes me wonder if we'll see a change in how people write narratives as streaming TV-on-demand becomes more common. Some people consider the non-Netflix Arrested Development to be designed for obsessive DVD rewatching. Is streaming different? More social? More portable?

August 1, 2013

Filed under: tech»web

Learning WebGL

Once Microsoft announced IE 11 will offer WebGL, that was pretty much the last straw: Apple may drag their feet at enabling it in Safari, but everyone else seems to have decided that it's secure enough and capable enough for production. I still think it's a little nutty, but I don't really have an excuse to avoid it anymore. So when an EaselJS-based visualization at work started having performance issues, I wrote a WebGL shim as a learning project.

I stand by my earlier impressions of the WebGL API--it's clumsy and ill-suited to JavaScript--but the performance is undeniably there. Rendering through EaselGL is often orders of magnitude faster than vanilla Easel, particularly when it comes to mouseover responsiveness. It's worth struggling through the learning process if you find that canvas is becoming a bottleneck for your application. I think a more interesting question is why so many WebGL tutorials are awful. And they are awful:

  • They hide the WebGL boilerplate behind library code--say, a function call that loads shaders or does matrix math--and force readers to dig through the source to figure out what mat4mult() or loadShader() does.
  • Even when they leave the code all in one place, they treat the often-confusing GL code as boilerplate, and don't explain it. Why do I need to call bindBuffer()? What do the six (!) parameters of vertexAttribPointer() actually control? What's the deal with all the constants, like gl.STATIC_DRAW?
  • Since WebGL is not a 3D API, they require a lot of 3D math. Most people teach this badly, assuming they don't double down on the mistakes above and just hide it behind calls to library functions. As a result, it's easy to get lost, and hard to reach the "putting shapes on the screen" feedback loop that keeps students engaged.

Of course, these are not uncommon mistakes in programming tutorials. In fact, they're extremely common--I just haven't had to learn anything from scratch in a while, and had forgotten how confusing the process could be. Anyone writing for beginners would do well to keep these errors in mind.

There are a few walkthroughs that I found more helpful. As I've mentioned, Greg Tavares's series on WebGL was eye-opening, and Brandon Jones provided the only worthwhile explanation of attribute array setup that I found. Between those two, and countless Google searches, I managed to cobble together a basic understanding of how the GL state machine actually works.

As a way of distilling out that knowledge, I've assembled the WebGL demo script that I would have wanted when I started out. It uses no external code--everything's right there on the same page. It explains each parameter that's used, and what each function call does. And it's only concerned with drawing a basic 2D shape--no matrix math is involved. It's stored in a Github Gist, so feel free to file pull requests against anything you find confusing. Also, feel free to look through EaselGL: it's a bit more advanced and I need to add more comments, but as a 2D API I think it's quite a bit easier to understand than the typical game library, particularly for ex-ActionScript developers like myself.

July 24, 2013

Filed under: journalism»new_media

The Narrative

I had planned on writing a post about Nate Silver's departure from the New York Times this week, but Lance pretty much beat me to it:

Silver is now legendary for being a numbers guy. But there aren't going to be any useful numbers for analyzing the next Presidential election until the middle of 2015 at the earliest. The circumstances under which the election will take place---the state of the economy, whether we're at war or peace, the President's popularity and if and how that will transfer to the Democratic nominee, what issues are galvanizing which voters, etc.---won't make themselves known and so won't show up as numbers in polls at least until then. And until then, everything said about the election is idle speculation, and we know how Silver feels about idly speculating.

But we also know that the most incorrigible idle speculators believe idle speculation is the point.

It's well worth the time to read the whole thing.

I've seen some people assert, in light of this departure, that lots of people could do what Silver did for the Times: his models weren't that complicated, after all, and how hard can it be to write about them? I think this dramatically underestimates the uniqueness of FiveThirtyEight and, to some extent, signifies how threatening it really was to political pundits.

There are, no doubt, a few journalists who could put together Nate Silver's models, and then write about them with clarity. I don't think anyone doubted that evidence-driven political reporting was possible. What he did was show that it could be successful, and that it could draw eyeballs. I think it was John Rogers who said that the best thing about blogging was not the enabling effect for amateurs, but for experts. Suddenly people with actual skills--economists, historians, political scientists, statisticians--could have the kind of audience that op-ed pages commanded.

This should not have been a surprise for newspapers, except that the industry has spent years convincing itself that investigative teams and deep expertise in a beat aren't worth funding. To be fair, the New York Times has put money behind a lot of data journalism in the past few years. If they can't keep the attention of someone like Silver, who can? I guess we're going to find out.

July 18, 2013

Filed under: tech»web

Over the Top

By the time you read this, I'll have been running Weir as my full-time RSS reader for two and a half weeks, starting on July 1. It's going well! Having just added OPML export, so that I can switch if it stops being worth the trouble, I've had a chance to sit back and consider some lessons learned from the project.

  1. Eight megabytes does not seem like a lot of data these days, but it adds up. Before I started culling feeds (and before I added Gzip support to the request service), Weir was pulling down roughly eight megs of data with each fetch, at ten minute intervals. That's 48MB per hour, a small amount that adds up to over a gigabyte per day. By default, I get 24 gigs per month of transfer allowance on my server. Something had to go.

    It's interesting to note, by the way, that this is something that RSS services like Newsblur or Feedly don't worry so much about, because the cost of each feed is spread across all subscribers. I didn't cost Google Reader as much traffic as Weir requires on its own.

  2. So I started unsubscribing. The majority of my original subscription list in Google Reader came from Paul Irish's front-end feed collection, and while I had already unsubscribed from the crazy people, it turns out most of the other blogs in that collection were dead. Even with 304 support added in, Weir was downloading a ton of RSS, only to discard much of it as being past the configured expiration date. I don't think this means blogging is a thing of the past, personally, but it's clearly down from its heyday in favor of social services, particularly (in the technical community) Google+.
  3. That said, using Feedburner seems to be a clear indication that you weren't that interested in blogging anyway, because it makes up a disproportionate amount of the abandoned or simply broken RSS feeds on my list. I suspect this is because it signals a lack of ownership. If you care about your feed, you maintain it yourself.
  4. Even with feeds that work, sometimes connections fail, or things break, just because it's the wild and crazy web out there. Taking that into consideration from the start, and tracking the last result for every feed, was one of the smarter things I did. I should probably be tracking more, but I'm too lazy to do real logging.
  5. Feeds are messy, and sanitization is hard. People inject all kinds of styles into their RSS. They include height and width attributes that don't play well with mobile. They put things into tables. They load scripts that I don't want to run, and images that I'd like to defer until their containing post is activated. Right now, I'm using document.implementation.createHTMLDocument() to make a functional (but "dead") DOM, then running a sanitization task over that, but figuring out that process--and making it watertight--has not been easy.
  6. In fact, working with RSS--ostensibly a "machine-readable" format--tends to drive home just how porous the web can be, and how amazing it is that it works at all. Take RSS date formats discovered by the developer of another reader web app, for example. I'm relatively isolated from the actual parsing, but there's code in Weir to work around buggy HTTP responses, missing feed information, and weird characters. Postel's Law has a lot to answer for, in my opinion.
  7. "Worse-is-better" really works for me as a personal development philosophy. My priority has been to get things running, no matter how badly--hacks get added to the .plan file and addressed later on, when I have time to figure out a graceful solution. This has kept my momentum high, and ensured that I don't get bogged down with architecture that I might not even need.
  8. The value of open-source software for this project can't be overstated. There's no way I could have built Weir on my own. In addition to Node, of course, I'm using a number of open-source modules for parsing feeds, handling two-factor auth, and storing posts in the database. Because of open source, I can patch those various libraries together, add my own code on top, and have a newsreader application that does everything I need. Weir doesn't stand on the shoulders of giants--it stands on the shoulders of countless other people, each giving a little bit back to the wider community.

July 16, 2013

Filed under: politics»issues»firearms

Trigger Happy

I wish I could say I'm surprised by the verdict in the Trayvon Martin case. It would have been nice to see the manslaughter charge stick--even Florida should be able to prosecute the poor man's murder--but that was probably a long shot. The fix was in from the moment that the police had to be embarrassed into even charging Zimmerman in the first place.

There were a lot of ugly parts of the American character wrapped up in the case. There was the casual, almost off-handed racism of the whole affair, but there was also the clownishness of our national fixation on firearms. That's the narrative that drove George Zimmerman, after all: a one-man neighborhood watch, following whatever "punks" were unlucky enough to find themselves the antagonists of his inner screening of Death Wish. I imagine that there are a lot of people who knew Zimmerman, who thought he was a nut and a caricature--almost a joke. After all, I have known people who were a hair's breadth from being George Zimmerman, and I've laughed at them. They're a lot less funny now.

Over the last year, since the shooting in Newtown, Josh Marshall has reposted stories to the TPM Editor's Blog whenever there's a story on the wire services of child deaths caused by guns. On average, there's probably one a week. It's a powerful, if understated, kind of journalism, like one of those Family Guy hanging gags: at first it's horrific, then it becomes routine, and then the normality of that routine becomes devastating in and of itself. There have been a lot of kids killed in the last eight months, with surprisingly little outcry.

It's as if, across the country, we've decided to raise our kids in a tank filled with deadly scorpions. Even though we lose children on a regular basis, discussing the obvious solution--getting rid of the scorpions, maybe buying a puppy instead--doesn't seem to be an option. To the contrary: more scorpions, screams the NRA! Scorpions for everyone! Only when everyone is covered in poisonous arthropods will we truly be safe!

(Of course, as various people have commented, the NRA is oddly silent on whether or not Trayvon Martin would have been safe from assault if he had been packing heat. This differs markedly from their usual argument that the solution is always more, and more powerful, weaponry. I can't imagine what's different in this case.)

With every recent shooting, there's been a sense on the left that this time, people will see how terrible our firearms fetish has become: Tucson, Aurora, and Newtown each brought a fresh sense of unreality to the whole debate. And now George Zimmerman walks, after shooting an unarmed black teenager for the simple crime of being where George Zimmerman didn't think he belonged. Maybe, finally, this will be the case when we start to think about what all these guns actually mean as a society, but I doubt it. That gives us too much credit: the deadlier our guns, the more we cling to them for comfort. Heaven help us all.

July 9, 2013

Filed under: tech»web

Chromebook

I bought a Chromebook (the Samsung ARM model) a couple of weeks ago. It became increasingly obvious that the battery situation on my beloved Thinkpad was going from bad to worse, and trustworthy replacements are hard to find--especially on a budget. I still have lots of uses for the Thinkpad (it may end up serving as a media center if the XBox dies again), but it can't really be portable the way I need it to be when my classes start back up again.

I don't particularly want to get into the question of whether the Chromebook is a good solution for other people. I'm not other people. I can't tell you whether they'll like it. I think it covers a great deal (if not all) of the average person's computer usage, most of which is spent in a browser, but I don't have evidence to back that up, and I'm not going to treat my case as representative. What I can say is how it's working for me so far, specifically as a writer and a web programmer with a heavy emphasis on Linux tools. And the answer is that, for the most part, it's working very well.

My top priority was battery life and portability. I'm on a bus for two hours a day, and one of my goals this year has been to turn that into productive time by working on my textbook, lesson plans, or other projects, preferably with some juice left over for when I get off the bus and walk into my classroom at night. The Chromebook definitely has that covered. I'm not sure the battery meter is 100% accurate, but I tend to run out of energy before it does, and the ultrabook size is easy to carry or slip into a small Timbuktu bag. The build quality seems solid, although I'm a bit uneasy with the idea of cheap, "disposable" laptops like this.

Second priority was a decent browser experience, since (like most people) I spend most of my time these days in a browser. Depending on the page, the Chromebook can be a little slow sometimes, but it handles most things the way you'd expect Chrome to do. It's easy to forget that it's basically a smartphone chip hooked up to a big screen. WebGL performance is surprisingly good: I loaded up the new Google Maps beta, and had no problems panning around a 3D textured version of downtown Seattle. Flash is built-in, so I'm not missing that (the new XBox Music site, like a lot of its competitors, still uses Flash for streaming audio). Tethering works flawlessly.

But my third priority (and still a must-have factor for me) was the ability to develop and write on the Chromebook itself. Being able to log into a server from the Chrome OS SSH client is fine, but a lot of the time I still don't have a network connection. If I can't work locally using the tools I'm used to, it's useless to me.

There's a thing called Crouton that installs a full, semi-sandboxed Linux distribution alongside Chrome OS. The two operating systems share a kernel, but have separate sets of binaries and processes. The result is a complete Ubuntu server stack that I can dip into whenever I need to work offline, including Git, NodeJS, PostgreSQL, and all the other command-line utilities I've gotten used to having. Crouton's totally supported, by the way: you need to be in developer mode, but that's just a keystroke away.

You can even set Crouton to run the graphical interface for the second OS, toggling between them, but considering how much I hate the Linux GUI situation, I haven't bothered. Chrome OS works nicely to manage my terminal and browser windows--the Aura interface that they've added lately does a decent impersonation of Windows 7, including an improved version of Aero Snap. There are some quirks--the dedicated "switch windows" button doesn't seem to quite work consistently--but it's already the best Linux window manager I've used.

The weirdest thing as a developer is the lack of full-powered editors running within Chrome itself. Cloud9 doesn't run on ARM yet, and Brackets isn't available as a packaged app. I'm personally fine using a terminal-based editor--I wrote most of Weir using Nano, and I'm getting more comfortable with vim--but it surprised me that none of the web-based editors have made a serious effort to run on a web-based platform.

The second-weirdest thing is the way Chrome OS distinguishes between "bookmarks" and "applications," considering that (for the most part) they're the same thing. There is a legitimate set of "packaged apps" that get more privileged API access, but most of the products in the Chrome "web store" are just links to web sites, so why can't I add bookmarks (such as the aforementioned XBox Music site, which I prefer to run in its own, chromeless window) to the Chrome OS launcher? I've been using this method to build single-serving Chrome Apps for the few sites where I want this ability, but it really ought to be built-in, and (considering that all you need is a JSON manifest and a .png file) I have a hard time understanding why it's not.

Oddities aside, though, the Chromebook is a great little machine for my needs so far. If I edited photos/audio/video on the go, or wanted a portable gaming laptop, I'd probably feel differently. On the other side of the power spectrum, if I didn't need a keyboard, I'm sure an Android tablet would cover a lot of my needs. My work, however, is almost entirely centered on text-editing in a web-friendly (preferably Linux or Windows) environment, and Chrome OS handles that gracefully and without complaint. It's surprisingly close to being useful even without Crouton. I'm excited to see whether (between Chrome OS and Firefox OS) the web platform can become legitimately self-sufficient in the future.

July 2, 2013

Filed under: music»artists»the_roots

Mo Meta Blues

It seems cruel to suggest that the worst half of Ahmir "?uestlove" Thompson's new memoir, Mo Meta Blues, is the half that's actually about him. Cruel, but not untrue--and not undeserved, given that ?uest himself opens the book by complaining about the predictability of most musical memoirs. Maybe that's impossible to escape. But when the rest of the book practically sparkles with mischief, I can't help but wish it was willing to spend more time dancing around expectations.

The book opens with a great deal of self-awareness. We're dropped into an interview between ?uestlove (a nickname that is wreaking havoc with my keyboard muscle memory) and an unnamed interviewer, debating how the memoir should be written. A letter from Ben Greenman, co-writer, then fills in some context: the interviewer is Richard Nichols, co-manager of The Roots, the band for which ?uestlove has been drumming for many years. Nichols proceeds to almost steal the show: a passionate and wry speaker, he takes over the narrative during the interview chapters, contradicts ?uestlove's account of events, and then decides he doesn't particularly care for the interview format. He spends the rest of the book weaving arch comments into the footnotes instead.

This is a book that takes the "meta" part of the title very seriously.

The problem is, when Mo Meta Blues actually slips into memoir, that awareness and playfulness seems to vanish. There are times when it picks back up, like ?uestlove's amazing Prince anecdotes or his year-by-year recounting of the best records he listened to throughout his childhood and why they're important, but these are few and far between. For the most part, the biography part of the story follows a traditional trajectory, with little scandal: The Roots form up in Philly, struggle for years, mingle with a collective of other artists, and eventually reach a kind of working success. The group comes across a lot like ?uest himself: wholesome and largely uncontroversial.

Which, to be fair, is not untrue: The Roots are not another Motley Crue, behind-the-music tabloid tale. But I think it probably undersells them. As Mo Meta itself points out, they're an uncommon outlier in modern hip-hop: a live band with lots of members and a long chain of albums, not to mention an expressly political viewpoint. There are hints of analysis there, but I wanted more.

So what we're left with is half slightly-dull memoir, half guided tour through hip-hop's sonic history. Which half wins? To me, it's a no-brainer: as a fan of his music, I'm happy to indulge ?uestlove for a few hours. But I'd love to see him cast his critical net a little wider next time.

June 27, 2013

Filed under: movies»reviews»scifi

Magic Missile

I'm not entirely sure why you would make films based on a franchise that you never liked. I'm on record as believing that the first JJ Abrams Star Trek flick was a reasonable popcorn flick but it didn't share anything with the original product except some character names. That's not true for the second movie. Into Darkness (to use its weird, not-really-a-subtitle subtitle) isn't just bad Trek, it's loathesome filmmaking.

The low-hanging fruit is that the plot doesn't even try to make sense for more than five minutes at a time, but since the original series was hardly airtight, I have a number of other bones to pick, including:

  • The Enterprise is not a submarine.
  • In a franchise known for its progressivism, it's painful to see all of the women reduced to either needy girlfriends or passive sex objects.
  • Along the same lines, I like Benedict Cumberbatch just fine (actually, I think most of the actors do a decent job), but he is surely one of the whitest people on earth and should not be playing Khan Noonien Singh.
  • The Enterprise is not a submarine.
  • Scotty's Magical Transporter and Plot Hole Device can now send people all the way across to the Klingon empire, but our heroes still get in a ship to follow him because there wouldn't be a chance for a pointless shootout otherwise.
  • Star Fleet dress uniforms that bear an uncanny resemblance to Death Star formalware.
  • Warp speed is now basically Rainbow Road, complete with starships spinning out into space with skidding sounds when they get hit with a blue shell magical laser beam.

Sure, much of this probably seems like nitpicks and nerd rage. I've watched a lot of Star Trek, probably more than most people, and so there are a lot of things that to me are instinctively not right but aren't necessarily invalid. I think it's a shame to lose those parts of the Trek canon (and I tend to think that Abrams' alterations are worse than the material he's replacing), but I'm hardly objective. Lance believes that he's just trolling us, and I'm not sure that's wrong.

I find the movie's general incoherence to be frustrating. But that's not what actually makes me angry.

At the end of Star Trek Into Grim Serious Incoherence, Khan crashes his spaceship into San Francisco. Hundreds of thousands, if not millions, of people are killed, but that's okay because they're not the protagonists and presumably their psychological issues were less attractive. This is, to put it lightly, not really what Gene Roddenberry had in mind when he pitched "wagon train in space" to some bored Desilu executives.

Speaking personally, I'm getting a little sick of the whole "it's been a decade since 9/11, so let's crash a flying vehicle into a city and call it emotional resonance" thing that every hack director with a render farm has been on lately. Abrams is doing it, apparently the new Superman movie does it, The Avengers did it. It's a cheap, transparent ploy to make otherwise airy summer entertainment seem important, so that critics can write that your otherwise incoherent summer tentpole flick has "real-world allusions" in it. Blowing up a planet in the first reboot movie wasn't enough, I guess.

Nowhere is that more true than in Star Trek No Subtitles Just Darkness. Khan doesn't really have a good reason to crash his ship into a major city. It doesn't particularly help him achieve his goals. He just does it because, as with every other reason that anyone does anything in a JJ Abrams movie, it's part of the story checklist they wrote before actually getting to outmoded concerns like "dialogue" or "motivation" or "character." City destroyed: tragedy achieved. On to the next setpiece!

Reboot or not, there are some things that a Star Trek movie shouldn't do, and mass murder is one of them. I'm under no illusions about the ideological purity of Star Trek, especially under Paramount's management, but I like to think that Roddenberry's vision should mean something regardless. As it is, there must be a little whirlwind somewhere around the ionosphere where his ashes are spinning. If JJ Abrams wants to participate in a little cinematic disaster porn, he's welcome to do so, but I wish he'd restrict it to some other, less established franchise. It's probably just as well that he's moving on to Star Wars: this kind of bankrupt cheesiness will fit right in there.

June 19, 2013

Filed under: random»linky

Remember the Linkblog!

Obviously I've been a little obsessed with RSS the past couple of weeks (get used to it: it'll be everyone else's turn come July 1). Along the way, I've been trimming my subscription list: I've been blogging for more than nine years now (!), and collecting feeds for nearly as long. A lot of those URLs are now broken, which is a little sad. In a precursor to the whole Google Reader situation, if you were on Feedburner, there's a pretty good chance I'm not reading you anymore.

Speaking of things that people don't really do in a post-Twitter world, I was reminded this week that I need to post another set of links--not so much because anyone else is interested, but because between the dismal searchability of social media and the death of bookmark services like Delicious, it's the only way I can be sure to find anything more than three months from now. And so:

  • A lot of people linked to Jeremy Keith's defense of RSS-as-API this week. Indeed, when I was at CQ, getting RSS running for our various services and reports was one of my constant campaigns. In many ways, it's one of the purest expressions of the web: a machine-readable format of human-centric information.
  • What reminded me of link-blogging in the first place was this study of privacy and de-anonymization, which I knew I'd posted to one service or another but could not for the life of me locate when I wanted it. It's a fascinating case of matching health records to individuals through obscured metadata and demographics--food for thought in light of the NSA metadata hubbub.
  • Earlier than expected, and all too soon, Iain Banks died last week. Ken Macleod has a passionate remembrance in the Guardian.
  • I have always been skeptical of WebGL, but it looks like it'll graduate to legitimate technology with a rumored inclusion in IE11. I still think it's a terrible API. That said, this article by Greg Tavares (one of the Chrome coders on WebGL) got me more excited about it than any other tutorial has ever done. Tavares points out that it's not actually a 3D API, but a 2D drawing API with decent tools for projection math. In that light, and given my love for 2D, I've actually started screwing around with WebGL a little.
  • If you are interested in using WebGL for 3D, though, this presentation does a great job of presenting both the what and the why of the math involved. It almost made me care about matrices again.
  • It is taking years, but people are finally realizing that the web is not killing long-form journalism. If anything, it may be enhancing its chances.
  • I really enjoyed this retrospective on the Portal 2 alternate reality game. The section on false clues and coincidence is a testament to people's ability to match patterns, whether they exist or not. It sounds like a fun gig.

June 12, 2013

Filed under: tech»web

Outward Vectors

I'm happy to say that Weir is now in a beta-ready state. You'll need a server capable of running NodeJS and PostgreSQL (for now), and you'll need an OPML file to populate the feed list (Google Takeout will accomodate you nicely with a subscriptions.xml if you're fleeing Reader). But if you pull from the repo and then follow the instructions in the readme file, everything should be in a good-enough state to fetch, read, and mark stories as read. Feedback would be awesome.

The front end for Weir is written using AngularJS, because it's supposed to be great for rapid development and I'm all about failing fast on this project. Indeed, getting the client-side application up and running has gone very quickly, but Angular itself takes some adjustment, especially if you're used to other JavaScript frameworks.

I'm not convinced that this is a bad thing. Predictions are a mug's game, but I suspect that future libraries are going to look a lot more like Angular than its competitors. Before I can explain why, we have to first look at the way client-side JavaScript has been traditionally organized, and then see how Angular works differently.

JavaScript MVC libraries, from Backbone to Ember, find themselves confronted with a language that's very different from the languages where Model-View-Controller philosophies evolved:

  • JavaScript has no privacy, and (until recently) no getters and setters. Between the two, it's hard to know if a given object has changed since the last redraw.
  • The DOM is not designed to be strongly linked with JavaScript data structures.
  • Multi-level inheritance of values is fine, but inheritance of behavior is a mess.
Despite these quirks, libraries are still designed as if JavaScript was similar to SmallTalk. They work around the differences by using manual getter and setter functions on Model classes, registering for DOM events inside View classes, and retemplating using templates when one or the other is changed.

This works--and is certainly a million times better than writing jQuery spaghetti code--but it's not what you'd call "clean." For example, here's some code written in an imaginary (but typical) library, just to update a simple list view: var Song = new Vertebrae.Model.extend({ title: { value: "" }, listens: { value: 0 }, file: { value: "" }, starred { value: false } }); var SongView = new Vertebrae.View.extend({ render: function() { var model = this.get("model"); var el = this.get("element"); el.find(".can-template").html( templates.song(model.toJSON())); var rev = model.get("review"); el.find(".cannot").val(rev); } });

That is a lot of boilerplate just to display a song (and it doesn't even include the templates, or loading the actual data). Heavy object classes are necessary so that the framework can be notified of changes--hence all the extend and get calls, as well as the awkward way of defining default values. In places, we can at least use templates, but we're still having to place them manually into the DOM. It's like a terrible parody of Java's worst bits glued onto jQuery.

In contrast, Angular uses regular JavaScript objects, written with normal JavaScript syntax, for its models. There are no getter or setter functions, unless you really want them: change an object, and if it is attached to the $scope variable, it will be scanned for changes automatically. And while you're not discouraged from using inheritance, you're not really encouraged to do so, either. Angular uses prototypal inheritance to manage values under the hood, but its developer-facing APIs tend to bear more resemblance to AMD or CommonJS modules. It feels like JavaScript, in other words.

On the other hand, Angular is all about augmenting HTML: although templates are available to ease re-use, an Angular page actually gets marked up using custom tags and attributes, then compiled and linked into components that respond instantly to the application's backing data. This is very forward-thinking--in fact, it's not dissimilar from the Extensible Web Manifesto, and I can dig that--but it definitely comes across as "magic" the first time that you use it. After years of logic-less template engines being popular, Angular stakes out a very different position.

Normally, I'm not a fan of magic in programming: it's hard to debug what you don't understand. In this case, the novelty of Angular's approach--and its undeniable effectiveness--overcame my skepticism, to the point where it's really grown on me. Using Angular makes me much more aware of the boilerplate that's required by the traditional MVC frameworks I use in my day job. Simple tasks require less code, and I don't feel like I'm fighting my way through thick layers of abstraction.

If there's a place where Angular still feels awkward, it's anything to do with the DOM. Angular will let you get access to elements of your page, but only reluctantly--it would really prefer that you only alter your model data and let the DOM react. Most of the time, this is fine: the less page manipulation I have to do, the happier I am. But there are some times when it is inevitable, such as when I'd like to perform deferred image loading, and those are definitely the ugliest parts of Weir's client code so far.

But here's the rub: if the web ecosystem teaches us anything, it's that you can always make a simple framework faster and more powerful, but people won't use an API that's clumsy and tiresome (see also: jQuery vs. pretty much everything else). Yes, DOM manipulation isn't great in Angular--they'll have to write some new directives, to cover the edge cases and holes. Yes, the object polling that Angular does is kind of scary, but browsers will add features like Object.observe() to make it faster overnight. Meanwhile, nothing's going to make those heavy Model and View classes any more fun to use.

There has been (and still is) a lot of time in the JavaScript community spent trying to make it work like something more familiar. That's how you end up with Coffeescript, or YUI, or all these MVC frameworks. Those projects have a place, and there are certainly times when I want something familiar, but it's also good to see tools (like Angular, Node, or D3) that are built around JavaScript weirdness. There hasn't been an oddball language with a profile this high in a long time, so let's shake things up while we've got the chance.

Future - Present - Past