Sunday, January 2, 2011

Kingdom of Nouns ...

The other day I took advantage of a rare couple of hours of peace and decided to catch up on my blog readings, I came across a nice post by Joel Spolsky from the Joel on Software fame on Map/Reduce. The post is probably one of the clearest writing on origin of Map/Reduce and what it does - if you haven't read it I highly recommend it, even if you are a Map/Reduce pro - in the course of explaining Map/Reduce he talks about how thinking in terms of functional languages made inventing Map/Reduce possible and implying that if one only think in term of OO languages where functions (or verbs) are not first class citizens coming up with an abstraction such as map() or reduce() function is tough. He includes a link to another interesting post title "Execution in Kingdom of Nouns" that contends that Java is a kingdom of nouns and verbs are "owned" by nouns. I like this post too, especially the witty narration. However I disagree with conclusion (or implication) that one can not effectively or elegantly model certain class of thoughts and abstraction with a statically typed language like Java.

Look at any natural language, they ALL seems to be kingdom of nouns. Look at how babies start to talk, they almost excursively uses nouns for a while and THEN add verbs to form sentences (or form thoughts). The core example of the post for taking garbage out that I copied here:


get the garbage bag from under the sink
  carry it out to the garage
  dump it in the garbage can
  walk back inside
  wash your hands
  plop back down on the couch
  resume playing your video game (or whatever you were doing) 
 
(italic emphasis is from original post)

 
This example is there to show that a normal function is a sequence of verbs and 
can be easily expressed without needing a "noun", but the noun here is hidden, 
it is the "subject" that is actually doing it. In a function language like JavaScript
the replacement would be the "global" scope, or some form of function that author would
create called "takeOutTheGarbage()" and call it from different "context"s, those context
would be the nouns.
I admit,I am not a language guy, I am more of a modeling guy but i do think that 
type spaces formed around collaborating nouns (subject, objects etc.) are capable of modeling and asbtracting
any concept/thoughts. I do agree that some folks in the "Javaland" overuse classes and have too many
factories and adapters, mediators, visitors etc. but this is more of a "fashion" issue than a basic
OO modeling issue. 
I also agree (and have seen) that functional languages are better for certain tasks
but I wishing for live in a "kingdom of verbs" is a bit extreme in my view, after all 
verbs are all performed by somebody/soemthing unless you prefer to live in the land of anonymous.