Saturday, April 24, 2010

Not "new"



This article from the Facebook engineering team captured a lot of what I've been saying about an emerging new way of building scalable systems for the web. I've been drawing a little table like this:
OldNew
Relational DBsDocument DBs
IDsUUIDs
IndexingMap/Reduce
Function callsMessage passing
Shared, mutable dataImmutable data
It's reductive to say that this new style is (a return to) functional programming, but it's not far from the truth. It feels like we're hitting the limits of OOP, and we're headed towards a world of smaller, less consistent data processing components. Instead of acquiring, for instance, The Object That Represents The Message Queue, we acquire the functions that submit messages and accept message handlers. In so doing, we side-step issues of global state and synchronization.
The poster-children of this new style are functional programming languages like Erlang and scala, But the strictly functional style is very hard for the average programmer -- it's more than just a different way of thinking -- it's a more rigorous, harder way of thinking. I'm sure the OCaml honks out there think that functional programming is easy as falling off a log, but try explaining what a monad is to your average getter/setter writer. Furthermore, some of these approaches just take the immutability thing a little too far. When you're working on a DOM, or working with a message buffer, a little state can go a long way.
msjs uses what I call a "relaxed functional style," to borrow an attitude from the excellent CouchDB project. msjs programs are built as a series of functions and their dependencies, but just as a way of passing messages between the relatively stateful world of the browser DOM on one side, and the world of the JVM on the other. Say what you will about Java, but it's got the best libraries for shared mutable data.
javascript is already a great glue language. It's highly embeddable and nearly ubiquitous, and JSON is quickly becoming the preferred data interchange format. But the best thing about it is that it supports an intuitive functional programming style.

No comments:

Post a Comment