Tuesday 14 May 2013

Improving ColdFusion CFML's OO-ness

This has probably done the rounds before, but it's just put itself back within my sphere of attention, so I thought I'd mention it. It's also a good quick article to write from bed as I desperately try to ditch a cold I picked up in Ireland; before I have to sit on a plane for 9h tomorrow, to get to cf.Objective() (cue: sympathetic violins). I'm buggered if I'm gonna be hamstrung in my networking (read: beer consumption and general revelry) by a bloody sniffle.

Anyway, I just raise an enhancement request (3559652) for ColdFusion, thus:

I think it’d be timely for CFML to retask most of its type-specific functions as object methods. As Railo has done. EG:

keys = myStruct.keyList();
length = myArray.len();
result = myXml.search(xpath);
// etc

At the same time, promote all these methods to be first class, so they can be used as callbacks. Currently if one wants to have a function to - for example - uppercase each element of an array, one cannot simply give ucase() as a callback, one needs to wrap it in a UDF. Which isn’t the end of the world, but it’s just... something that would be nice not to have to do.

I also like how in languages like Javascript "even literals are objects", so one can do this:

"G’day World!".length();

This is not something one would generally do, but it demonstrates an architectural elegance that CFML doesn’t have at the moment.


I think it’s a mis-step in the language to add OO to it for developer-written code, but not embrace OO in the language itself. It leaves CFML being a bit of a mishmash.

I’m not suggesting getting rid of the more procedurally-oriented versions of the functionality, because a lot of ppl will still be coding that way; but this should not prevent CFML additionally moving more towards OO itself.

This might not be an exciting feature for IT Managers (although if they’d probably already expect it to be the case), but for the people who seem to do most of ColdFusion’s marketing - the vocal part of the dev community - this would be a significant feature.
This is always a fairly polarising topic, so I thought I'd throw it out there for discussion. If you think it's a good idea, then please go vote for it & add your 2p. Or if you're not for it, post a comment as to why not. Everyone's opinions are important.

As always, and comments here are also welcome, but if the comment is also relevant to the E/R, filing it with Adobe too would be cool.