MATHEMATICS

Senin, 25 September 2006

Blogger's Block #4: Ruby and Java and Stuff

Part 4 of a 4-part series of short posts intended to clear out my bloggestive tract. Hold your nose!

Well, I held out for a week. Then I read the comments. Argh! Actually they were fine. Nice comments, all around. Whew.

I don't have any big themes to talk about today, but I've got a couple of little ones, let's call 'em bloguettes, that I'll lump together into a medley for today's entree.

Bloguette #1: Ruby Sneaks up on Python



I was in Barnes today, doing my usual weekend stroll through the tech section. Helps me keep up on the latest trends. And wouldn't you know it, I skipped a few weeks there, and suddenly Ruby and Rails have almost as many books out as Python. I counted eleven Ruby/RoR titles tonight, and thirteen for Python (including one Zope book). And Ruby had a big display section at the end of one of the shelves.

Not all the publishers were O'Reilly and Pragmatic Press. I'm pretty sure there were two or three others there, so it's not just a plot by Tim O'Reilly to sell more books. Well, actually that's exactly what it is, but it's based on actual market research that led him to the conclusion that Rails and Ruby are both gathering steam like nobody's business.

I like a lot of languages. Really, I do. But I use Ruby. I'm not even sure if I like Ruby. The issue might just be irrelevant to whether I use it. I like OCaml, for instance, but I don't use it. I don't like Java, but I do use it. Liking and using are mostly orthogonal dimensions, and if you like the language you're using even a little bit, you're lucky. That, or you just haven't gotten broad enough exposure to know how miserable you ought to be.

I use Ruby because it's been the path of least resistance for most of my programming tasks since about 3 days after I started messing with it, maybe 4 years ago.

I don't even really know Ruby all that well. I never bothered to learn it. I did read "Ruby in a Nutshell" cover-to-cover, but it's a short read (and it's a bit out of date now.) Then I read bits of "Programming Ruby", but not all of it. And now I use Ruby for everything I can, any time I have any choice in the matter. I don't even mind that I don't know the language all that well. It has a tiny core that serves me admirably well, and it's easy to look things up when you need to.

I do a lot more programming in Python than in Ruby -- Jython in my game server, and Python at work, since that's what everyone there uses for scripting. I have maybe 3x more experience with Python than with Ruby (and 10x more experience with Perl). But Perl and Python both have more unnecessary conceptual overhead, so I find I have to consult the docs more often with both of them. And when all's said and done, Ruby code generally winds up being the most direct and succinct, whether it's mine or someone else's.

I have a lot of trouble writing about Ruby, because I find there's nothing to say. It's why I almost never post to the O'Reilly Ruby blog. Ruby seems so self-explanatory to me. It makes it almost boring; you try to focus on Ruby and you wind up talking about some problem domain instead of the language. I think that's the goal of all programming languages, but so far Ruby's one of the few to succeed at it so well.

If only it performed better. *Sigh*. Well, its performance is in the same class as Perl/Python/JavaScript/Lua/Bash/etc., so there are still plenty of tasks Ruby's admirably suited for.

I think next year Ruby's going to be muscling in on Perl in terms of mindshare, or shelf-share, at B&N.

Bloguette #2: Java's Biggest Failing (Literally)



I still do most of my programming in Java -- at least half of it, maybe more. The Java platform continues to make amazing strides. The newest incarnation (JDK 6) has lots of goodies I can't wait to play with. Like Rhino, for instance, and although they appear to have gutted it, it's still awesome. I think it's the best choice they possibly could have made. Thank God they didn't bundle Groovy. What a catastrophe that was, and still is, and would have been for Java if they'd bundled it. Rhino rocks.

The JVM is just getting faster and more stable, and there are even some OK libraries that come with it. I used to think the Java platform libraries were the cat's meow. Heck, I thought they were the whole damn cat. But working with better libraries in miscellaneous other languages has got me thinking that Java's libraries are hit-or-miss.

Example: Java's concurrency libraries (java.util.concurrent[.*]) are to die for. I mean, if you're stuck with threads. I think in the fullness of time, hand-managed threads will be history, but in the meantime, Java's concurrency libraries are just superb.

I recently ported a medium-sized Python program I'd written (about 1200 lines of fairly dense Python code) to Java, because the Python was taking about an hour to run, and I wanted to parallelize the work. I spent about 3 days doing the rewrite: one day on the straight port, a day adding in the threading, and a day fine-tuning it. The straight port wound up as 1300 lines of Java (surprising that it wasn't bigger, but maybe I code in Python with a Java accent?), and ran about 50% faster, down to about 30 minutes. After adding in the threading and state machine, the program ran in 50 to 60 seconds.

So I got an order of magnitude improvement with only about a 50% increase overall in program size. The vast majority of the improvement was attributable to the threading, which in turn would have taken me FAR longer if I'd been using raw synchronization primitives. The java.util.concurrent stuff made it a snap.

On the other hand, Java's DOM implementation completely blows chunks. It quickly became the bottleneck in my application, due to an O(n) algorithm I stumbled across with no good workaround for. I can't remember exactly where it was (this was back in July), but I found a sheepishly apologetic comment from the author in the online docs. It was something to do with setting attributes on nodes while you're doing a traversal of some sort: something you'd definitely want to be fast, but it had at least linear performance, maybe worse, and now accounts for 95+% of my app's processing time.

And of course Java's DOM interface blows too, because you can't create subclasses or decorators or do anything useful with the DOM other than use it as a temp container until you've transfered the data to something more flexible.

Java's collections library is decent, but not superb. It's nice having the data structures they provide, but they're not very configurable, and the language itself makes them often cumbersome. For instance, you can have a WeakHashMap (nice), or an IdentityHashMap (nice), or a ConcurrentHashMap (also nice), but you can't combine any two of those three properties into a single hashtable. Lame.

And java.util is missing implementations and/or interfaces for a bunch of important data types like priority queues (you're stuck using a TreeSet, which is overkill), the disjoint set ADT, splay trees, bloom filters, multi-maps, and of course any kind of built-in graph support. Java hyper-enthusiasts will tell you: "well, go write your own! Or use one of the many hopefully robust implementations on the web!" That seems lame to me. We're talking about data structures here: they're more fundamental than, say, LDAP libraries and much of the other stuff Sun's bundling these days. It's smartest to provide robust, tuned implementations of these things, because it empowers average Java programmers to write faster, more reliable code.

Oh, and let's not even get me started with java.nio. What a mess! It's pretty gross, especially if you come from the comparatively simple background of select() and poll() on Unix. But maybe the grossness was necessary. I'll give them the benefit of the doubt. What bugs me isn't that the API is conceptually weird and complex (and buggy as hell last time I checked); what bugs me is that nobody at Sun bothered to put a layer atop java.nio for ordinary programmers. Like, say, a nonblocking DataInputStream that takes a type to read, a Buffer, and a callback to call when it's finished reading. So every frigging Java programmer on the planet has to write that exact class -- or just flail around with the raw APIs, which is what I think most of them do.

And look what they did to poor LDAP! I mean, the LDAP bindings are dirt-simple in every language I've ever used. It's supposed to be lightweight -- that's what the "L" stands for, fer cryin' out loud. JNDI is this huge monster. So is JMX. I mean, Java libraries have this way of being so bloated and overengineered.

But whatever; I've digressed. Java's libraries are not its biggest failing. The libraries (as I said) are decent, and the platform (in terms of tools, speed, reliability, documentation, portability, monitoring, etc.) really raises the bar on all those other loser languages out there. All of 'em. It's why no better languages have managed to supplant Java yet. Even if the language and its libraries are (on the whole) better than Java's, they also have to contend with the Java platform, and so far nobody's been able to touch it, unless maybe it's .NET, but who cares about .NET? Certainly not Amazon.com or Yahoo! or Google or any other important companies that I'm aware of.

Literals



Anyway, Java's biggest failing, I've decided, is its lack of syntax for literal data objects. It's an umbrella failing that accounts for most of the issues I have with the language.

The idea behind literals is that you have some sort of serialized notation for your data type, and it's part of the language syntax, so you can embed pre-initialized objects in your code.

The most obvious ones are numbers, booleans and strings. It's hard to imagine life without support for numeric literals, isn't it? Well, Java's support is limited at best. There's no syntax for entering a binary value, for instance, like "0b10010100". And there's no BigInteger/BigDecimal syntax, so working with them is a disaster and nobody does it if they can help it. Heck, Java doesn't even have unsigned ints and longs. But Java does more or less the bare minimum for numbers, so people don't notice it much.

Imagine if there were no String literals, so that instead of this:

String s = "Hello, world!";

you had to do this:

  StringBuffer sb = new StringBuffer();
sb.append('H');
sb.append('e');
sb.append('l');
sb.append('l');
sb.append('o');
sb.append(',');
sb.append(' ');
sb.append('W').append('o').append('r').append('l').append('d').append('!');
String s = sb.toString();

Not only is the latter bloated and ugly and error-prone (can you spot the error in mine?), it's also butt-slow. Literals provide the compiler with opportunities for optimization.

Well, unfortunately this OOP garbage is exactly what you have to do when you're initializing a hashtable in Java. Nearly all other languages these days have support for hashtable/hashmap literals, something like:

 my_hashmap = {
"key1" : "value1",
"key2" : "value2",
"key3" : "value3",
...
}

That's the syntax used by Python and JavaScript, but other languages are similar. The Java equivalent is this:

Map<String, String> my_hashmap = new HashMap<String, String>();
my_hashmap.put("key1", "value1");
my_hashmap.put("key2", "value2");
my_hashmap.put("key3", "value3");
...

It might not look that much worse from this simple example, but there are definitely problems. One is optimization; the compiler is unlikely to be able to optimize all these method calls, whereas with a literal syntax, it could potentially save on method call overhead during construction of the table (and maybe other savings as well.)

Another is nested data structures. In JavaScript (and Python, Ruby, etc.) you just declare them in a nested fashion, like so:

my_thingy = {
"key1": { "foo": "bar", "foo2": "bar2"},
"key2": ["this", "is", "a", "literal", "array"],
"key3": 37.5,
"key4": "Hello, world!",
...
}

It would be hard to do this particular one in Java 5 because of the mixed value types, though it's probably not an issue since using mixed-type data structures is something you rarely do in practice, even in dynamically-typed languages. But even if all the values were hashes of string-to-string, how are you going to do it in Java without literals? You can't. You're stuck with:

Map<String, Map<String, String>> my_hashmap = \
new HashMap<String, HashMap<String, String>>();

Map<String, String> value = new HashMap<String, String>();
value.put("foo", "bar");
value.put("foo2", "bar2");
my_hashmap.put("key1, value);

value.clear();
value.put("foo3", "bar3");
value.put("foo4", "bar4");
my_hashmap.put("key2, value);

...

And then you find out later that your clever clear() optimization (instead of creating a new HashMap object for each value) busted it completely. Whee.

Java programmers wind up dealing with this kind of thing by writing generic helper functions, and it winds up layering even more OOP overhead onto something that ought to be a simple declaration. It also tends to be brutally slow; e.g. you could write a function called buildHashMap that took an array of {key, value, key, value, ...}, but it adds a huge constant-factor overhead.

This is why Java programmers rely on XML so heavily, and it imposes both an impedance mismatch (XML is not Java, so you have to translate back and forth) and a performance penalty.

But the story doesn't end there. What about Vector/ArrayList literals? Java has primitive array literals, which is nice as far as it goes:

String[] s = new String[]{"fee", "fi", "fo", "fum"};

Unfortunately, Java's primitive arrays are a huge wart; they don't have methods, can't be subclassed, and basically fall entirely outside the supposedly beautiful OOP-land that Java has created. It was for performance, to help capture skeptical C++ programmers, and they have their place. But I don't see why they should have all the syntactic support. I mean, the [] array-indexing operator is ONLY available for Java arrays. Sure would be nice to have it for ArrayLists, wouldn't it? And Strings? And FileInputStreams?

But for some reason, Java gave arrays not one, but TWO syntactic sugarings, and then didn't give that sugar to anything else array-like in the language.

So for building ArrayLists, LinkedLists, TreeMaps and the like, you're stuck with Swing-style code assemblages.

I think of them as Swing-style because I used to do a lot of AWT and Swing programming, back when I was a Thick Client kind of guy, and they have a distinct(ly unpleasant) footprint. It looks vaguely like this, in pseudo-Swing:

Panel p = new Panel(new FlowLayout());
JButton b = new JButton("Press me!");
b.setEventListener(somethingOrOther);
p.add(b);
JSomething foo = new JSomething(blah, blah);
foo.setAttribute();
foo.setOtherAttribute();
foo.soGladIDontDoThisKindOfThingAnymore();
p.add(foo);
...

Building UIs in Swing is this huge, festering gob of object instantiations and method calls. It's OOP at its absolute worst. So people have come up with minilanguages (like the TableLayout), and declarative XML replacements like Apache Jelly, and other ways to try to ease the pain.

I was on a team at Amazon many years ago that was planning to port a big internal Swing application to the web, and we were looking at the various ways to do web programming, which at the time (for Java) were pretty much limited to JSP, WebMacro, and rolling your own Swing-like HTML component library.

We experimented with the OOP approach to HTML generation and quickly discarded it as unmaintainable. (Tell that to any OOP fanatic and watch their face contort as they try to reconcile their conflicting ideas about what constitutes good programming practice.)

The right solution in this case is, of course, a Lisp dialect; Lisp really shines at this sort of thing. But Lisp isn't so hot at algebraic expressions, and the best Lisp machines no longer look so cutting-edge compared to the JVM, and blah blah blah, so people don't use Lisp. So it goes.

The next-best solutions are all about equally bad. You have your XML-language approaches (like Jelly, but for the web), but they don't give you sufficient expressiveness for control flow -- presentation logic really does require code, and it gets ugly in XML in a real hurry. You have your JSP-style templating approaches, and they aren't bad, but they can have as many as 4 or 5 different languages mixed in the same source file, which presents various problems for your tools (both the IDEs and the batch tools).

And then you have a long tail of other approaches, none of which manage to be very satisfying, but that's not really the fault of the languages. It's the browsers' fault: they START with three languages (HTML, CSS, and JavaScript), rather than having just one language to control the entire presentation, and it only goes downhill from there.

But NONE of the approaches to web templating is as bad as Swing-style programming, with a huge thicket of calls to new(), addChild(), setAttribute(), addListener(), and the like. The only approach that's worse (and even it might just be tied) is raw HTML printing:

print("<html><body>...</body></html>");

So we're all in agreement. OOP-style assembly of parents and children is the worst way to generate HTML. You want to use declarations; you want a template, something that visually looks like the end result you're trying to create.

Well, it's the exact same situation for data structures, isn't it? You'd rather draw a picture of it (in a sense, that's exactly what you're doing with syntax for literals) than write a bunch of code to assemble it. This is all assuming that you're working with a small data set, of course. But that happens all the time in real-world programs; it's ubiquitous. So you kinda want your language to support it syntactically.

And so far we've only covered literal syntax for HashMaps and ArrayLists (which you can combine to produce various kinds of custom Trees.) Already Java's way behind other languages, and we haven't discussed any richer data types.

Like, say, objects.

JavaScript does it the best here, IMO, in the parity between hashes and objects. It's not really possible in Ruby or Python to declare a class, then create instances of the class using literal notation the way you can in JavaScript, where the keys are the names of instance variables. Fortunately you can accomplish this in either Ruby or Python with just a smidge of metaprogramming, so it's spilt milk at worst.

In Java, you only have one big hammer (instantiation), and one big wrench (the method call), so that's what you use. All you can really do to help is create a constructor that takes arguments that populate the instance variables. But if any of your instance variables are collections (other than arrays), then you're back to the old create-setprops-addchild, create-setprops-addchild pattern again.

And what about functions? Ruby and JavaScript and Lisp and Scheme and Lua and Haskell and OCaml and most other self-respecting languages have function literals. That is, they have a syntax for declaring an instance of a function as a data object in your code that you can assign to a variable, or pass as a parameter.

(Python has them too, but unfortunately they can only be one line, so Python folks prefer to pretend anonymous functions aren't very important. This is one of the 10 or so big problems caused by Python's whitespace policy. Don't ever let 'em tell you it doesn't cause problems. It does. Maybe it's worth the trade-off; that's a personal style preference, but they should at least admit the tradeoff exists.)

Well, Java sort of has them, but Java's static type system doesn't have a literal syntax for a method signature. It's pretty easy to imagine one, e.g. something like:

(int, int) -> String x;

This imaginary syntax declares a variable x that takes 2 ints as parameters and returns a string. Lots of languages have signature-syntax of some sort, and Java's syntax space is definitely sparse enough that they could pick a good syntax for it without fear of collisions, even conceptual collisions. But no such luck. Instead, when you want to do this sort of thing you have to declare a named interface, and then inside of it declare at least one named method (which is where the params and return type show up), and then you're still not done, because when you create the function you have to create an anonymous (or named) class that contains the definition of the function that matches the interface.

Yuck. But at least they let you do it; the alternative of not having it at all is definitely worse.

Still... isn't syntactic sugar nice? I mean, they added the "smart" for-loop, which Java programmers just rave about. So someone, somewhere in the Java community thinks syntax is good. I'm not sure many of them really understand the difference between syntactic sugar (into which category the "smart" for-loop falls) and orthogonal syntax, in which the basic operators apply to all data types for which those operators make sense, and there are literal declarations possible for every data type.

Let alone the next step, which is extensible syntax -- but that idea strikes fear into the hearts of many otherwise brave Java programmers, and Rubyists and Pythonistas as well, so let's back it up a notch to "orthogonal", and keep everyone calm.

So there you have it: Java's biggest failing. It's the literals. No literal syntax for array-lists (or linked lists or tree sets), nothing for hashtables, nothing for objects of classes you've personally defined, none for functions or function signatures. Java programmers all around the world spend a *lot* of their time working around the problem, using XML and YAML and JSON and other non-Java data-declaration languages, and writing tons of code (whole frameworks, even) for serializing and deserializing these declarations to and from Java. For the smaller stuff, they just write helper functions, which wind up being bloated, inefficient, error-prone, and extremely unsatisfying.

Java's next-biggest failing may well be the lack of orthogonality in its set of operators. We can live without operator overloading, I suppose (the simplest form of extensible syntax), but only if Sun makes operators like [] and + actually work for objects other than arrays and Strings, respectively. Jeez.

Epiblogue



You can draw your own conclusions about why suddenly there are all these books on Ruby appearing on the bookshelves. It's a mix of truths, no doubt. And you can draw your own conclusions about why Sun's adding support for scripting languages to the JVM, rather than simply fixing Java so that people don't want (need, really) to use those other languages.

But when you dig down into a programming language, and you get past all the hype and the hooplah, what you find is a set of policies and decisions that affect your everyday life as a programmer in ways you can't ignore, and that no amount of hype will smooth over.

If your language is sitting on you like an invisible elephant, and everyone using the language is struggling to work around the same problems, then it's inevitable that other languages will come into play. Libraries can make you more productive, but they have almost no effect on the scalability of the language.

Every language has a complexity ceiling, and it's determined by a whole slew of policy and design decisions within the language, not the libraries. The slew includes the type system (with its attendant hundreds of mini-policies), and the syntax, and it also includes the language's consistency: the ratio of rules to exceptions.

Java's demonstrating quite clearly that at a certain level of complexity, the libraries and frameworks start to collapse under their own weight. People are always writing "lightweight" replacements for existing fat Java libraries and frameworks, and then the replacements get replaced, ad infinitum. But have you ever seen anyone write a replacement for XPath? Nope. It's not like everyone is rushing out to write the next big XML-querying framework. This is because XPath is a language, not a library, and it's orders of magnitude more conceptually scalable than the equivalent DOM manipulations.

Object-Oriented Programming. Touted even by skeptics as a radical leap forward in productivity, and all OOP really is boils down to a set of organizational techniques. Organization is nice, sure.

But it's pretty clear that OOP alone doesn't cut it; it has to be supplemented with Language-Oriented Programming and DSLs. And all languages, DSLs and general-purpose languages alike, have to be designed to maximize consistency; each inconsistency and special-case in the language adds to its conceptual overhead and lowers the complexity ceiling.

So you can look at the shelves filling up with Ruby books and chalk it up to marketing hype, but I have a different theory. I think it's entirely due to complexity management: Ruby does a better job of helping managing complexity than its competitors. It doesn't do a perfect job, mind you -- far from it. But it's enough of a step forward in productivity (even over Perl and Python) that it's managing to shoulder its way in to a pretty crowded language space.

With that in mind, despite my griping about Java's failings, I think Sun might actually be doing the right thing by introducing scripting languages (and improving support for them in the JVM.) Maybe. Their investment isn't really so much in Java as it is in the JVM; the JVM is their .NET. Java's not really about productivity, not really -- it's got a lot of strengths (performance, deployment, reliability, static checkability, and so on), but productivity isn't high on the list. So maybe the best way to address the productivity issue, for folks who really need it more than raw performance, is to introduce new JVM languages rather than try to pull Java in two directions.

We'll see. And with that, I think I've officially un-blocked myself; I seem to be able to blog again. So I'm declaring the Blogger's Block series finished!

BloggersBlock block = new BloggersBlock();
block.setFinished(true);
block.tieOffAndStuff();
blog.addChild(block);
...

Selasa, 19 September 2006

Blogger's Block #3: Dreaming in Browser Swamp

Part 3 of an N-part series of short (well, fast, anyway) posts intended to clear out my bloggestive tract.

I've been doing a lot of JavaScript and DHTML and AJAX programming lately. Increasing quantities of it. Boy howdy. The O'Reilly DHTML book has gotten big enough to crush a Volkswagon Bug, hasn't it? And my CSS book has gone from pristine to war-torn in under a month. I've managed to stay in the Dark Ages of web programming for the past 10 years: you know, HTML, a little CGI, font color="red". Way old school. And now I'm getting the crash-course. The more I learn, the more I wish I'd known it for longer. Although then I'd have had to live through the long transition from Dark Ages to the muchly-improved situation we have today. Far from good, to be sure, but it's improved dramatically since last I looked.

JavaScript is probably the most important language in the world today. Funny, huh? You'd think it would be Java or C++ or something. But I think it just might be JavaScript.

For one thing, despite JavaScript's inevitable quirks and flaws and warts and hairy boogers and severe body odor, it possesses that magical property that you can get stuff done really fast with it. Well, if you can find any halfway decent tools and libraries for it, that is. Which you can't, not without effort. But the situation is improving. Slow and steady wins the race and all. JavaScript is definitely the tortoise to Java's hare.

See, JavaScript has a captive audience. It's one of those languages you just have to know, or you get to miss out on Web programming, and in case you hadn't noticed, thick clients are like Big Hair these days. Most non-technical people I know pretty much live in their browsers, and they only emerge periodically to stare in puzzlement at iTunes or a game or something, and wonder why isn't it in the browser, because everything else useful seems to be. It's where the whole world is. To non-technical people, of course. Which is, like, practically everyone.

We technical folks like to eye browsers with suspicion, and for a good reason. They're not platforms. They're sort of like platforms, but they're missing all this stuff you normally expect from platforms. The DHTML book (which covers pretty much the only semi-reliable intersection of the browser platforms) is, for all its massive size, still just one book, and any platform worth its salt will need a whole shelf.

It turns out if you dig deep into Mozilla (aka Netscape, aka Firefox, aka SeaMonkey, aka SwampMonster, I mean the thing really has way too many farging names already), you'll find that it actually is a relatively full-featured platform. It's not quite as general-purpose as an OS (or Java), but it's certainly big and hairy enough to be making threats in that general direction.

But my God, it's sooooooo ugly. It's got well over a decade of ugly packed in there. "Hello, World" in Mozilla is six or seven files in as many different languages. I kid you not. It's worse than Hello, World was back in the Petzold days of Win32 programming. You have your XUL file and your JavaScript file and your CSS file and your manifest.rdf and your i18n.something and I can't remember what all else. And then you have to build them together (using some other files) to make even more files: a JAR file and an XPI file at a minimum. That's one gnarly-ass introductory program.

Me, I kinda prefer Python's version:
print "Hello, world!"
Color me silly with font="red", but it just seems cleaner to me.

And then when you try to graduate from Hello, World to something that seems like it should be only epsilon more difficult, like, say, "Get me a list of the user's bookmarks", you officially launch off into this eerie XPCOM world where you have to write dozens and dozens of lines of JavaScript code that looks nothing at all like you'd imagine it should, if you closed your eyes and thought to yourself: "I wonder what the JS code for getting bookmarks would look like?"

Look, I'll even show ya:
/**
* Returns a sorted list of bookmark objects. Each object
* has properties name, url, and (optional) kw.
* @return bookmark list: an array of anonymous objects, each
* with "name", "url" and "kw" fields. Sorts the list by name
* if sort is true.
*/

function getBookmarkList(doSort) {
var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].
getService(Components.interfaces.nsIRDFService);

var bmks = rdf.GetDataSource("rdf:bookmarks");
var NC_NS = "http://home.netscape.com/NC-rdf#";
var kwArc = rdf.GetResource(NC_NS + "ShortcutURL");
var urlArc = rdf.GetResource(NC_NS + "URL");
var nameArc = rdf.GetResource(NC_NS + "Name");
var rdfLiteral = Components.interfaces.nsIRDFLiteral;
var e = bmks.GetAllResources();
var items = [];

while(e.hasMoreElements()) {
var r = e.getNext().QueryInterface(
Components.interfaces.nsIRDFResource);
var urlR = bmks.GetTarget(r, urlArc, true);
var kwR = bmks.GetTarget(r, kwArc, true);
var nameR = bmks.GetTarget(r, nameArc, true);
if (!(nameR && urlR)) {
continue;
}
var item = {};
item.name = nameR.QueryInterface(rdfLiteral).Value;
item.url = urlR.QueryInterface(rdfLiteral).Value;
if (kwR) {
item.kw = kwR.QueryInterface(rdfLiteral).Value;
}
items.push(item);
}

if (doSort) {
items.sort(function(a, b) {
return (a.name.upcase() < b.name.upcase()) ? -1 : 1;
});
}
return items;
}

Shouldn't there be a "getBookmarks()" in there somewhere? I mean, what is all that crap?

Admittedly this function does a little extra, what with the sorting, but that's only 5 lines of code, because JavaScript came with verbs included, thank you so much Brendan. And those 5 lines are actually fairly sane; I mean, you can read them and say "hey, that's sorting!" But as the rest of the code, what we seem to have is a serious failure to separate infrastructure from business logic. We're trying to take the patient's temperature here, and they're making us saw the poor guy open and grub around in his intestines looking for the right spot to stick the thermometer. So to speak.

In any case, that's not really JavaScript's fault; it's Firefox's fault. I have trouble keeping them separate in my head sometimes, because I, unlike the rest of the Free World, have the balls not to support Internet Explorer. For my personal stuff, anyway. (Or so I believe at the moment. Time will tell.)

That's what's really holding JavaScript back, you know. And it's holding back CSS, and DOM, and all the other standards. We have this little impasse problem. You know the song and dance: Microsoft didn't want Netscape to be a competing platform, so they built IE and gave it away for free, and for a brief while they even had a better product, so they captured enough market share.

And then... nothing. Oh, sure, they've made a few half-assed attempts to make IE standards-compliant, sort of, but only after making many full-assed attempts to distort those standards to give Microsoft competitive advantages. I've heard that directly from folks working on the relevant teams over there. Microsoft cheerfully shows up at the standards meetings to make damn sure they screw up the APIs for everyone else. You know. Microsoft-style. Sorta like how DirectX was bugly compared to OpenGL. Or Win32 compared to *nix. Or MFC compared to any sane object system (e.g. TurboPascal and TurboC). Or COM compared to CORBA. (I mean, you have to work hard to be worse than CORBA.) Microsoft has always been awful at making APIs, always always always, and I've decided over the years to credit this to malice rather than incompetence. Microsoft isn't incompetent, whatever else they might be. Burdened, yes; incompetent, no.

Why am I talking about them side-by-side with JavaScript? Because the standoff between Microsoft and the Forces of Neutrality (open standards and the like) is the main thing that's holding JavaScript back. Nobody wants to build an amazingly cool website that only works in FireFox/Opera/(insert your favorite reasonably standards-compliant browser here). Because they're focused on the short term, not the long term. It would only take one or two really killer apps for Mozilla to take back the market share from Microsoft. That, or a whole army of pretty good ones. People don't like downloading new stuff (in general), and they also don't like switching browsers. But they'll do it if they know they have to in order to use their favorite app.

Everyone knows all this; not a jot of it is news to anyone, but nobody wants to be the one to make a clean break from IE. It might bankrupt them. Great app, nobody sees it, company goes bust. So the killer apps will have to come from the fringe, the margin, the anarchy projects engineers do on the side — at least at companies where engineers have a little free time for innovation. Excepting only go-for-broke startups, most places can't (or won't) bet the farm on a Firefox-only application. So even though the spec is moving forward, or maybe sideways, DHTML in the real world has been in near-stasis for years.

In any event, the whole MSIE standoff isn't the only thing holding JavaScript back. There are definitely other contributors.

One big problem is that it's JavaScript. Nobody wants to use JavaScript.

I'm serious. It's not that it's a bad language (it's not); it's just not the language they want to use. You know. Them. You. Everyone who has a favorite programming language. Most people only want to use one, their favorite, whatever they're best with, and when they switch to a different one, they're slower. They feel stifled, held back, uncomfortable. That feeling goes away in under a month of immersion in a new language, but most engineers begrudge that time fiercely, probably because they don't realize it's only a month.

So many folks who take a stab at browser programming wind up saying "oh GOSH, why can't I use BLUB, man this really SUCKS!" and then instead of writing their killer web app, they go off and write some lame-ass toolkit that compiles their language into JavaScript, or tries to be a Firefox plugin, or tries to be a Frankensteinian compiled-together monstrosity like Apache and mod_perl was.

The funny thing is, they wouldn't be gaining a damn thing with a new language, except maybe libraries, but even that's somewhat doubtful. The standard library and runtime for any respectable general-purpose programming language are pretty big: definitely too big to expect everyone in the world to download. And that's the problem. You'd have to get everyone to do it. Might as well work on your own browser at that point. Oh, you can bet a bunch of people run off to do that, too, utterly overlooking the fact that nobody will use it even if it's great (like Opera), because it's not the browser they're accustomed to, and it has no killer app.

But if they wrote a killer app... oh, but that would have to be in JavaScript... well, maybe we can come up with a way to write it in XYZ instead! That's right — a bunch of would-be web app programmers are stuck in a vicious circle trying to break into a market that has one of the weirdest monopolies in history: IE (and to a tiny extent, Firefox and Safari: the Dr. Pepper and RC Cola of browsers, respectively) maintains its monopolistic lock not through overt control, but through apathy on the part of users worldwide.

And that apathy extends to the browser makers themselves. Microsoft and Apple have no reason to try to make their browsers competing platforms; quite the opposite in fact. So almost no innovation happens in IE and Safari, compared to the innovation (in Apple's case) or purchase and/or me-tooing of other innovations (in Microsoft's) going on outside the browser groups at those companies.

OK, but what about Firefox? Why don't they, you know, innovate? Well, they're trying, I think, but for what I'm guessing are probably tangled historical reasons — which manifest as the developers often being gridlocked politically — Mozilla lacks what Fred Brooks Jr. calls "conceptual integrity" in his classic "The Mythical Man-Month". [Which, incidentally, remains today the most vitally relevant book on software engineering, over 30 years after it was written.] The Mozilla folks would have to do a lot of serious re-thinking in order to reduce XUL's "Hello, World" down to a few lines of code in a single language. And I'm not convinced that kind of thinking is happening in the Firefox camp right now. It's not that they're not thinking at all; don't get me wrong. They're just not thinking about radical, revolutionary user-level simplifications to the basic framework.

Like, the kind of radical simplification Ruby on Rails introduced for server-side web programming. Yeah, yeah, I know, you hate Ruby because it's not the language you learned at your mother's teat, for God's sake. Despite Ruby's near-perfect Conceptual Integrity Index, you'd sooner quit your job and become a sanitation engineer than spend a day or three just learning the language and being done with it. But whatever your feelings on Ruby, Rails has caused a huge stir, because it took something that everyone assumed had to be ugly now and for all time, and it built layers and scaffolding on top that smoothed over a tremendous amount of that ugliness. Made it almost purty, even.

Rails — now that's the kind of simplification I'm talking about. Screw all the XML minilanguages (XUL, XBL, X*L). Screw the RDF. You need to be able to do everything in JavaScript. JSON is just good enough and parseable enough and language-interoperable enough to replace all of them. For that matter, screw CSS. I don't mean the CSS spec, not the relatively elegant constraint system they have in place; I just mean the CSS syntax, since it's one more language piled onto the heap. The whole selector minilanguage is nifty, but does it really need to be different from XPath? I mean, aren't they both doing path expressions to select things in the DOM? Jeez!

Am I spouting heresy or common sense here? It depends who you're asking. There are a lot of "web developers" in the world. Lots and lots. And they, my friends, are the last thing holding JavaScript back.

Because nobody wants to be a web developer. No self-respecting, rootin'-tootin', core-dump-debugging programmer wants to be one, anyway. That's sissy stuff. That's what most non-web programmers think, whether they use Java or C++ or C# or Perl or Python or Haskell or what-have-you. There's a deep-seated cultural perception problem in our industry about this, and I think it has a lot of root causes.

One cause, and let's be honest here, is that a lot of web developers were self-taught, weaned from text to HTML to onclick="foo.hide()" and onwards to CSS and DOM and more complex JavaScript, and thence on to CGI and PHP and VB and ActiveX and SVG and Flash and the rest of the gigantic mess of barely-interoperable languages we have to work with for web programming, not one of which covers the whole spectrum the way C++ or Java does. You have to mix and match them (always poorly) in order to achieve some effect that usually would have been trivial using a thick-client framework.

So we really have two reasons at play here: one is that web developers mostly taught themselves, which means they're generally not very good at what "real" programmers of course consider "real" programming, so diving into web programming hasn't been considered very glamorous, nor a very good career move. The other is that the field is so littered with new, ugly languages and technologies (again, not one of which is a turn-key solution) that most folks who do try it wind up fleeing.

I mean, I'm all in favor of MVC, but I think Common Sense and its kissing-cousin Conceptual Integrity will both tell you that M, V and C don't need to be three separate languages. And the manifest and build information needn't be a fourth and fifth, respectively. And i18n a sixth. And the XPCOM system services an effective seventh. And the server-side languages Nth through Zth. It just doesn't make any sense.

Which is in no small part why you keep hearing about Ruby on Rails, even though you really just wish it would go away so you don't have to learn it. Rails has the laws of physics (or at least economics) on its side. Rails is like one of those bizarre tunnel diodes, where the electrons on one side of the barrier tunnel to the other side without traveling the distance in between (at least in the classical-mechanics sense of "traveling"). They just sort of appear on the other side, instantaneously, because being on the other side is a lower quantum energy state, and tough shit if you don't like it.

People want Rails to go away because it has Ruby in the name: you can't use it like a library, nooooo, it has to be in some other language, and other languages are bad by axiomatic decree. Programmers are lazy: they've found that the greedy algorithm gets them there with the least energy expenditure most of the time, and switching languages requires much more energy than integrating a new library, no matter how godawfully complex and ultimately useless the library is. Which is why the Java community is thrashing around with like 50 competing frameworks for server side web programming. Oh, and the Python community too. And, um, all of the rest of them too.

Well, if you happen to be doing web programming, Ruby on Rails defies classical language mechanics by actually being a lower energy state. That's right; it's more lazy to learn Rails than it is to try to get your web framework to be that productive, so people are just tunneling over to it like so many electrons.

This phenomenon will happen in the browser space. I can assure you it will. It's an economic certainty. There's money at play here, lots and LOTS of money; every company in the world wants a cool website. Not just a cool website; they want cool apps. Companies are realizing — glacially, yes, belatedly, yes, but inexorably — that most people with computer access in the world today live inside their browser, and they'd prefer not to leave it.

"Everyone in the world" — that's an awful lot of money at stake.

So as soon as "Scheme on Skis" or "JavaScript on Jets" or whatever comes along, that Rails-like radical simplification of the huge ugly Browser Swamp, the game will change almost overnight.

I'm not sure exactly how it'll pan out. Rails is basically a big code generator, a big compiler, in a sense. The "language" is Rails itself — there's precious little actual Ruby in a Rails app, surprisingly enough, although there's tons underneath — and the target platform is the Browser Swamp. It's not a seamless abstraction; you still need to know CSS and HTML (at least), and you need to know a fair bit about HTTP and relational databases and web servers and all that crapola you need for "Hello, World" on the web.

But maybe that was the right choice. Maybe if DHH had defined an entire DSL for web programming in pure Ruby, with all the DHTML auto-generated, it wouldn't have been as popular. In the long run, I think the pure-Ruby approach (or pure-anything, as long as it's a single language that supports declarative programming, which rules Java out) is economically superior, because there's less to learn, and more purchase for optimizations, error-checking and the like. But in the short term, meaning today, the hybrid approach seems to be doing well.

The alternative to a Rails-like multi-language hybrid is to do the whole ball of wax in a single language. Lisp and Scheme folks have, of course, warmed to this idea, and they all write macros that generate HTML, which winds up being way cleaner than you might guess. But not many frameworks have taken the approach of generating all the JavaScript. The GWT is one, of course, but you'd have to be a pretty doggurn die-hard Java programmer to go that way. I'm sure it'll improve with time, but the biggest stumbling block, amusingly enough, is that it's not JavaScript. JavaScript is still King in the browser space, and ironically it's like programming to the "bare metal" compared to using a Java-to-JavaScript compiler. So JavaScript what the "real" web programmers prefer to use.

And we've come full circle.

Isn't this great? Me, I'm loving it. Yeah, it's a crap sandwich and we all have to take a bite. But it's also a greenfield opportunity, a land rush, a high-energy state just dying to become a low-energy state. Who's going to solve it? What will the solution look like?

One option I haven't really discussed is the incumbent: maybe the standards committees will eventually evolve cross-browser support into a platform that doesn't drive most programmers into I'll-write-my-own-dammit frenzies. I mean, it's a LOT better than it was in 1997. Look at Google Spreadsheets or Writely or GMail or Google Maps (anyone notice a pattern here?) — would any of these really have been possible in 1997? Heck, I doubt it: they're barely possible today. But they make it pretty obvious which way thick clients are headed, don't they?

Hang on — you're not still a thick-client programmer, are you? Oh dear. You'd better get yourself a DHTML book and an AJAX book, and right-quick. Oh, you're above that client stuff, you're a server-side programmer then, are you? Bully for you! I don't blame you. I hid there for many years myself; server-side is a haven of sanity, isn't it? But I think you'll find that adding web programming to your skills lineup will go a long way; you'll be able to wire up those nifty backends you're writing in ways that real-live people will appreciate. Like, say, your family. And real employers too. They like the web. There's money there. So DHTML/AJAX a great Mixin skill; it complements just about anything else you know how to do.

Anyway, I've pretty much belched out the barest outlines of my browser-ish thoughts for today: just enough for a blog entry, so I'll wrap up.

Ooooh, and it's a Blogger's Block entry! This Blogger's Block series has been great for the ol' creative juices. Just write about whatever you want, no worries, and it all flows nicely.

The only thing that could possibly go wrong is me reading the comments.

What?

I had a realization last night as I was juuuust falling asleep. The realization I had was that I have all my realizations just as I'm falling asleep. Or just as I'm waking up. There's something magical about that time, and I think I know what it is.

I think you (or at least "I", but I think maybe "we") are highly creative when we're nearly asleep because all the pressure's off. You can't go to sleep if you're under a lot of pressure — not easily, at any rate. Nobody can follow us into our dreams, so we go there alone, and when you're alone with yourself, you can be yourself. We've put shields in place to prevent us from saying or doing stupid things in public, and those shields come down when we're asleep.

That's why you always have those amazing dreams that you want to write down in the morning, the ones that would make a great movie screenplay or spy-thriller novel. Your mind is in a creative frenzy, and you mostly suppress it during the day.

Well, you can't say stuff in a public blog without getting some criticism, which is why most employees at most companies (that's you, an all likelihood) are reticent to try it. There's not much to be gained, and a lot of potential downside. People have been fired over their blogs, for instance, although those are relatively rare cases, and the blogger in question is almost invariably a jackass. For most bloggers it's more subtle. If you're speaking in a public forum and sufficient people appear to be listening, then it's hard not to be perceived as a spokesperson (of sorts) for the company. Scoble's the canonical example, but you can easily find others who fit the profile.

If your company has an ad-hoc, out-of-band, quasi-pseudo-spokesperson on the loose, the person is a risk. Sort of. I mean, it's lose-lose. If the person is cheerleading, well, nobody likes a fanboy. (It's a truly ugly word, isn't it? "Fanboy" is the new F-word.) If it's badmouthing, well, that's not too cool either. But hey, one person's fawning is another person's badmouthing, right? There are two sides to any interesting opinion (otherwise it's not going to be very interesting), so anything a blogger says in public is going to be criticized by some percentage of the readers. So no matter what, the company the blogger works for is taking some indirect heat, and it's risky to hope that the positive side of the blog, if any, will make up for it.

Well then. That's why bloggers like me always have to give you the following disclaimer: I don't speak for Google. Not even a little bit. For the reasons I've outlined above, the best I can really hope for is that they choose to look the other way when I blog. It's the best any blogger can hope for. It's what I'm hoping for.

I'm a frigging Google fanboy, though; that's going to be really hard to hide, so I'll just be honest with you. F-word, I hate that F-word. But it fits in this case. I'll try my best to be objective. Google's a terrible place to be when you're on a diet, for instance.

In any case, my sleepy realization has effectively solved my Blogger's Block problem. I couldn't write because I was too worried about what other people (i.e., you) would think. Yeah, I care about you too much. You! I think that gradually piled on resistance, and it was getting harder and harder for me to write past it. You can see it pretty clearly in the "Clothes for the Soul" post, which I don't care all that much about — it was just a thought-exercise, after all, and was supposed to be fun. But then I got all defensive at the end, which made commenters all defensive, and I made a mess, all because I was trying so hard to avoid criticism.

So the solution is simple: I won't read the comments.

ZZZZZzzzzzzzooooooooompf — and just like that, in a flash, I'm alone with my thoughts. Amazing. Really. I can feel a chill; it's like I didn't know I was in a haunted house until all the ghosts left, all at once.

La la la, La la la, I can say whatever I want, and I needn't know 'til I'm dead what anyone else thought of it. Nobody mentions my blog at work, by and large, since it's awkward to do so. (I assume this is the case for all bloggers — we don't have any cultural conventions for it, so it's like the third time you pass someone in the hall and you both carefully avoid eye contact.) So if I don't read the comments, then I really am alone with my thoughts.

That's how I was able to write some of my more interesting things back at Amazon; initially nobody read my blog, so I was writing for an audience of at most about 5 people, and then only if I pestered them to read it, which I almost never did.

So no reading comments. My blogs may not be any better for it, but I'm sure I'll be much happier. Oh, you can bet I'll be tempted. Maybe I won't be able to resist. Must... *pant* ... resiiiiist... augh! But I think I'll be able to hold out. Why? Because for this entire entry I've felt like I'm just about to fall asleep. Well, that's because I was; it's been a long day, and I didn't start until 1am, and it's 4:30am now. So yeah. Sleeeep.

But it's a nice feeling. Much nicer than the Russian Roulette of reading the comments on my blogs. "Uh-huh, uh-huh, yep, *BANG* aaaaah!" <blood pressure shoots up to 190/150>. High blood pressure is a recipe for some pretty questionable blogging, I think, and it's not too good for your health, either.

So! Tell me what you th... er, tell others what you think! I'll be hiding under my desk, hoping the monsters go away.

And learn DHTML! You won't like it, but you'll be glad all the same.

'night.




p.s. some light reading:

Minggu, 17 September 2006

Blogger's Block #2: Anime for the Nonplussed

Part 2 of an N-part series of short posts intended to clear out my bloggestive tract. Hold your nose! Especially since this is, you know, Number Two.
I discovered much to my surprise, almost exactly 1 year ago, that I like Anime: Japanese animation. What started it was watching Miyazaki's Spirited Away — I think just about everyone's watched that by now, right? Anime for the unwashed U.S. masses? It made mainstream here, more or less, with the Oscar for Best Animated Feature. My wife and I were tired of the same old Hollywood crap, tired of waiting for those maybe two or three really good movies a year, so we gave it a shot.

After we watched Spirited Away (which is, of course, fantastic, hence the Oscar), we went looking for more stuff like it. First we watched some of the other Miyazaki movies, like Princess Mononoke and Kiki's Delivery Service. All Miyazaki films are worth watching, though, so that wasn't exactly adventurous of us.

Then we went to Suncoast in the mall and met this girl, an American girl, 19 years old, who loved Anime but was too poor to watch most of it. Think of that! We were initially astonished that Anime can make you poor, but now some 150 DVDs later, we're starting to re-think that position. On the plus side, it's nice to own them, and I've never been much of a digital pirate. I'm not a rabid anti-pirate; I've just never been part of the "in" crowd that knows how to steal the stuff, I guess. But it's hard to be against it when half the free world is doing it.

It's a bit of a tangent, but Jeff Bezos explained to us Amazonians, some years back, that being the world's biggest retailer of books, music and video was going to get the company buried, and precisely because of digital piracy. I mean, nobody buys CDs in China, and China is soon going to be half the free world if they're not already. Well, they're far from free, alas, but they're big, and they're pirate-y. Books, music and video can all be digitized, so they'll never be safe against piracy. That's why Amazon branched out and started selling appliances and clothes and sports equipment and everything else under the sun: because not doing it would eventually mean their doom. Or at least that's what I got out of his talk that day. Who knows what he was really trying to say. Jeff, sorry if I've misrepresented you.

Anyway, I still buy CDs (I'm such a lamer), and I still buy books and DVDs too. And I can tell you this much: DVDs are frigging expensive when you get hooked on Anime series. It's nowhere near how much I was spending on my golf habit, or even my snowboarding habit, but it's right up there. Rental places in the Seattle area don't usually have a very good Anime selection, so I wind up buying experimentally.

Well, this girl at Suncoast, I forget her name, Ashley or Lauren or some such trendy 19-year-old name, we were chatting with her and we asked her for a recommendation. "What genres do you like?" is always the first question an Anime fan will ask you, because there are in fact many genres, as many as there are genres in US video. Anime seems to be the dominant form of entertainment in Japan, as far as I can tell from a distance. So if you like one kind of Anime, it's no guarantee that you'll like another.

We didn't know what genres we like. They have genres? Isn't it just like, cartoons, like Scooby-Doo and Speed Racer? All we'd seen were some Miyazaki flicks, and we liked those well enough.

So she gave us her first recommendation, and I can tell you this much: that girl cost us thousands of dollars over the next 18 months. If she had recommended something that was total crap (and I can assure you, there's a LOT of total crap to be found in Anime, just like with other movies), then we might have quickly and permanently lost interest.

But she told us she'd been watching this relatively little-known Anime series called Twelve Kingdoms, and even though she was only on the 3rd or 4th disc, she thought we might like it.

Well, she picked a winner. Turns out this series (45 episodes in all) is pretty consistently rated in the Top Ten Animes of all time by actual Anime fans. Most Anime is based on Manga, which are sort of like Japanese comic books. Twelve Kingdoms is unusual in that it's based on a series of epic Japanese novels, basically high fantasy literature.

Ashley (I think it was Ashley) warned us that the main character, Yoko Nakajima, is "a little bit whiny" at first, but that she gets better as the series progresses. Again, that small tidbit contributed to our multi-thousand-dollar spending habit, because Yoko is in fact the most pathetically insecure, whiny, annoying high-school brat you've ever laid ears on, and if it hadn't been for Ashley's warning, Yoko would have killed Linh and I stone-cold dead within the first three episodes, if we'd even made it that far.

But we persevered, night after night, and by the 2nd DVD were were thinking "well, this might at least hold our attention for a while". By the 5th DVD we couldn't talk about anything else. By the 9th we were actually coming out of the closet and telling our baffled family and friends that we had been watching this Japanese cartoon, and by the end of the series, we started dragging our friends home to watch it with us. Again. We've watched it like 4 or 5 times now.

You know how little kids at a certain age like to watch the same movie over and over and over again, for up to a year, and child psychologists say that each time they see it they're seeing it from a new perspective? Well, 12 Kingdoms was like that for us. There's so much for a Westerner to take in. We missed a lot of it the first time around. It took at least 3 or 4 viewings before the patterns started taking shape in our minds. And yeah, we were watching the English-dubbed version. Mostly. On the 4th viewing we watched it all in Japanese, and it was like seeing it again for the first time.

Purists will tell you that you should always watch the subtitled Japanese. But we've kinda grown used to the English voice actors. The studios use the same people, the same maybe 40 or 50 actors (of which maybe 10 to 20 are instantly recognizable) for every Anime series bound for the U.S. It's just a thing with us. We like to hear Blondie (the En-Ki Ki-Rin from 12 Kingdoms), or the King of En, or Klaus and Lavie, or Alex Row. We hear their voices coming back in each series and we've come to love them all. But YOU, you should watch the subtitled versions, before you're tainted like us.

After a month or two, we ran back to a surprised Ashley and begged her for another recommendation. This was a big deal for her; we were actual paying customers who could afford to buy Anime, and we respected her opinion greatly so far. What to recommend next?

She pondered. She hemmed and hawed a bit. Then she told us: "Well, I guess you could watch Last Exile. I mean, everyone loves Last Exile. Young people, old people...

She sorta tailed off there at the end. I think Linh thought she meant, you know, senior citizens, but that wasn't what she meant at all. AT. ALL. She meant US. Us OLD PEOPLE. It felt like the first time some teenager called me "Sir" (or the first time someone on the 'net called me "Mr. Yegge") — I had to look behind me to see who she was talking to.

But even though I knew damn well who she was referring to, I hardly noticed because I was so excited. We were both excited: a new series to watch, by the famous recommender of 12 Kingdoms!

Well, the rest is history. If 12 Kingdoms hadn't clinched the deal, Last Exile certainly would have. We looooooooooove Last Exile. There's no Anime better than that. Some are as good, almost, maybe, but I don't think there's anything better. We have the posters, we have the plush toys. We went through a Last Exile phase of our lives that lasted at least two months, one of those phases that generates nostalgia for a lifetime. Linh and I decided at one point that we were going to name our kids Klaus and Lavie after the two main characters, and we were dead serious for at least a week, if I'm not mistaken.

Last. Exile.

It still brings chills, a tear to the eye, just to think of it. Even if you're not planning on watching it, you should spend a few minutes and check out the Official Site, if you have Flash and some speakers. It's one of those rare Flash intros you don't want to skip, and if you play with the menu, you can read a little about the characters, storyline, etc.

I'm so jealous of you. You haven't watched it. What I wouldn't give to erase it from my brain so I can see it again for the first time.

Once again we ran back to Ashley, and I don't remember what her third recommendation was. She gave us a whole list, I think. She was running out of ideas because she was too poor to keep up with all the recent series.

So we've forged out on our own, and we've been working our way through many series and movies. Lots. Tons. And sometimes we go back and watch our favorites again.

I've learned to be really careful, because most Anime is either crap (i.e. it's a genre that appeals to us, but it's written and/or executed incredibly poorly), or it's genres that don't appeal to us. Like Mecha. I'm just not into the giant robot suits. I liked that scene in Aliens where Sigourney Weaver fights the Alien Queen in a big mech suit, but that's about the extent of it. And a surprising percentage of all Anime, at least 25% I'd wager, appears to be mecha-oriented.

It's hard to find reliable reviewers, since 10-year-olds are just as likely to post their reviews, and you can't tell them apart from 40-year-olds who never learned their native tongue. But we've found a few indicators. Whenever some Anime-store clerk half-disparagingly tells us a series is "a thinker", we know we'll probably like it. If a bunch of reviewers say it was boring and they didn't understand half of it, we go check it out. Studios make Anime for all ages, from 3 years old to 83, and there's usually nothing apparent on the packaging that distinguishes one from the other.

So after much trial and error, I've put together a Top 10 list of my favorite Anime series (and movies). I tend to like the series better, since you can get more immersed, and I've deliberately left out the Miyazaki flicks because they're all pure genius and they'd take up the whole Top 10 if I let them in.

Keep in mind that I haven't watched a lot of the classics; e.g. I haven't watched Cowboy Bebop (*gasp*). There's a lot of great Anime out there that I've yet to discover. That's actually a good thing, as far as I'm concerned. But I've watched a fair bit now, and I think my Top 10 list will have at least a few titles in it that you'd get a kick out of.

Oh, and I wouldn't necessarily watch them in this order, if you're seriously thinking of checking them out. If you're into action and/or horror-type stuff, I'd start with Vampire Hunter D: Bloodlust. It's just one movie, a sequel. If you like it, go watch the original Vampire Hunter D (from 1985).

Anyway, here goes:


Haibane Renmei: my all-time favorite. It's in my wife's top 4 or 5, but it really got me. It's a "thinker". Different from all other Anime out there; it's in a class and genre of its own. It's short: only four DVDs. Strong spiritual undertones non-specific to any religion, although there's some definite Buddhist symbolism. A masterpiece.




Last Exile: unquestionably a landmark in Japanese Animation. Amazing animation (mixed CGI and hand-drawn), amazing soundtrack, gripping epic storyline, unforgettable characters. And, like Haibane, it's unique, which really throws many of the reviewers, since it goes off in unexpected directions pretty often. I'd just skip the reviews and watch it.




Fullmetal Alchemist: one of the top-rated Anime series of all time, and argued by many critics as the greatest ever. My wife and I both like it a lot. We're not finished with the series, though; it's still in the process of being released to the U.S. We've made it up through disc 9, and I think they're up to 12 or 13 so far. Long series -- not sure how long it is, exactly. But it's pretty amazing work: great story, great characters, nice animation, great soundtrack. All-around worth watching.




12 Kingdoms: our first big series, and still one of our all-time favorites. It's a total of 45 episodes, and they were planning on doing something like 60, so it leaves a few story arcs unfinished, including one cliffhanger that will drive you nuts. Follows a very clichéd storyline (for Anime): a high school girl is whisked off to another world where she finds out she's royalty. Serious: this happens in about every 3rd Anime series. But Twelve Kingdoms is the gold standard for this kind of storyline, and it takes on increasingly epic proportions as it progresses. It's a must-see.




Vampire Hunter D: Bloodlust: a neat movie. Lots of action, lots of vampire slaying, and a nice love story in it to get a girl to watch it with you. Heh. My wife loved it too, and yes, more for the love story than for the monster-slaying. It'll have you hooked within 10 minutes. Give it a try! If you like it, be sure to check out the original Vampire Hunter D movie, from 15 years prior, which has older animation but an equally excellent story.




Scrapped Princess: this one just finished being released to the U.S. It's a slightly bizarre storyline, but has everything I look for in escapist fantasy: memorable and occasionally cute characters, drama and humor, some great fight scenes, a sweeping story arc, and good animation. We couldn't help liking it, and we'll likely watch it again soon.




Witch Hunter Robin: another favorite. This one is, regrettably, a bit slow (and strangely episodic) in the first ten episodes or so. It's sort of a mix of a bunch of TV shows I've never seen: CSI, Buffy, and X-Files, maybe. I've never seen a single episode of any of them, but that's what I'd compare it to. However, about halfway through the (6-disc?) series, it changes completely, and it's gripping all the way to its rather disturbing finish. Linh and I both really enjoyed it, even if she had to sleep through a few of the plot-development episodes.




Wolf's Rain: I have to recommend this even though we didn't finish watching it. It was just getting too depressing. Those poor wolves. It's definitely a story of hardship, and it doesn't get easier to watch as it goes. But the weird thing is that it's stayed with me. I still think about it often. I suppose that's a hallmark of great art? I'm 100% sure I'll go back and finish it within the year, because it's been nagging at me. It was a great story with great characters, and just because it wasn't easy to watch doesn't lessen its greatness. It's definitely in my Top 10.




Gunslinger Girl: This was only 3 discs, 13 episodes. A little masterpiece, no question. It was funny and over-the-top as all hell at first, with some La Femme Nikita influences, but pretty soon it's clear that it's more of a psychological/emotional piece. The violence and the setting are totally secondary to the storyline, which is about these little cyborg girls trying to figure out if they're human or not. Beautiful ending. Lovely animation. Well worth watching.




Gankutsuou: The Count of Monte Cristo (adaptation). I'm going out on a limb with #10 here, because we just bought the first DVD and watched it this week. Haven't seen the rest; there are 6 discs, 24 episodes total. But the first four episodes already have us thinking it might be one of the greats. Same studio that did Last Exile. This is a newer series that aired on Japanese TV in from 6/2004 through 3/2005. Man, I'm jealous of Japanese people. Their television just blows ours away. Anyway, if you're adventurous, you can watch it at the same time as us! So far we haven't been a bit disappointed. It's lavish and mysterious, and we know we're in pretty good hands.



You might ask what Anime I've watched that I wouldn't put in my Top 10. Well, Vampire Hunter D is the only movie (2 movies, actually) that made my list, because movies generally just aren't as immersive as the TV series.

As for series, I've watched the first N episodes of a bunch of series, including Burst Angel (looks OK), Kuo Kara Maoh (lame), .hack sign (lame), Gilgamesh (pretty interesting so far), Otogi Zoshi (ok), Hellsing (pretty good so far), and several others I've rented but didn't get far into.

As for movies, I've seen Metropolis (loved it), Perfect Blue (loved it), loved all the Miyazaki I've ever seen (so far: Spirited Away, Mononoke Hime, Howl's Moving Castle, Kiki's Delivery Service, Castle in the Sky, Nausicaa: Valley of the Wind, Porco Rosso, My Neighbor Totoro, and the Cat Returns), seen Ghost in the Shell (good), Grave of the Fireflies (a masterpiece, but very very sad), Blood: the Last Vampire (great, almost made the list), Samurai X (liked the first one but not the sequel), and a bunch of others I'm forgetting.

I have a bunch of series on my to-watch list, including Cowboy Bebop, Rayearth, Fushigi Yuugi, Steamboy, Samurai 7, Fruits Basket, and at least half-dozen others. We're talking thousands of bucks, so no rush at the moment. And I don't know if I'm going to like any of them. It seems to be hit-or-miss.

Anyway, if I were going to summarize my learnings from the past year, I'd tell you this:

  1. Some Anime is fantastic. You just have to sift a bit and find what you like, but there's almost guaranteed to be something you'll love.

  2. Sturgeon's Revelation applies to Anime too. 90% of it is crap.

  3. I've been missing out, all these years.

If you have recommendations for me, I'd love to hear them!

Blogger's Block #1: Joelprah

Part 1 of an N-part series of short posts intended to clear out my bloggestive tract. Hold your nose!

Ever since my last entry I've had blogger's block. Haven't been able to write a thing. I've tried, but haven't made any progress on anything.

Partly it's because I hinted I'd be writing about a controversial technical topic next. I was going to, but I can't seem to bring myself to talk about it. I've tried exactly umpteen approaches, many of them over half finished. None of them quite hit the mark. You make a promise like that, and I think you'll find it hard to keep. I know I have.

It's also partly because I was finishing up a long-ish project at work, and then I went on a much-needed vacation for 2 weeks. Of course I just stayed at home and worked on a new Ruby on Rails site, which might not sound like much of a vacation to you, but if you've been working with the web technologies I've been working with lately... let's just say RoR is like having a pillow surgically removed from your face. I can breathe again.

Incidentally, my game-and-blog server has been down for a week, since I decided to shepherd it into our current century by upgrading from RedHat 7.3 to the latest Ubuntu. Wow. Ubuntu rocks. Everything just works, including apt-getting a smp kernel and rebooting. So now I can drag the server back to the dismal concrete bunker in downtown Seattle where my ISP hosts the thing.

I moved the old Drunken Blog Rants, though. They're now all hosted in
pages.google.com. They were (inexplicably, as always) getting a lot of traffic, and it was really eating into the CPU and bandwidth for my game, so I've moved them to a place where they'll presumably have better latency and availability. When my old server comes back online, I've just told Apache to do permanent redirects for the 50-odd articles.

Putting them in Google Pages was pretty easy. I eventually wound up getting to where I could port one in about 90 seconds, so the whole exercise only took a few hours. It really was the perfect place to host them: they're mostly static content, and I just needed a permanent place for them to live. Google has a way of creating things I actually use. Blogger's just good enough. The spreadsheet is just good enough (I use it for my diet log). Google Pages is just good enough. And so on. I'm living more and more in my browser now because of Google.

I work there now, you know. A teeny fish in a big ocean of brilliant people. I'll blog about that a bit in one of my upcoming bloguettes, I think.

So where was I? Oh yeah. Blogger's block. It wasn't just the Mystery Tech Topic that's had me blocked, nor was it entirely the vacation. There are some other weird things going on, and I'm going to have to learn to deal with them or I'll never be able to write anything again.

First, my blog got really popular after Joel Spolsky linked to it. That guy is like the Oprah Winfrey of tech blogging. Yeah, I watch Oprah. I can't help it. When my wife's watching it, I try to ignore it as best I can. But then I sneak a peek, or I laugh at one of her jokes or one of her guests' jokes, and then I'm hooked until it's over. My wife Linh says Oprah is the most powerful woman in the U.S. Linh says that if Oprah told every woman in the United States to go jump off a cliff, they'd do it. Oprah, don't do it!

Well, if Joel told all the techies to go jump off a cliff, I'm sure only a handful of them would do it, probably just the parkour wannabes. But when he tells them all to go read my blog... well, I used to get a max of 8,000 to 9,000 hits a day. After Joel linked to me a couple of times, about 70,000 people came and peered at my blog, most of them newcomers.

After your blog gets that popular, even for a little while, you'd better grow a thick skin fast. I've seen people praise Joel and bash on Joel (more of the former, generally), and I've been able to read both sides with interest but without emotion. Just try doing the no-emotion thing when they're talking about YOU.

I mean 70,000 people is like a stadium-full. Imagine all of them glaring at you. Imagine them wanting to lynch you! Some of them did!

So I'd been planning to write an entry once a week, even a small one, and thanks to the Mystery Topic and Oprah-Joel and my work project and my vacation and whatnot, I haven't posted in over a month.

To help me overcome this block-thing, I'm just going to post small stuff for a while. It's the #1 rule of blogging, you know: when in doubt, spew it out. If you say something incredibly stupid and insensitive, no big deal, everyone will just despise you.

D'oh.

Well, we'll see how it goes. Maybe writing short articles will help. I have a whole bunch of things queued up that I'd like to write about. Maybe just writing about them will clear this whole blog-constipation problem up, and I can get back to pooping out entries with my usual, um, ah... my metaphor has stretched to the breaking point here... with my usual "aplomb". Ahem.

If that fails, I might just start writing under a pen name. Heck, my blogs would probably be a lot better for it, and more frequent to boot.

This is a hard problem. We'll see how it goes!

Senin, 14 Agustus 2006

Clothes for the Soul

I un-published this for a few days because I was so bummed that almost nobody appeared to understand any of the key ideas I'm trying to get across. I've lost sleep over it. Not only did people not understand the main points -- for instance, that notions of "race" and "gender" are going to be obsolete in 100 to 200 years, hence racism and sexism will be roughly equivalent to pants-ism and shirts-ism -- but they didn't understand the meta-point, either: that our current ideas about the world and about ourselves can make it horribly hard to contemplate new ones, technical or not. But I figure, screw it. My blog is already controversial; this won't make it any worse. Don't read this entry if you're a little squeamish. And next time I promise to be both funny and on-topic technically.



There's an idea that's gradually taking root in the United States. It'll take about another generation; that's how long this kind of idea takes to permeate. It's already much further along in many other countries, including Brazil, China and Korea, and others.

The idea is simple enough: your body is no longer a prison for your soul. It's become more like a house, one that you can decorate to your tastes. In the fullness of time it may even become more like clothes for your soul, and you'll change it daily.

It's interesting that this idea is having so much trouble in the US. That's not to say, of course, that the US is particularly progressive. We're behind most of the civilized world in cell phone infrastructure, and we never did manage to adopt the metric system (unless you define "adopt" as "shoot km/h signs down with high-powered rifles", in which case: adoption successful.) And we love sports in which an actual ball is in play for under 10 minutes in a 3-hour game. But Americans are as vain as anyone else, so it's strange that we haven't warmed to the idea of customizable bodies.

If you think idly about what the distant future will be like, assuming you don't take the apocalyptic view, then you might envision everyone in the future as being healthy, beautiful, and long-lived. That's the way it is in all the sci-fi movies: take your pick, from Logan's Run to Gattaca. It's not much of a mental leap, though, since from what we know of the Middle Ages, people were comparatively unhealthy, ugly, and short-lived. (By "ugly", I mean that people were more commonly disfigured from diseases or other misfortunes.) If you extrapolate a few hundred years into the future, it's easy to predict improved health and improved looks.

So we're in a strange limbo today, because making changes to your body isn't quite yet socially acceptable, but people assume that it will be acceptable in the future.

You probably think I'm overlooking the plastic surgery craze. Well then: if a 22-year old girl gets a nose job, and she has to wear a bandage for a couple weeks, does she tell everyone she got a nose job? Nope. She fell down some stairs, or maybe had a split septum. If people speculate that she got her nose redone, then she has to deny it, or say it was an accidental by-product of the surgery.

So yeah, there's a plastic surgery craze, sort of. But most people in the US (even in Southern California) aren't comfortable admitting it or talking about it. Instead they have to lie about it.

Let's take stock: what cosmetic changes are acceptable these days?

Tatoos and piercings have gradually become acceptable to everyone except the parents of the person in question. Plus it's hard to lie about them and say you accidentally shoved a steel bolt through your lip and then sat naked on an inverted permanent-ink design.

Anyone who's not going gray is allowed to color their hair pretty much any color they want without exciting much comment. A woman can color her hair to cover up gray. It's less acceptable for a man to do this, but he can more or less still get away with it. Wigs and toupes, however, can't be talked about openly: they're taboo.

Getting a wart or a mole removed: fine. In fact people will be mildly surprised if you don't go to the trouble to remove them. Getting a scar removed or hidden: also definitely OK. In fact, any and all kinds of reconstructive surgery to help recover from injuries or disease are perfectly acceptable, and you can talk about them without shame. Little blue pills, oddly enough, have to be taken in secret.

Getting your legs extended by a doctor who saws through your bones and adds metal extenders: that's one you don't advertise. The procedure is incredibly (and increasingly) popular in China, by all accounts. Heck, in the US you can't even tell people that you wear platform shoes.

Getting your teeth bleached: fine to talk about, though most people won't advertise it. Getting your anus bleached (a popular new procedure discussed to death by such luminaries as Howard Stern and Adam Corolla): not so much. You don't send before/after pictures around to your friends, to the best of my knowledge.

How about a boob job? Unlike nose jobs, breast implants are now more or less acceptable to talk about and, yes, even brag about. Everyone's getting them, and nobody seems to think it's a big deal any more. What about butt implants, which are super popular in Brazil? I don't know anyone in the US who brags about their butt implants, so I'm guessing no, that one's still taboo here.

Cosmetic vaginal surgery is all the rage these days, in case nobody's told you yet. You're practically the last person to find out. The two most popular variants are restoring the hymen, and removing the labia. You can bet your implanted butt that neither of those procedures gets a lot of coffee-table discussion with the relatives and co-workers. I think we can safely add them to the taboo list. Same goes for penile anything, with the possible exception of reduction on account of elephantiasis.

Eyelids: it's very popular in Asia to get your eyes "cut", referring to a procedure that introduces a fold in your upper eyelid, which allegedly looks nicer, albeit at the cost of no longer being able to close your eyes fully when you're asleep. My understanding is that you're not supposed to admit to having had this surgery.

However, changing your eye color via contacts is popular and non-taboo, so presumably if there were a surgical procedure to change the color permanently, it would also not be taboo. Lids, taboo. Color, not taboo. Lash extensions, taboo. Lasik, not taboo. Got it.

Liposuction: shouldn't admit to it. Artificial tanning: fine. Hair implants: don't admit to it. Veneers for your teeth: OK, for the most part. Lip implants: keep 'em secret.

And so on. There's a vast economy around cosmetics and cosmetic surgery, but only a handful of changes are socially acceptable in the US. By "acceptable", I mean they're things you'd talk about openly at work, like going to the dentist to get your teeth cleaned. For most procedures, even the most popular ones, you have to pretend you didn't do it.

In case you hadn't figured it out, I think the whole taboo-ness of cosmetic changes is pretty lame. I think the girl shouldn't have to say she fell down the stairs. People should be able to complement her on her pretty new nose the way you complement someone on a new haircut. Same goes for all the other procedures I've mentioned, although I confess even I might have trouble complimenting someone on their newly-bleached anus.

Generally speaking, though, I think it's pretty obvious to most rational people that the trend is towards having control over how you look, and there's nothing wrong with making yourself look better. If a change makes you happier, then it will almost certainly make the people around you happier too.

And for that matter, changes can make you healthier -- you can already get your eyesight upgraded and your teeth upgraded, so in some sense our bodies are becoming like so much hardware. What if you could get a new set of synthetic lungs, or a new heart, to put you in better shape and increase your life expectancy? It's an open question, since organ replacements aren't readily accessible, and they have to come from other people. But if you could grow them in vats, then would it be socially acceptable to purchase them for yourself? I sure hope so.

But futuristic upgrades aside, the fact remains: most permanent cosmetic modifications still too embarrassing to talk about openly. Why is that? And why is the US in particular so far behind many other countries in how open we are about discussing them?

I don't know. Maybe there isn't a simple answer. But my suspicion is that it's a byproduct of our puritanical heritage in the US. Cosmetic surgery is closely tied to vanity and pride, which are proscribed by any number of popular religions, presumably on the dubious grounds that if God made you ugly, then it was just "meant to be" and you have to live with it.

I'm not sure how many people actually think that way today in the US, in those exact terms -- probably no more than one percent of the population: a few million. But it was likely the majority opinion 100 to 200 years ago, and it takes a long time for a culture to shake off the often ridiculous ideas passed down from our forebears.

However, I also think that cosmetic surgery has the evolutionary advantage: beautiful people get better treatment in the world, whether the world is conscious of it or not. So being beautiful gets you, on average, better jobs, better pay, and a better lifestyle. It pays to be good looking. It seems like this is going to drive cosmetic surgery towards becoming more or less completely acceptable, up to and including changing your apparent race, roughly as fast as these things become technically feasible. Economics will drive it.

In the meantime, feel free to treat yourself. You deserve it. Don't let stupid, old-fashioned social mores (the same ones that keep the mall from being open late on Sunday, the one day when you actually have time to go shop) hold you back. And if you ask me, you shouldn't have to lie if someone asks you about your hair or your nose or your love handles or whatever you changed. Your body is your very own, and it's just clothes for your soul, nothing more. Decorate it however you please, and be proud of your decor.

Why did I write about this?


Believe it or not, today's rant was inspired by technical problems, which is why it's here in this mostly-technical blog. The technical problems (and I won't bore you with details) are the direct result of cultural problems related to the dissemination of ideas.

When you put two people together, they're smarter than one person. Ideas bounce around and settle in faster. A group of two acting in concert can learn faster and respond faster than a single person can: the whole is greater than the sum of the parts. But a group of three or four is back to being about as smart as a single person. A group of ten to twenty people acts about as smart as a lost child, and a group of fifty is only about as smart as a dog. It takes a while to teach a group of fifty people any new tricks. A group of a hundred people? A sheep, of course. A thousand or more? Lemmings. When we're in big groups, we just follow what everyone around us is doing. The bigger the group, the dumber we get.

Unfortunately, this means that getting radical new ideas across can be tricky. Imagine sitting in front of a sheep, trying to explain to it that new ideas have a hard time penetrating big groups of people, especially if they fly in the face of so-called conventional wisdom. I can tell you this much: the sheep will be unimpressed.

One of the many techno-cultural problems I've encountered is going to be the subject of my next blog. A lot of people are going to react very negatively to the ideas I present in this upcoming blog, and oddly enough, their reactions aren't really coming from them as individuals. The strongly negative reactions stem from membership in a group that thinks very differently about this technical subject than I do. But when you're in a group, even a virtual group comprised of people who subscribe to some technical belief, you're only as smart as a sheep. Happens to all of us.

I have various technical ideas in the oven that aren't ready to serve yet. They're in all stages of preparation, from still-mooing to raw to nearly ready to eat. In each case I'm looking for a way to break it to you easy, to explain it in just the right way.

That can be hard, because ideas embody change, and someone is always profiting from the status quo. The profiting isn't always money -- sometimes people simply have their self-image tied up in the status quo. If your idea threatens to change it, they feel you're threatening them directly.

Sometimes the time is just ripe for an idea, and everyone seems to have it at the same time. Other times, it's pretty clear where we're headed, but even so, people aren't willing to let go of some of their cherished old ideas that conflict with the new ones. That's where we're at (in the US, anyway) with plastic surgery. And sometimes an idea is so different and revolutionary that people either don't get it at all, or they're naturally inclined to misunderstand and criticize it. When that happens, you have to attack it from different angles, and try to use tricks like metaphor or analogy to help people make the connections you want them to make.

I think the plastic-surgery problem is well-positioned as a educational tool: it seems pretty obvious (to me, anyway) that a twenty-something girl with a bright future who's unhappy with her nose should be able to get the surgery without having to lie to everyone about falling down the stairs. You'd think everyone would be full of complements about her wonderful new nose, but instead we treat it like the Emperor's clothes. It's sad. And the situation won't change, not quickly enough at any rate, unless some sort of social miracle happens, in which trend-setters with charisma to spare start bragging about their new noses and lips and buttocks... who knows! Stranger things have happened.

Hopefully I've planted a seed with this non-technical article, one that will take root, grow, and flourish into a beautiful tree, which I can then yank a branch from and whack people over the heads with when they choose to resist ideas simply because they fear change.

If that doesn't work, and people still want to lynch me, well, I can always disguise myself with a fake moustache.