CF’s “syntactic activation energy”

With all of the talk about Scorpio lately, and with my recent forays into Flex and Apollo, one thing that keeps popping into my brain is what I am going to call the “syntactic activation energy” of programming languages. In chemistry, activation energy is the bare minimum of energy you need to dump into an object before it will do anything interesting. Any less than that minimum, and nothing really happens.

In my head, this isn’t quite the same as the learning curve for a language, as the learning curve is primarily only of concern while you are initially getting the basics of the new language under your belt. The syntactic activation energy is a measure of how much work you have to do on a daily basis to get the language to do anything interesting.

The perfect example for this is object and literal notation, which is getting a serious overhaul in Scorpio:

JavaScriptCFScorpio
var obj = {
    'foo': 'bar',
    'baz': 1,
    'quux': [ 'abc', 123 ]
}
<cfset obj=StructNew()>
<cfset obj.foo = "bar">
<cfset obj.baz = 1>
<cfset obj.quux = ListToArray("abc,123")>
<cfset obj = {
  foo = "bar",
  baz = 1,
  quux = [ "abc", 123 ]
}>

Of course, I’m cheating a bit for simplicity in my CF-classic example there. If that array was any more complex, it would require ArrayNew calls and twice as much code. And, I’m kindof making the assumption that the Scorpio example will work with the nested literals. Here’s hoping. But really, that’s also kindof my point: in the current version of CF you have to resort to hacks to keep your code from inflating into a George R R Martin novel. It’s not that it’s difficult to learn how to do these things in CFML, nor that they are particularly counterintuitive. Just that, like me, CFML has a predilection for verbosity.

Yes, I have blogged about this before.

Don’t get me wrong. I love CF as a product — there are just some rough areas in the language. But that got me thinking: if Adobe came to me tomorrow and asked me the following question, what would I tell them?

We’re going to release a new product: the ColdFusion engine and capabilities (easy queries, easy App/Session/Client management, etc) but you can now code in server-side ActionScript/JavaScript/ECMAScript. You get all the fuzzy wonderfulness of ECMAScript 4, including variable typing, E4X, lots of literals, anonymous and first-class functions, etc. But, we’ve gone in and added bindings for every part of the infrastructure, so there’s nothing you can’t do in this new language. You’d be writing your CFM pages and CFCs in this new language instead of CFML. Interested?

Essentially, it’s cfscript on steroids, instead of the semi-afterthought that it is now.

Or, if you want to look at it from another direction, it would be Adobe’s direct competitor to ASP.NET and JSP. That is, sure CF is now a direct competitor, but because of its tag-based language and the heavy need for Adobe to bolt-on functionality, and it’s non-native OO capabilities, it generally isn’t seen as being on quite the same level. (I’m not here to argue whether or not it is — the point is that there’s a perception issue.) But this new approach to CF would be OO from the start thanks to its ECMAScript roots, and similarly wouldn’t suffer from the “tags are for n00bs” perception.

One immediate plus would be the lower impedance mismatch. That is, switching between CF tags and JavaScript in the same file can be a little jarring. But switching between ECMAScript4 and the subset that is used by browsers today is a no-brainer. Switching tabs to an ActionScript file would similarly not involve much internal rewiring.

But that leads us down another track. If we grant (which you may not) that ripping out the current language engine and replacing it a new one would be beneficial, could we keep the tags? Why not have CFML and MXML meet in the middle?

<cf:query datasource="foo" name="q">...</cf:query>
<ricko:mywidget query="q" />

Sure, you can do things like this right now with custom tags and whatnot. But again, it’s more hackery than how the language was designed to be used.

So …

I’m not really going anywhere in particular with this. It was just a thought that seems to be coming up often lately. Am I reinventing JSP? Maybe. Is it just because I have a sick love for CF and JS? Maybe. But, is it frustrating bumping up against CF’s syntactic activation energy? Definitely.

Published by

Rick Osborne

I am a web geek who has been doing this sort of thing entirely too long. I rant, I muse, I whine. That is, I am not at all atypical for my breed.