Coldfusion 9 CFScript enhancement

I'm not exactly sure how I missed Ray Camdens post on the proposed CFScript enhancements for ColdFusion 9 but it's never too late to throw in my own two cents. I think it's awesome!

Perhaps that's a little bit too general of an answer that should be backed up a little.

A Real Langauge

One of the big complaints I get from programming "purists" (read:Java Programmers) is that ColdFusion isn't a real programming language, it's a scripting language and a bad one at that because of the bracketing. Now the whole bracketing thing is a kind of lame argument but I do have to agree just a "little" with them on this one. If it wasn't for the code completion in CFEclipse and the other IDE's I would have gone crazy a lot earlier in my career.

A Sample

From the screenshot that Ray has on his blog of Bolt one can see the following code snippet.

component
{
public void function init(){}
public query function getData(mediaid)
{
var q = new query();
q.setDatasource("cfartgallery");
q.setSQL("select * from art where mediaid = :mediaid:");
q.addParam(name="mediaid",value=arguments.mediaid,CFSQLTYPE="CF_SQL_INT");
return q.execute();
}
}
I know this is all very pre-Alpha stuff but it does look interesting enough so long as we can will be able to add all the initialization params at the start and not have to add all the query arguments as separate lines as shown below.

component
{
public void function init(){}
public query function getData(mediaid)
{
var q = new query();
q.setDatasource("cfartgallery");
q.cachedwithin (createTimeSpan(0,6,0,0));
q.result("myresult");
q.user("mysqluser");
q.password("thepassword");
q.timeout(10);
q.maxrows(100);
q.setSQL("select * from art where mediaid = :mediaid:");
q.addParam(name="mediaid",value=arguments.mediaid,CFSQLTYPE="CF_SQL_INT");
return q.execute();
}
}

A Welcomed Enhancement

Some may not consider the energy that Adobe is investing to enhance CFScript worth it. These are probably the same people who think CFScript should just go away and die a quiet death. I, on the otherhand, welcome any enhancement to CF that may make it easier for other developers to adopt it and see it as a viable alternative to other programming languages.

Whatever Adobe plans to do with CFScript it will be impossible to please everyone.

9 Comments to "Coldfusion 9 CFScript enhancement"- Add Yours
mark's Gravatar Unfortunately it isn't a language feature but just a wrapper around the tag. Same as mail and other CFScript IMPLEMENTED tags. Yes - it is query.cfc and mail.cfc behined the scenes. Sorry dude.
But you'll see when CF9 comes out.
# Posted By mark | 2/5/09 11:32 PM
JAlpino's Gravatar Not sure I follow that last comment, does that mean that there will be cfc wrappers for tags (like cfquery and cfmail) that live in global space or something? I guess I'm not following since I see the statement "new query()" which would imply that its built into the language.
# Posted By JAlpino | 2/5/09 2:27 AM
Peter Zainger's Gravatar Please for the love of all things CF do not enhance CFScript, the implementation of scripting in ColdFusion is severely broken and adding more CFScript enhancements would only add to the fubar that it is.

Every ask yourself why ArrayAppend et all, return true/false rather than return the object you are working with? What am I going to do with a FREAKING boolean success variable? Okay you failed, well then THROW AN ERROR!

Ever write a large CFScript block only to freaking flip out when you have to implement something not supported in in CFScript, If you are nested in logic you are SOL and have to reactor all your script to tags. Sure I can write wrapper functions but then I am including function libraries all over the place, what is the point. If you can't implement CFScript correctly then DON'T give us some half backed implementation that makes me pull my hair out and play in roads.

Keep CF simple, keep the learning curve low, and concentrate on more valuable enhancements. People who advocate for CFScript should just go program in something else, because your desire is just out of envy.

If you must have CFSCRIPT then allow me to code the example above as:

component
{
public void function init(){}
public query function getData(mediaid)
{

return query().setDatasource("cfartgallery").setSQL("select * from art where mediaid = :mediaid:").addParam(name="mediaid",value=arguments.mediaid,CFSQLTYPE="CF_SQL_INT").execute();

}
}


Sorry to rant, but the CF Teams need to be spending time with other functionality rather than chasing something ColdFusion isn't. Let's stay unique.
# Posted By Peter Zainger | 2/5/09 3:02 AM
Gary's Gravatar Peter,

I agree that simply extending cfscript is not quite enough :)

Method chaining is an absolute must have, as well as the ability to add in Hibernate meta information (I am just assuming thats going to be included).

But, and here is my big BUT. CFML is a simple language and should remain so but I see no reason not to provide another way of tapping into the power of CF through cfscript.

if that is to be done it must be done correctly and thoroughly and no half-assed implementation like we have now in cfscript.
# Posted By Gary | 2/5/09 3:12 AM
mark's Gravatar @JAlpino: what's there to follow? It is not a language feature however "new" operator is. So you will be able to do: new my.crappy.CFComponent(); and if you place your CFComponent.cfc in approot you could do new CFComponent(); - new is just addition to createObject("component", ...). "new" operator does not imply that "new query()" is a language feature. It would be if you could do:

- new wddx();
- new ajaxproxy()
- new feed()
- new schedule()

but because there is no CFC wrappers for cfwddx, cfajaxproxy, ... you can't. These constructs:

- new query()
- new mail()

are implemented using query.cfc and mail.cfc available in global CFC path and methods like setDatasource() are just CFC methods.
So in other words - Adobe did nothing that you couldn't do on your own.
# Posted By mark | 2/5/09 4:27 AM
Brian Kotek's Gravatar It's kind of funny that people are wigging out or leaping to conclusions about how or how the script enhancements will be implemented based off a screenshot with 10 lines of code on it. To the people who are upset, I suggest you wait until you have more information before you draw any conclusions.
# Posted By Brian Kotek | 2/9/09 1:11 AM
Russell Brown's Gravatar Personally I'm glad the changes are coming; however I think they are kind of late. This should have happened with version 8 and maybe even in part version 7.
# Posted By Russell Brown | 2/9/09 2:08 AM
Anonymous's Gravatar (smile goes over his face) Funny how people whinge about cfscript, yet use frameworks which use it extensively. :-) Those who love tags are about to be very, very upset... wait and see!!

Why don't we just get rid of tags all-together!!
# Posted By Anonymous | 3/4/09 3:42 PM
MrMarbles's Gravatar Tags are antequated, an outdated relic of the former web - CF's main mantra is rapid application development - script supports that much, much better. Finally CF is growing up. Get used to it.
# Posted By MrMarbles | 7/16/09 3:34 AM

Powered By Railo

Subscribe

Subscribe via RSS
Follow garyrgilbert on Twitter Follow me on Twitter
Or, Receive daily updates via email.

Tags

adobe air ajax apple cf community cfml coldfusion examples ext flash flex google javascript jquery max2007 max2008 misc open source programming railo software technology ui

Recent Entries

No recent entries.

Blogroll

An Architect's View
CFSilence
Rey Bango
TalkingTree

Wish List

My Amazon.com Wish List