I am reposting this from my blog ("ColdFusion 11: <cfclient> in the context of the CFML language, not the tooling") at the suggestion of Adobe support:
I have edited this in places to remove language that will be deemed inappropriate by the censors here. Changes I have made are in [square brackets]. The forums software here has broken some of the styling, but so be it. There is worthwhile discussion in the comments of the article on my blog: perhaps go have a read.
This article could end up being a complete waste of space, as I am operating under more real-world re-interpretation of the raison d'être of
<cfclient>, as described by Ram:
"ColdFusion Splendor has added support for client side CFML" is probably phrased wrong and gave me flash backs to VBScript or CFML running in the client browser.
Maybe this is better verbiage. "ColdFusion Splendor has added support for CFML to generate JS".
Because... there's not such thing as "client-side CFML". That would imply CFML actually running on the client (ie: the browser, or the mobile device, as is the target of
<cfclient> as a concept). This is absolutely not true. I know Ram went on to qualify what he meant there, but the messaging from Adobe on
<cfclient> has been inaccurate. Possibly I think to the point of actual misrepresentation (in the legal sense, I mean).
Why I say this article could be a complete waste of space is that I dunno if this is the intent of
<cfclient>; because, really, the messaging from Adobe as to what
<cfclient> is for is very muddied. In general the narrative about it is bundled-in with various features of ColdFusion Builder 3.0, in regards to mobile application creation and packaging (and debugging, and all sort of stuff that sounds quite nice but I don't care about as I don't use CFB).
<cfclient> has to stand on its own merit in the CFML language, completely decoupled from CFB features. And as far as I can tell, Mike is right: as far as CFML goes,
This of course just sets my alarm klaxons going. Because Adobe are (I choose my words carefully) [not very good] at converting CFML to client-side code. This has been borne out by
<cfclient> is a far more "meta" solution than
<cfpod> were... at least the CFML-to-client-side solution there had a tangible target in mind.
<cfclient> has removed the targets, and is just a tag designed for converting general CFML to general JS. Yikes.
600-odd words in, here's some code. This is the first-ever code I have written using
<cfclient> <cfset msg = "G'day World"> <cfoutput>#message#</cfoutput> </cfclient>
So I'm off to a false start: I admit I'm sitting in the pub and I've had a few pints (probably four, I guess; this is "having some drinks before deciding to actually drink this evening" sort of level for me), and I inadvertently [messed-up] my variable names here. And this did not yield a compile error. The error just fell through to JS, where it did error
If, in contrast, I tried this in CoffeeScript, I'd get this:
coffee> alert msg
ReferenceError: message is not defined
at eval (eval at (http://larryng.github.io/coffeescript-repl/js/main.js:96:26), :1:9)
Important note: I know nothing about CoffeeScript - it seems like a solution to a non-existent problem to me - so I just googled "hello world coffeescript" and REPLed the code on http://larryng.github.io/coffeescript-repl/.
The point is here is that ColdFusion, during the "compile" process should actually notice I am referencing a variable that doesn't exist. I'm OK with this being a runtime error in the normal CFML-compile process, because there could be many moving parts (and other files) involved in the runtime environment, but I don't think this is a valid notion with
<cfclient>? Or maybe it is?
Update:As Ray points out and Aaron agrees with below: I was being unduly harsh here... it's entirely reasonable for variables to be declared in other JS code elsewhere in the response.
Anyway, once I actually write my code properly, I get this:
On the screen. What CF actually sends back in the response is this:
[Blimey]. To output a string variable? Really? That's what you compile my CFML down to?
And [forget] emotive things like "gobsmacked"... if one looks at the size of the response, it's 128kB to represent "G'day World" on the screen. 128kB might not be a great deal these days when it comes to a web page, but when it comes to rendering "G'day world", it's lunacy. And on a mobile phone - which intrinsically might be in an area in which one is paying a premium for data - it's just irresponsible. This is before we get to the point that it seriously should not take 128kB of data to render 11 bytes.
Blimey. To be honest I was gonna try some more tricky CFML and see how it compiled, but I've run out of will to live (and I have to concede the beer is getting the better of me, and my laptop battery is almost dead). I'll continue this, but I will let this article stand or fall on its own merit; something
<cfclient> certainly seems to be unable to do, thusfar.
I'll be back on the case with this tomorrow.