Post Detail


ColdFusion 9 brings a great set of new features and language enhancements but personally none greater then full cfscript support. I am not sure but there has been a large number of people who have spoken out against this enhancement so I wanted to take some time today and go over the new enhancements on cfscript and some personal thoughts on the feature.

First off I wanted to touch on the fact that a lot of people have come out against this feature which I really don't understand. I personally don't use cfscript a lot because of the fact that I had to switch between script and cfml when I had to use tags like cfmail and cfquery. That problem has been eliminated and the ColdFusion team has brought to us full cfscript support.

I am a huge fan of this for 2 reasons. I think that the script support just looks better but more for productivity. The one problem I have always had with writing components is the very verbose nature of components. This is going to drastically cut down some development time and since the bulk of my time is spent writing component I am going to be pretty happy. People have expressed that they really don't like this feature and to them I would say to you, that's fine. You can continue to write your components in CFML and there will be no change for you. Another great idea would be to a ColdFusion Builder extension that would be able to convert cfcs from cfml to cfscript and vice versa.

Now that we have gone over some information about the feature let's dive into some actual code. First we have an example of user component that has been written in complete script. One of the cool features I think is the ability to keep our code clean by using JavaDoc style notation for documentation and meta data.

Then if we wanted to invoke this component we could work with the new keyword "new".

We can also take this one step further and I will talk about this more in another blog post but there have been some enhancements to cfcs that allow us to generate getters and setters by declaring properties. We can take the code from above all the way down to this. You will notice that we don't have any getters or setters defined but because we declared the property for each, those methods are in fact available for use. We run the setters in our constructor and use the getters in our get properties method.

Finally another really great thing that I wanted to point out was that ColdFusion Builder has full support for the script syntax! I just wanted to take a second to fill people in on this enhancement and as you can tell I am pretty excited about it. Please chime and let me know what your thoughts are.


James White's Gravatar James White
July 13, 2009 3:14 PM


I totally agree with you. I see no reason to dislike full script support in CF 9. I think it's better to have choices. I have used CF since back in the CF 4.0 days, and feel full script support has been a long time coming. CF has always been about speed and efficiency and there are situations where it is faster and more efficient to write script versus using tags. I'm glad Adobe decided to do what I have been wanting to see for the last 5 years at least.

I think there are some developers who have just really gotten used to tags over the years and do not want to switch. Having programmed in a few other languages (most notable Java, some C#, and a bit of Perl). I have an appreciation for the script syntax
and consider it to be a big step towards making CF an even stronger language. So people who want to continue to work with tags, good for you, they work and have worked for a long time, but I'm totally pumped about this enhancement above all the others.

In terms of CF Builder, I just downloaded the Beta today and am looking forward to getting a feel for CF 9 over the next few months.


Paul Kukiel's Gravatar Paul Kukiel
July 13, 2009 3:44 PM

I love the addition of full cfscript support and look forward to having my CF code look closer to my Action script ( Flex ). Now all we need is a new syntax highlighter brush....actually the java one might work just fine.


property username;

is a handy shortcut to know, thanks!

John Whish's Gravatar John Whish
July 13, 2009 4:23 PM

Nice post Dan. I think the cfscript support is great. I think it lets you write "cleaner" code, which is much easier to read. Perhaps more importantly I think that full cfscript support makes ColdFusion look like a "serious" language to developers who are used to other languages and have previously been put off my the HTML style code. If cfscript simply broadens ColdFusion appeal and credibility then it is a great asset to all CFML developers whether you use it or not! :)

Brian FitzGerald's Gravatar Brian FitzGerald
July 13, 2009 4:34 PM

Agred!! I am totally pumped about the full cfscript support in CF9. IMO, this is something that has been needed for a long time. cfscript finally feels complete!

Gerald Guido's Gravatar Gerald Guido
July 14, 2009 11:00 AM

Right on! I am writing a function, not War and Peace. I think that ppl coming from C type languages will find themselves right at home with CFscript. Tag/XML based languages can be very foreign to some people.

Case in point:

One of the things I like a about PHP, JS and other C type languages is that they are relatively terse. Writing CFCs in cfml can be such a pain.

Steve Bryant's Gravatar Steve Bryant
July 14, 2009 4:52 PM

Well said, Dan!

Like you, I am a big fan of cfscript and I am looking forward to having more flexibility in its use.

I don't know if I will build any CFCs in just script, but it is nice to know that I can. I like the idea that I can use a tag based syntax for output and a script based syntax for logic (like Flex or HTML/JavaScript). Even better, I am not forced into that configuration!