Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I like what Adobe has done with CF9 and full scripting syntax support, but IMO the cleanest way to write SQL within your app is within the cfquery tag. You can't do that for a 100% script-based CFC, and you end up having to mixing up string variables or perhaps even going the ORM route. This could be a downside if you like seeing your SQL code colored.
On the flip side, I've heard it argued that all SQL should be within stored procedures, so if you don't plan on writing SQL at the application layer, it's very feasable to write all your business logic using cfscript syntax.
Pre-CF9, the cfscript vs. CFML (tags) is mainly an issue of what you need to be able to do. Between CF5-8, cfscript is a subset of what's available in CFML, so some tags cannot be run accessed using cfscript. Regardless, cfscript is much cleaner to look at and does not generate any output until you use the WriteOutput() function.
Copy link to clipboard
Copied
You can still debug in cfscript, It's just not called "cfdump" there, instead it's a function called "WriteDump" and you can CFOutput with "WriteOutput"
Afaik, these days, there is nothing you can do with cftags that you can't do with CFScript except for maybe custom tags, but you can use modules and everything in CFScript, so probably even then you can still use CFScript for everything.
Imo, it's a lot easier to do code logic in CFScript, Switch, If, Else, functions, etc etc, so I just stay in CFScript pretty much the whole time.
Copy link to clipboard
Copied
I've read all the replies, here. Just adding my two cents.
For me, there are no readability issues between the two. I can read code within CFSCRIPT tags just as well as I can read the HTML-style CFtags.
However, one thing that I do really like about CFSCRIPT - not having to use CFSET when you have a bunch of variables.
This:
myVarA = "foo";
myVarB = "bar";
param name="session.id" default=myVarA & "." & myVarB;
request.dsn = "fubar";
application.pageSize = 10;
is less typing than:
<cfset myVarA = "foo" />
<cfset myVarB = "bar" />
<cfparam name="session.id" default="#myVarA#.#myVarB#" />
<cfset request.dsn = "fubar" />
<cfset application.pageSize = 10 />
Now, five variables isn't a lot. But imagine you're setting 50 variables. Which would you rather do? 🙂
On the flip-side, CFSCRIPT code looks too much like JavaScript. Which, at the surface, isn't a big deal. But then keep in mind - JavaScript (and most other languages) uses zero-indexed arrays; CF uses one-indexed arrays. Maddening when you can't (immediately) figure out why your code keeps throwing errors like "position 6 doesn't exist".
V/r,
^ _ ^