Peter-Paul Koch, ppk on JavaScript — June 27, 2010

Peter-Paul Koch, ppk on JavaScript

![Cover of ‘ppk on JavaScript’: the letters ‘ppk’ spelled out hacker-like, with ‘]{’ supposed to form a ‘k’ and so forth.](https://static.stevereads.com/img/book_covers/ppk_on_javascript_cover_smaller.jpg)

This is a book for beginning JavaScript developers. If they come to this book with any pre-existing software-development experience, and they have any choice in the matter, the most sensible response will be to run away from the field as fast as possible.

There’s no elegance in this book. It is a collection of ways to hack around browser defects. This is expected, given that its author runs the famous QuirksMode website, documenting in glorious detail all the ways that browsers vary in their support for web standards. You’ll find, for instance, that Internet Explorer calls the target of an event its srcElement, while the standard calls it its target. So then you’re required to write a little shim like ppk’s doSomething() method. Or you’ll find that the XMLHTTPRequest object behaves differently under different browsers, requiring another abstraction like ppk’s createXMLHTTPObject().

None of this is actually interesting. At best, when you’re done using every one of these abstractions, you will have overcome some silly impediments to doing what you actually want to do. What is interesting about software development is actually solving problems. When a language — or, in this case, an ill-specified language with competing frameworks — gets in the way of getting the task done, it forces you to gnash your teeth just to accomplish basic chores, not to speak of the challenge that you entered the profession to solve. Syntax hurdles are not interesting; actual substantive problems are.

This sort of problem is why libraries like jQuery exist. Instead of dealing with every browser’s strange implementation of XMLHTTPRequest, you deal with a normalized jQuery object that looks like $(someObject). That $(…) business is where all the target-versus-srcObject, ActiveXObject-versus-XMLHTTPRequest nastiness gets hidden.

Indeed, throughout ppk on JavaScript, all I could think was that much of what Koch was writing should be hidden behind frameworks like jQuery. (And if Koch were writing this book today, I’m fairly certain he’d help you skip all that.) An ungodly fraction of the rest of ppk on JavaScript is devoted to the basic syntax details of JavaScript — for-loops, while-loops, and the rest. Any experienced developer is going to skip right over these.

It is a valuable book if you want to understand the fundamentals beneath your jQuerys and Node.jses and such. I’m sure it’ll be good to have on my shelf to grab when I encounter some corner case. But over time, the difficulties covered in ppk on JavaScript are getting hidden more and more beneath frameworks, and pushed out of existence as browsers become more standardized and websites drop support for old browsers. So ppk on JavaScript starts to look like a dated catalog of the bad old days.

P.S.: It’s a small nit, but I really did enjoy this line of Koch’s: “Frankly I don’t believe that Internet over mobile phones will ever amount to much in Europe and North America”. ppk on JavaScript came out in late 2006; the iPhone came out in mid-2007. Talk about bad timing. This convinces me (as if I needed any more convincing on this point) that playing the tech prognosticator is a mug’s game.

In defense of AT&T — June 22, 2010

In defense of AT&T

People love to bust on AT&T, but I have to say that I have no — zero — complaints about them:

* __Reception__: AT&T’s reception has been better than it ever was when I was on Verizon. I can make calls from inside my girlfriend’s house in New Hampshire, and from inside my parents’ house in Vermont; on Verizon, I always had to step outside in both those places. And AT&T doesn’t even have service in Vermont! Needless to say, their reception in Boston is just fine. I’ve had some problems in the immediate vicinity of my workplace in Kendall Square; I believe that’s because the volume of electronic equipment there is over the top and causes lots of electromagnetic interference. I’ve had some problems with their reception in New York City. (NYC people: has AT&T gotten any better there?)

* __Their online store__: People were bitching and moaning about being unable to buy an iPhone 4 because AT&T’s website got slammed. I had no such problem. I ordered an iPhone from them on the day it became available, and was notified today that it’s shipped. (By the way: is “I’m going to have to wait a few days to order my several-hundred-dollar pocket computer, *and I am pissed*” the definition of “first-world problem”?)

* __Customer service__: Verizon’s customer service was always great, and they always tried to find me the plan that fit my needs. AT&T has done the same. (Bank of America’s customer service is also stellar. I guess I’m supposed to hate BofA too, but I don’t.)

Others may have had worse luck, but I kind of wonder if people just like getting mad at big companies.

Barack Obama…for state senate! —

Barack Obama…for state senate!

Back when I was in college (Carnegie Mellon class of 2000), a friend who was attending the University of Chicago gave me a placard that was posted hither and thither on Chicago’s South Side: a dorky-faced guy with a ridiculously toothy grin smiling out at us. It read

“Barack Obama

for state senate”

My buddy Josh and I thought this was hilarious. Over the years, we turned the guy on the placard into a superhero. We’d be studying for one hard exam or another and would say to one another, “You know who could ace the piss out of this test right now?” The other would respond, “*Barack Obama!*” to which the first would respond, inevitably, “…*for state senate!*” Or we’d be at the gym: “Man, these weights are *tough*! … Know who could lift them without breaking a sweat?” “*Barack Obama!*” “…*for state senate!*”

The years go by. It’s 2004. There’s a dude up on the stage at the Democratic National Convention who’s making everyone ask, “Why do I have to vote for Kerry? Why can’t I vote for this guy?” Josh and I called one another: “Uh … dude, do you see who’s on stage right now?” It was surreal.

It’s still surreal. Every few months it occurs to me afresh that Josh and I were making this obscure local politician the punchline of a joke probably a decade before he became president of the United States. Bizarre.

Little Eclipse nits I want to fix: a series of notes to myself — June 18, 2010

Little Eclipse nits I want to fix: a series of notes to myself

As I think of them, I’ll add notes here on what I want to add to Eclipse. Eclipse is really pretty fantastic, and it’s 90% of the way to feeling like a really comfortable tool for me. Here’s what would make it perfect. Since it’s an open-source tool, I should be able to fix it.

1. Sometimes — but not always — you can Select All in the Project Explorer. When you can’t, you can click the first project in the list, then shift-click to the last project in the list. I submit that if that is possible, then Select All ought to be possible.
2. Periodically, Eclipse or Maven or m2eclipse or somesuch will have a mild freakout: *I can’t build project X until I get project Y!* But it’s just that project Y is closed. So: *get the various plugins to open project Y when necessary.*
3. run-jetty-run ought to honor the pom.xml, specifically the XML directive that tells jetty to use a specific port.
4. Command+Shift+R (under OS X)/Ctrl+Shift+R (everywhere else, I guess) doesn’t let your cursor keys wrap around the list control. My cursor starts at the top of the list of matching resources; I should be able to press the up arrow to go to the bottom-most matching resource, and vice versa.

Much larger than mere nits:

1. I wish Eclipse worked at all for Python development. I don’t know anyone who’s had good luck with Pydev, though maybe I need to give it another shot.
2. I wish Eclipse integrated better with FreeMarker: syntax highlighting, proper indenting and reformatting, jumping from macros to their definitions and their uses within your workspace, etc.
3. There are times when the only way I can unbreak my m2eclipse environment is by dropping to the command line and running various incantations like `mvn clean install eclipse:clean eclipse:eclipse`. I should never have to drop to the command line (that’s the point of an IDE, no?), but much smarter people than me say that they’ve never been able to control Maven flawlessly from inside Eclipse.

A note on blog branding — June 12, 2010

A note on blog branding

I long ago unsubscribed from Jack Balkin’s “Balkinization” blog when it was taken over by people other than its namesake. If you look at its front page now, *none* of the posts there are Balkin’s. Balkin’s voice is the reason I wanted to read it to begin with. Granted, it has other fine people — Marty Lederman, as I recall, has some good things to say, as do Sandy Levinson and Brian Tamanaha — but they don’t have the voice that I signed on for.

Now Matt Yglesias’s blog looks to be in danger of going the same way. He got some guest bloggers when he was away in China, because either he or his employer believed that filling in space was more important than purity of voice. They may be right in the aggregate; maybe people don’t care so much about hearing Yglesias’s distilled voice, and instead care to hear about those *topics* that interest Yglesias.

I hope ThinkProgress has some way to answer this analytically, because my suspicion is that it’s dead wrong. I submit that the reason people come to Yglesias’s blog is for his particular brand of intelligent sarcasm deployed against his opponents on matters of policy. (The Yglesias-Glenn Greenwald feud — Greenwald, as is his wont, constantly inveighing at excessive length against centrists, whom he constantly refers to as “centrists”; Yglesias poking fun at Greenwald and lecturing him as he would an overintellectual eighth grader — is a fine instance of the species.) Merely reading another writer lecture on No Child Left Behind just doesn’t cut it.

Ezra Klein did the same thing when he was on the same junket to China, with somewhat more success. He got Mike Konczal, of the Rortybomb blog, to write about financial reform; Klein had been writing on the topic in the days preceding his departure, and Konzcal happens to be both better qualified and a better writer than anyone else writing on the subject today, so that was a good pick. He had some other guest bloggers during the China trip, none of whom I remember.

It’s one thing to use guest writers when you’re away. It’s quite another to let them contribute to your blog while you’re still in town. That seems to be what Yglesias has done today, allowing one Ryan McNeely to contribute while Yglesias is (presumably) elsewhere in D.C. chilling out. I’m sure McNeely is a fine man, but my first thought upon seeing his name under the Yglesias masthead was, “Who the hell is this guy?” I advanced to the next post in Google Reader posthaste.

My advice to Klein and Yglesias is similar to the advice for aspiring cafés I read years ago: be known *for coffee*; don’t dilute your brand by being known both for high-end coffee and mediocre sandwiches. My advice to Balkin and Yglesias and Klein is: we love reading *you*; we don’t love reading your proxies. We’re not going to run away if you fail to update your blog for a few days. So relax and keep your brand pure.

An incomplete list of things you want from programmers — June 7, 2010

An incomplete list of things you want from programmers

Lest I be accused of being an entirely negative person when I document the difficulty of hiring software developers, let me enumerate — in roughly increasing order of desirability — a partial list of what one wants from developers:

* understand basic syntax in at least one language
* quickly absorb the rudiments of a new language
* quickly program idiomatically in that language
* use algorithms and data structures that reach a solution to your particular problem before the heat death of the universe, using a computer smaller than the Chandrasekhar Limit
* write literate code that you and others can understand months later
* know how to test your code so that you’re not handing QA a steaming mess
* be a good mentor to other developers, which means being a clear thinker and a clear speaker
* debug often mysteriously dysfunctional code
* know when it’s okay to be sloppy in your code and when it’s not
* quickly learn the set of available solutions to the problem before you, know how to compare them, and defend your chosen approach rationally
* take an ill-formed problem and fill in the details enough to start writing
* understand customer needs and turn them into a plan for a program
* understand customer priorities and reflect those in your day-to-day work, strategically cutting corners when it doesn’t deflect you from your path

By no means can I claim that I do all of these, or even do most of them most of the time; I’m still learning, and I expect that most candidates will also be learning. (Maybe “be able to pick up any of the items on this list that you don’t already know” should be the final bullet?) My point is that it is hard to screen for these things during a standard few-hours-long interview, or even during the standard interview+phone screen+coding sample process. Though it would be valuable, and probably not very difficult, to test for more of these during the interview. As it stands, most interview questions address the first couple bullets — or test your ability to repeat the stock answers to stock questions (“My biggest challenge was when I tackled [insert puffed-up big project]; my perfectionism nearly got the best of me, but I persevered”). What’s remarkable is that so many people get the trivial/stock questions wrong. Hopefully we’ll eventually move beyond those questions and start grilling developers on what really matters.

I finally had my first exposure to programmers who can’t program —

I finally had my first exposure to programmers who can’t program

This sort of madness is apparently commonplace. I had never directly encountered it, so I was shocked when I interviewed someone today who was incapable of performing a basic programming task. This was someone with a master’s degree from a prestigious university, and he couldn’t code something that you should be able to write as a freshman in college. Fortunately it only took, by my estimate, $18.07 in salaried time to screen him out: I put him in front of the excellent See[Mike]Code after a few minutes of pleasantries and “what would you like to know about our company?”-type questions, watched him fail to code, and ended the interview. During in-person interviews, we “fail fast”: if the first interviewers raise a red flag, they relay this to the second pair of interviewers; if the second pair of interviewers is negative or only neutral, we show the candidate the door. I’m now inclined to fail phone-screen candidates fast: program first, talk about the company second.

I’ve thought for a very long time that the hiring process is largely a *negative* affair: it establishes those people whom you screen *out*, but it doesn’t do a very good job screening *in*. You filter out the obviously incompetent programmers. Then you filter out those with bad social skills. Then you filter out those who fit badly with the company’s culture. You still may end up with disasters. At my company, we give candidates three to six months to prove their mettle even after we hire them, which is (it seems to be) an admission that the hiring process is imperfect.

In large, advanced market economies centered around anonymous transactions, you avoid some of these problems with credentialing organizations like universities. The assumption is that (apart from MBAs, which I gather are high-cost multi-year networking events) a prestigious school wouldn’t just put its stamp on anyone. After today, I’m not at all convinced that that’s true. I want to call up today’s candidate’s master’s-thesis adviser and demand that he pay me $18.07. Perhaps that would start shifting the incentives the right way.

iPhone 4 FaceTime/Infinite Jest mashup —

iPhone 4 FaceTime/Infinite Jest mashup

Apple’s introduction of FaceTime, their videophone protocol in the forthcoming iPhone 4, reminds me of this great passage in David Foster Wallace’s Infinite Jest:

(1) It turned out there there was something terribly stressful about visual telephone interfaces that hadn’t been stressful at all about voice-only interfaces. Videophone consumers seemed suddenly to realize that they’d been subject to an insidious but wholly marvelous delusion about conventional voice-only telephony. They’d never noticed it before, the delusion – it’s like it was so emotionally complex that it could be countenanced only in the context of its loss. Good old traditional audio-only phone conversations allowed you to presume that the person on the other end was paying complete attention to you while also permitting you not to have to pay anything even close to complete attention to her. A traditional aural-only conversation – utilizing a hand-held phone whose earpiece contained only 6 little pinholes but whose mouthpiece (rather significantly, it later seemed) contained (62) or 36 little pinholes – let you enter a kind of highway-hypnotic semi-attentive fugue: while conversing, you could look around the room, doodle, fine-groom, peel tiny bits of dead skin away from your cuticles, compose phone-pad haiku, stir things on the stove; you could even carry on a whole separate additional sign-language-and-exaggerated-facial-expression type of conversation with people right there in the room with you, all while seeming to be right there attending closely to the voice on the phone. And yet – and this was the retrospectively marvelous part – even as you were dividing your attention between the phone call and all sorts of other idle little fuguelike activities, you were somehow never haunted by the suspicion that the person on the other end’s attention might be similarly divided. During a traiditional call, e.g., as you let’s say performed a close tactile blemish-scan of your chin, you were in no way oppressed by the thought that your phonemate was perhaps also devoting a good percentage of her attention to a close tactile blemish-scan. It was an illusion and the illusion was aural and aurally supported: the phone-line’s other end’s voice was dense, tightly compressed, and vectored right into your ear, enabling you to imagine that the voice’s owner’s attention was similarly compressed and focused … even though your own attention was not, was the thing. This bilateral illusion of unilateral attention was almost infantilely gratifying from an emotional standpoint: you got to believe you were receiving somebody’s complete attention without having to return it. Regarded with the objectivity of hindsight, the illusion appears arational, almost literally fantastic: it would be like being able both to lie and to trust other people at the same time.

This is only the beginning of a several-pages-long discussion of why videophones (from the future-retrospective stance) failed. People notice first that they look really gross on camera. Then they get self-conscious, so they wear masks when they’re on their videophones. This makes them terrified to meet people in real life, because those people will discover that they’ve been lied to during their videophone chats. So people stay indoors. There are a few other steps in there that I forget (and Google Books is no help), but the end result is that society eventually makes one big coordinated move to drop its videophones.

(You really need to read Infinite Jest. It’s one of those books that everyone knows about but few read. You should be one of the few to read it. I reviewed it on Amazon back in 2001.)

By the way: I’ve been considering switching to any of the new Android phones when my AT&T contract expires in August, but the new iPhone seals the deal for Apple.

jQuery and XMLHttpRequest objects — May 31, 2010

jQuery and XMLHttpRequest objects

I’m trying to find an answer to this, but the web has been remarkably unforthcoming. This includes the usually stellar Stack Overflow. Here’s what’s going on:

* I’ve gotten comfortable in jQuery over the past few months. It is awesome.
* I’ve just started playing with XMLHttpRequest objects (i.e.,“Ajax”).
* jQuery has a few methods to help you do XMLHttpRequest calls, e.g., .get() and the lower-level .ajax().
* If a .get() request succeeds, you can attach a success callback to it. The arguments handed to the callback include the XMLHttpRequest object itself.
* XMLHttpRequest objects, according to the spec, have a getAllResponseHeaders() method.
* It would seem to follow, then, that the XMLHttpRequest object in jQuery.get() and jQuery.ajax() would also contain a getAllResponseHeaders() method. If it does, I can’t get Firebug to print its results; it only tells me “null.” Null is a kind of sadness.
* Other pages, including the Stack Overflow one that I mentioned, indicate that other people have had this same problem. But no one seems to have solved it. So I’m putting the description up here; when I solve it, I will contribute to the world’s stock of knowledge, and a great light will shine forth upon the land. Hosannas, etc.

Methods of measuring GDP — May 30, 2010

Methods of measuring GDP

A colleague the other day mentioned his annoyance with the Hans Rosling TED talks on global poverty. His annoyance generally stems from treating developing nations’ GDP estimates as anything more than numerical hocus-pocus.

A few things I know basically nothing about:

* I really have no idea how hocus-pocusy these GDP estimates are.
* I also have no idea how hocus-pocusy the U.S.’s own GDP estimates are.
* Another thing I have no idea about is whether every year’s GDP estimates from a given country are mangled in the same way, so that (estimated GDP in year 2) minus (estimated GDP in year 1) is actually a reasonably accurate measure of year-over-year change in GDP.
* Per-capita GDP estimates might introduce another source of uncertainty, namely uncertainty in the population estimates. I likewise have no idea how accurate most nations’ population estimates are. And I have no idea whether per-capita-GDP estimates come from sampling individual people on their incomes, or estimating the country’s aggregate GDP and dividing by an estimate of the population.

I guess what I’d like, then, is a good introduction to the problems of measurement in countries with not-very-well-established economic-measurement systems — and for that matter, an introduction to how the U.S. statistical-measurement agencies do their work. Paging Chris Blattman