Friday's Foaming Rant: CFScript is silly
Posted by Joe Rinehart at 12:32 PM
44 comments - Categories:
ColdFusion MX | Causing Trouble
I'm looking at an app right now and every line of code that can be in <cfscript> is, in fact, in <cfscript>. I'm aware that some people love it, and I expect some commentors will disagree, but I've just got to say something I've felt for a while (bear in mind that this is just my opinion): CFScript is silly.
Here's why I think this:
1. It's confusing as hell.
If you're a web developer doing ColdFusion apps, it's likely that you jump between ColdFusion and Javascript regularly. ColdFusion is tag-based, and uses its own set of FORTRANish operators. Javascript uses ECMAish styling for both its formatting and its operators.
That's enough for anyone to accidently screw up now and then, so why would I want to use something that's a blend of the two, making me keep three sets of syntax straight in my brian? I've got better things to do with my time.
Heck, add AS3.0 into the mix, and CFScript becomes less of a code style, and more of an obfuscation tool!
2. It's got about one-tenth of what you need for ColdFusion.
"Let's put all of our code into <cfscript> tags, guys!"
"Sure, that'll make us look hardcore! But what if I need a query?"
"It's still top down, so just stop script, run your query, then script again!"
dsn = getDsn();
</cfscript>
<cfquery datasource="#dsn#" name="stuff">
SELECT * FROM leftHandedSwabHandles
</cfquery>
<cfscript>
if (stuff.recordcount) {
statusMessage = "We found stuff!";
} else {
statusMessage = "We didn't find squat!";
}
</cfscript>
Oh boy, that's fun to read. Leads me to...
3. It won't make you hardcore
I don't think using a half-breed of ColdFusion and ECMA is going to make you look like a hardcore programmer. Just having you code look more like C isn't enough to make you a C programmer.
4. Finally, why bother, in the first place?
You can be a perfectly good ColdFusion programmer and never in your life touch CFScript. There's no reason to learn it.
Learning and using CFScript is a lot like reinventing the wheel because you had nothing better to do, but felt like building a wheel that was missing all round parts...
Scott Stroz wrote on 04/14/06 1:04 PM
I can say that I have never written an app that uses even one line of <cfscript>, thogh I have had to work with/debug a few.I agree, I don't like it either.
I undertsnad that there was a time that <cfscript> offered a performance boost, but, if I remember correctly, that advantage went away in CFMX?