Friday, 30 May 2014

CFMX7 to CF11: how CFML has progressed

G'day:
In researching my previous article ("Hanging on to outdated knowledge: don't"), I had the displeasure of needing to write some code that would run on ColdFusionMX 7. It caused a lot of swearing, and a lot of "oh FFS, can you not even do that?", but it was cathartic in a way. CFML's really come a long way in between these two versions. And I don't mean pointless shite like <cfpod> and (yeah, I'm gonna...) <cfclient>, but just the language itself.

Here's a test file I knocked together, writing for ColdFusion 9's flavour of CFML. I know I said CF11 in the heading, but I was partially hamstrung by a requirement to have the code run on CF9. CF9 to CF10 is another thing (and then CF10 to 11 too; before one starts thinking about where Railo is taking the language).

Hanging on to outdated knowledge: don't

G'day:

Updated 2024-08-30

Reworded to avoid my misuse of the word "singleton" which I was using to mean "an object that is created once and reused", which is not a singleton. A singleton is about implementation, not usage. This was pointed out to me by John Whish of the CFML community, during a conversation we were having about misuse of that term. And in the spirit of not holding on to outdated knowledge: seems to be an appropriate update to make!

This has taken me a few weeks to sort out - I started on it well before CF.Objective() - but I think I've finally stared at log files for long enough to come up with my conclusion.

I'm working with a client's codebase. A lot of it was written a) a long time ago when come CFML coding practices were not as fleshed-out as they are now; b) initially on CFMX7 (which, of course, comes with penalties of its own). Their ColdFusion install has moved on to version 9, but some of their coding practices still languish in mid-last-decade.  Part of this is decision-makers arriving at a conclusion as to how ColdFusion does things based on how it did things in ColdFusionMX, and never re-assessing their position to see if it still had merit. Their position was never re-assessed partly because no-one ever questioned it. It was just the way things were done. Times and personnel have changed, so now questions are being asked. I hasten to add I don't think is at all unusual that this is the case, and often approaches stay static until someone new shows up and starts questioning stuff. We've had this @ work in the past, and I've noted it ("Hungarian Notation").

You might remember a while ago I had a look at one of CFML's favourite tropes: evaluate() is bad not least of all because it's slow ('"evalulate() is really slow". Is it now?'): that trope ends up being mostly bullshit. So one can't just settle in and accept what once might have been true will thereafter always be true.

The trope I'm looking at here is that on CFMX7 performance penalties in creating transient objects were such that they weren't a viable coding construct. The only feasible way of using object instances were as objects stored in the application scope and reused via ColdSpring during application start-up, and using those as services throughout the life of the application. Beans were an inviable notion, so they must not be used.

Object creation in older versions of CF certainly wasn't an efficient process, I agree with that.

Thursday, 22 May 2014

London Railo Group: but wait... there's MoreBox

G'day:
Blimey... not one but two London Railo Group meetings next week. On Friday Pixl8 are hosting Luis, who's gonna be showing off CommandBox, which is a CLI for CFML. As well as that Alex (and/or Dom?) are going to be demoing the revitalised PresideCMS. Details here: "Luis Majano (New Coldbox and CommandBox) , Pixl8 PresideCMS Sneak Peak".

I have to concede I don't have content to manage, so CMSes aren't something that're on my radar, but Alex has shown me bits 'n' pieces of PresideCMS, and I am really really impressed with what he and Dom have done with it. It's a cliche, but it really seems like they've taken CMSes to the next level.

Luis showed me a bit of CommandBox at CF.Objective(), and it looks really bloody excellent. Definitely covering territory that the CFML platforms themselves should already be covering as far as package management and CLI goes.

I really wish I could be at this presentation too, but I'll be over in Ireland seeing my boy, and that's a lot more fun than CFML stuff. Sorry guys ;-)

But I urge you to sign up for this meeting as well (as the Railo one on Tues: "London Railo Group: Gert's over").

Righto.

--
Adam

London Railo Group: Gert's over

G'day:
A very quick news announcement. There's a London Railo Group meeting next Tues (May 27), at Pixl8. Gert from Railo is going to be there, and he will be doing his "Railo 5.0 and Beyond" presentation from CF.Objective().

CFML: Regex to the rescue again

G'day:
Once again (prev: "Regex for simplifying string manipulation logic") I found myself able to slough off a coupla dozen lines of code in a CFLib.org UDF, by using a regex (well: two) in place of a bunch of looping and branching logic.

There's nothing new in this article, but a good real-world demonstration of where regexes can replace logic.


This UDF (titleCaseList()) got on my radar because someone mentioned a bug it had today, and looking at the comments, there was an earlier bug still outstanding. So I decided to quickly fix it. Here's the code for the previous version:

Wednesday, 21 May 2014

Quick & contrived & output=?

G'day:

Update:

The original wording of this was unnecessarily antagonistic towards one of my readers. I have reworded, and I apologise unreservedly for that.

A question came up the other day, regarding why one might specify the output setting on a CFScript-based function. All things being equal: this is seldom necessary, but the behaviour does change slightly if one explicitly sets it to false.

Monday, 19 May 2014

Difference between Railo and ColdFusion regarding annotating CFCs

G'day:
Yeah, I'll write some stuff up about CF.Objective() shortly, but I need to plan that a bit more before I put pen to paper. This is a quick no-brainer (so playing to my strengths ;-).