Highlighted

Are there advantages in using CFSCRIPT over CFTAGS?

Avatar
Aug 19, 2008

Copy link to clipboard

Copied

Hi!
My app. has many CFScripts in it and almost can't find anything written in javascript. I read about cfscript and it is not a client side scripting, just like cf tags it goes to the CF server for processing.
So my question is why bother using cfscript? what is the advantages in using cfscript rather than cf tags?

Maybe this application doesn't need to be coded in javascript but still in that case why the previous developer bother using cfscript instead of just use regular cftags. Is there many advantages in using cfscript and I just don't have enough knowledge to know these advabtages?
For me, I found it easier to debug when using cftags because I can cfdump everything?
A code example just because I wanted to.

<cffunction name="dumpMe" output="yes" returntype="void">
<cfargument name="someVar" required="yes" type="any">

<cfdump var="#arguments.someVar#" format="text">
</cffunction>

<cfscript>
anAry = ['one','two','three'];
dumpMe(anAry);
</cfscript>
TOPICS
Getting started

Views

1.2K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Are there advantages in using CFSCRIPT over CFTAGS?

Avatar
Aug 19, 2008

Copy link to clipboard

Copied

Hi!
My app. has many CFScripts in it and almost can't find anything written in javascript. I read about cfscript and it is not a client side scripting, just like cf tags it goes to the CF server for processing.
So my question is why bother using cfscript? what is the advantages in using cfscript rather than cf tags?

Maybe this application doesn't need to be coded in javascript but still in that case why the previous developer bother using cfscript instead of just use regular cftags. Is there many advantages in using cfscript and I just don't have enough knowledge to know these advabtages?
For me, I found it easier to debug when using cftags because I can cfdump everything?
A code example just because I wanted to.

<cffunction name="dumpMe" output="yes" returntype="void">
<cfargument name="someVar" required="yes" type="any">

<cfdump var="#arguments.someVar#" format="text">
</cffunction>

<cfscript>
anAry = ['one','two','three'];
dumpMe(anAry);
</cfscript>
TOPICS
Getting started

Views

1.2K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 19, 2008 0
LEGEND ,
Aug 19, 2008

Copy link to clipboard

Copied

At one time, it was theorized that <cfscript>...</cfscript> code ran a
tiny bit faster then tag code, but that was back in the C++ days before
the current Java versions. Now a days, both forms are compiled into the
same Java byte code so there is no performance differences.

So now it is just personal choice. Some people like the look of
<cfscript>...</cfscript> code. I personally use it when I am doing
heavy processing rather then heavy display outputting. But there is
nothing wrong with using tags for the same thing, and as you note there
are some things that can only be done in tags.

A workaround is that one can easily put the tags inside a user defined
function and call that function from within <cfscript> code.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 19, 2008 0
LEGEND ,
Aug 19, 2008

Copy link to clipboard

Copied

A code example just because I wanted to.

<cffunction name="dumpMe" output="yes" returntype="void">
<cfargument name="someVar" required="yes" type="any">

<cfdump var="#arguments.someVar#" format="text">
</cffunction>

<cfscript>
anAry = ['one','two','three'];
dumpMe(anAry);
</cfscript>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 19, 2008 0
LEGEND ,
Aug 19, 2008

Copy link to clipboard

Copied

easier to type and read. For debugging, you can use the writeoutput function.

Also, if you are doing switch/case stuff, you have a bit more flexibility with cfscript.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 19, 2008 1
Avatar
Aug 19, 2008

Copy link to clipboard

Copied

Ok now I understand. My app was written awhile ago, maybe that was when the cf still in a much older version. Thanks for the debugging techniques.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 19, 2008 0
LEGEND ,
Aug 19, 2008

Copy link to clipboard

Copied

> At one time, it was theorized that <cfscript>...</cfscript> code ran a
> tiny bit faster then tag code, but that was back in the C++ days

CFScript was *substantially* faster in CF5 and earlier. Not "a tiny bit".

> before
> the current Java versions.

It was still measurably and beneficially faster until CFMX7.

There's no difference now, other than non-obvious differences in how
<cfloop> and for() work, and that sort of thing.

To the OP, you might prefer using CFML tags, but I find them ugly,
unnecessarily verbose and completely out of place for most of the code I'm
writing. When mixing HTML and CF code, tags make sense. However we try to
minimise the intermixing of the two, keeping processing separate from
output, in which case tags are not - in my opinion - a sensible construct
to use. I also find ECMA-style code much easier to read that all the <CF>
taggy nonsense CFML requires.

But the difference is a trivial one, and it's very much a personal
preference.

--
Adam

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 19, 2008 1