Sunday, March 15, 2009

web 3.0 needs a javascript package manager

Javascript has gotten huge with Web 2.0 techniques. Libraries like jQuery, Scriptaculous, etc. etc. have helped redefine the role of Javascript from being a rag-tag script-kiddie language to becoming a viable platform for the web, competing with the likes of Flex and Silverlight. Javascript is getting serious attention from Google (ala V8) as a serious language with serious compiler design. In short, it's a glorious time to be using Javascript on the web.

So while the iron of Javascript infrastructure is hot, I have an idea for the next generation of the web:

the time has come for a javascript package manager.

No, I'm not talking about javascript loaders like jspkg or sprockets (although those are awesome efforts). I'm talking about a real package manager like Debian. Let me describe the growing problem and why I think a package manager might be a good solution.

The Problem:

Different sites require certain versions of scripts to run. Right now, site maintainers do this by downloading a copy of the library to serve from their site. This is fine if the site is simple and self-contained, but if you add several portlets to your site (a couple ad-rotators, some captchas, social site scripts), pretty soon you run the risk of accidentally including several copies of the same library in your page, all from different domains.

This sops up an enormous amount of bandwidth. Rich pages routinely download 1-2 Mb per page load... this is only going to get worse.

The Solution:

What we need is a package manager for Javascript like Debian's APT or Ruby's rubygems. Some way that the page can say "I need so-and-so version of this Javascript library in order to run." Then the browser can manage these javascripts in a secure cache -- if you have already retreived the version required, good. If not, then the browser will get a copy for you. The browser only gets new javascript if the page contains an updated version dependency. Furthermore, if a library depends on another library, the version dependency tree can be managed and sub-libraries can be automatically loaded once and only once.

Because the browser would be taking a more active role in managing scripts for separate domains in the same store, some work along the lines of Chrome needs to be done to make sure that script execution across multiple site clients remains secure and robust. Chrome is already leading the way on this, so I think it's doable.

A robust, integrated package management system for browsers would reduce bandwidth costs and at least double or triple the loading speed of AJAX web applications. That's something everyone would like.

Friday, March 13, 2009

Communism 2.0? More like 0.2 alpha.

Bruce Sterling's post, "Communism 2.0" over at WIRED caught my eye today. He talks about a new resurgence of communist ideas thanks to the global market meltdown -- Marxist philosophers are meeting in London this week with the thesis "from Plato onwards, communism is the only political idea worthy of a philosopher."

When the Soviet Union "fell" down many people thought this meant that Communism utterly failed (according to our vastly simplified propaganda). Well, now that the global market meltdown is laying waste to the economy, many people are saying that Capitalism has utterly failed (according to their vastly simplified propaganda).

This is dangerous talk, and not simply because of "our side" vs. "their side"... it's dangerous because irrational debate of utopia/dystopia is still volatile enough to end millions of lives in this century just like it did in the last century. Capitalism is just as loaded a word as Communism thanks to the Cold War, but if you strip away all the rhetoric and attached meanings, there is a simple fact at the core of Capitalism that is testable and proven:

Capitalism has a means for generating income, not simply dividing it.

Communist theory is oddly silent on the subject of generating income. The idea is that everyone will simply do the right thing. Marx neglected to say anything specific about how his Communist ideal would be attained... the underlying mechanism is left for the reader to "feel" as would a 19th century Romantic. Marx says that in the perfect Communist society, resources are distributed exactly where they need to go and people do exactly the work they need to do since they work for each other.

But how? How does a resource distribution system just magically know how to work? The 20th century answer to this was that an "appointed" leader makes the decisions for you. However the whole period from the 18th to the 20th centuries was about showing the flaw and futility of top-down aristocratic rule. Even when the ruler is kind and "works for the people", it doesn't work. Things change faster than a central authority can react -- if you can't react, you don't adapt -- you die.

Some would argue that matches the evidence of what happened in the USSR and nearly happened in China before Deng Xiaoping's reforms. Or what is still happening in Cuba. There should be little doubt at this point that top-down communism (like any aristocracy) simply does not work. It's not because we didn't try hard enough, or weren't selfless enough.

So, is there another way that Communism might work without being top-down? Something closer to Marx's ideal, rather than some of the transition states he described? Well, think seriously about how that ideal would work... it's a difficult problem to solve.

The only underlying mechanism I can think of is a distributed network of technology and humans that can make their own decisions and adapt locally to changing situations. But this sounds an awful lot like a democracy... there's no one to "enforce" that you do things for someone you don't interact with. And if you follow that idea further, you ask how will resources be optimally distributed in such a network and you come straight back to something that sounds an awful lot like a market driven economy.

But the Communist philosophers haven't gotten unstuck from the 19th century to answer these difficult questions. They are still arguing that you should believe them because of their passions. Until they can describe an underlying mechanism of Communism they are simply promoting unfounded speculation as a socio-economic theory and playing a very dangerous and foolish game with our lives in the process.

This crisis is real. The millions who died in the name of 19th century utopian ideologies were real. It's time to "set aside our childish things" and face these problems rationally or embrace utter destruction as a species.