shimon/travel/Cincinnati


link

My frassle activity has been light lately. I took a small vacation and didn't think much about blogging. Instead, I ate well, slept soundly, and enjoyed the warm (compared to Boston) Cincinnati weather. When I wasn't fully engaged in laziness or family, I was either moving furniture with my California-bound friend Coleman, or programming Javascript.

Yesterday I told Ingo Muschenetz that I had been programming a lot of Javascript, and he offered his sympathies. This is a common reaction: "real programmers" look down on scripting languages, and scripters don't even associate with the losers who write Javascript. Of course, with cool apps and new buzzwords, people are once again stunned at what you can do in the browser, and Javascript is reaching a status not unlike illegal immigrant labor: shameful and abused, but vital to the great stuff coming out of California.

But Javascript isn't all that bad. It's actually kinda nice. While its syntax mostly mimics its namesake, Java, it is in spirit just another dynamic functional language. My personal programming style, developed through Perl hacking and Java schooling, is a blend of object-oriented and functional/dynamic styles. Meaning that I use classes to support modularity and hold state, but use a lot of hashes, lists, and closures.*

It turns out Javascript is excellent for this. In Javascript, the hash (a map from arbitrarily-valued keys to values) occupies a position like the list does in Lisp. Every object in Javascript is a hash, including regular arrays. An object is a hash whose values are either variables or function references. myObj.getFoo() is equivalent to myObj["getFoo"]().

I am not without complaints about Javascript. With some syntactic sugar my programs could be 40% shorter and 20% easier to read, as they would be in Perl or Lisp. With a better and more stable spec from ECMA, cross-browser compatibility wouldn't be as hard. But I also respect that Javascript's priority should be coverage and consistency rather than elegance. Considering that the next feasible choice is Microsoft's VBScript, which would make my programs ten times longer and force me to write sort routines instead of novel UI, I'm impressed. That puts me in the corner with Douglas Crockford, who wrote a wonderful exposition of Javascript way back in 2001.

* Footnote: If you're a Lisp hacker, or just someone who thinks Perl is dirty, I want to understand why you feel that way. Perl has all the important functional features I'm aware of, and if I should really be using Lisp instead I'd like to know. Of course you can write hideous crap in Perl, but it gives the programmer amazing leverage over the language, which translates into huge productivity gains. Is it the punctuation? The diversity supported by the Perl's huge vocabulary? The hackish user community? Or are you just being lazy?

I'm taking a trip to visit my family in Cincinnati in a couple of weeks. Flight plan:

  • Fri 13-Aug-04: BOS -> CVG, 7:25 pm — 9:41 pm
  • Sun 15-Aug-04 CVG -> BOS, 6:55 pm — 8:59 pm

I look forward to seeing the mom, the grandmothers, the dog, the cats, and a few friends who happen to be in town.