It’s a MetaClass fight!


I start every morning the same way. I hang my coat on the back of my chair, pour a cup of coffee in the lunch room, sit down at my workstation and refresh the Nabble Groovy-user section. The Groovy-user section has become my morning paper and it is how I see the world. (There are a couple of other sites I read regularly but Groovy-user is always the first.) These past couple of days there’s been an ongoing thread that I’ve been following between two of the core project developers over Groovy’s MetaClass. I wish I was smart enough to figure out what they were really debating over but these guys are brilliant as they use terms like “soft reference” count and “weak references”. When was the last time you had to deal with soft strong or weak references in your project? If you work predominantly on Pricing, Accounts Receivable, and Order Entry stuff like I do then your chances of encountering these concepts are slim to none. Also I’m still new to the whole M.O.P. thing so a lot of what they’re saying flies over my head. I still follow closely because their debate affects the brilliant idea that I stole from the latter party in the debate. (In reality it is my idea and my code my work and all my credit but Mr. Latter Party would probably say differently.)

What’s the Meta?
I’ll tell you what’s the matter! There’s a huge change to Groovy Meta programming being discussed on the groovy-user list and I want in! I want to have an opinion! I want to take a side! The only thing is, I don’t know what they’re talking about so I have to just sit idly by and trust that the right decision(s) will eventually come out of the discussion. I trust both parties in the discussion. They both sound like they know what they’re talking about. They both seem to have valid points that are clearly in opposition of the other. It seems like one of those things where the war in Iraq is either “half started” or “half finished”. You know how people fight over whether we’re half winning or half humiliated over seas? (Ok, that’s a bad analogy, I know!) What’s important is how it affects us, the Groovy users.

M.O.P.
My favorite Hip-Hop group of all time, M.O.P. referrs to Meta Object Protocol. The debate invovles how us Groovy users would and should interact with Groovy’s Meta plumbing. I’ll explain a little of what I know and don’t know. In normal Java you call a method on an object and the call is dispatched to the intended code using a compile time vtable to match argument and instance types to the correct method signature. With M.O.P. “you” get in the middle of method dispatch. Well not necessarily you, but the runtime engine decides, while the code is executing, which code to execute. The runtime provides APIs, and hooks for you to change which code is exectued and these changes can be made at runtime. That allows you to do all kinds of cool stuff like add methods to an object using user input from a text field, or change a string concatenation operation to an integer summation on the fly. Groovy allows M.O.P. using MetaClass objects. (There, I said something smart! Now I feel a little better.) Here’s where I get lost. The discussion now seems to be about how many MetaClasses are created, who creates them, and how they get cleaned up. There’s also mention about alternate approaches, introducing interfaces for MetaClass and it’s constituents, and other ideas. If any of you readers are smarter than me then I give you the floor (to fall back on when I blast you for trying to be smarter than me). Explain in the rectangular white square below using 150 words or less what the big deal is, if I should revise GSpec, and how I should change it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s