Sunday, 1 December 2013

CFML: Discussion with a former Java developer

This is an adjunct to my most recent TDD article: "Unit Testing / TDD - passing data to on() and trigger()".

A bloke at the pub walked past my screen and saw my code, and asked me what I was up to. It turns out he was a developer too, working in Java (well: he was mostly doing QA stuff via Selenium these days, but still in Java).

I said to him I worked with ColdFusion, and he was like "oh yeah, I've heard of that. My boss knew something about it. Is it still around?" I've heard other people report this reaction a lot, but I've never really experienced it myself. But now I have.

A while later after the rugby finished and after I'd finished writing the article, we got to talking again, and I gave him the run-down of what ColdFusion / CFML was, and the Allaire / Macromedia / Adobe history was. He was very surprised that Adobe were in the business of selling a programming language, as it didn't seem much of a fit with the rest of their business model. He was also very bloody surprised that anyone would sell a programming language (ie: expect people to part with money for a language), and was gobsmacked that it costs around  €7000. I explained it came with an app server, but this didn't mollify him one bit: he looked at me like I had sprouted a second head.

He wanted to know why anyone would buy it if it ran on the JVM anyhow: why not use Java? I pointed out a lot of languages other than Java use the JVM, and cited that ColdFusion's USP was its ease of use. I cited this as an example:

fileWrite(path, string);

Is all one needs if one wants to write a file. No messing around with file handles and streams and that sort of horseshit. He agreed that sort of ease of use was pretty good. But not thousands of euros worth.

We discussed Railo too, and he figured that sounded more reasonable: a language should be free, and the open source side of things should be applauded too.

We continued talking about code, and I showed him two versions of the same file: one in script, one in tags:

// C.cfc
component {

    variables.myProperty = "";

    public void function setMyProperty(required string myProperty){
        variables.myProperty = arguments.myProperty;

    public string function getMyProperty(){
        return variables.myProperty;

<!--- CViaTags.cfc --->
<cfcomponent output="false">

    <cfset variables.myProperty = "">

    <cffunction access="public" returntype="void" name="setMyProperty" output="false">
        <cfargument required="true" type="string" name="myProperty">    
        <cfset variables.myProperty = arguments.myProperty>

    <cffunction access="public" returntype="string" name="getMyProperty" output="false">
        <cfreturn variables.myProperty>

Looking at the script-based code he could read if fine, and indeed spotted a bug I had in it. He thought the variables scoping was messy, and was also surprised that I was coding without an IDE (I use SublimeText), thinking it was awful he couldn't ust CTRL-CLICK on a method call to go to the class file (sic) the method was defined in. Being surprised I could work that way. He used IntelliJ himself (migrating from Eclipse which he thought was good but too bloated).

When I showed him the tag version he was like "err... what's this?" I explained it was CFML's alternate / original syntax, which was entirely tag-based. The gobsmack`dness returned. He was like "nah... this can't be code... it's configuration for the code you just showed me or something, isn't it? That's XML... it can't... be... code". I assured him it was, and again with the look like I had sprouted a second head.

I explained CFML's history that it started out being entirely tag-based, and the script syntax was a poor, incompletely implemented cousin. And probably most CFML in circulation is written in tags.

He asked how it came to be anyone decided to write a tag-based language, and I mentioned CF's older USP which was it was as easy to use as HTML. To which the reaction was "well that's stupid. HTML is mark-up, and nothing like code". Indeed. I pointed out that historically CFML was conceived before the notion of web applications, and it was all about individual web pages, so most code was mishmashed with mark-up, so the tags make some sense in that context. Yeah, he agreed. But not for things like I was showing him: class files, and in general code which never comes anywhere near mark-up. Again: I can't say I disagree.

Lastly we discussed CFML's OO-ness, and how whilst CFML allows one to write OO code, the language itself remains procedural. EG: arrayLen(myArray), not myArray.length. He figured this was an immense balls-up on the part of Macromedia: fair enough to also have the procedural functionality, but it should also have gone OO in its native code along with the capability to write OO code.

He was impressed one didn't need to "build" a CFML app, instead the code was compiled as it was needed.

Pleasingly he was never completely dismissive of CFML as some sort of archaic joke, which is something I hear a lot. But he was genuinely surprised it still existed and is seeing active development. Adobe (and Railo) are not doing such a hot job of promoting themselves, it seems.

And them we moved onto politics and religion, so I shall spare you the details of that. But I thought the CFML side of the conversation was interesting enough to report back on here.