Ben Forta

Created

30 July 2007

Requirements
 
User level: All
 
 
It’s been over two years since the introduction of the highly successful ColdFusion 7, and much has changed in that time:
 
  • There’s a new name above the door, we’re now Adobe (for those who are counting, that brings the companies who have owned ColdFusion to three).
  • Adobe Flex Builder 2 was released, making Eclipse even more appealing for many developers.
  • Ajax (which previously had referred to a character in Homer’s Iliad, a tragedy by Sophocles, a Dutch football club, and a household cleaning product) has become the hot new way to build next-generation web front ends.
  • AIR (previously Apollo) has gone into public beta, allowing developers to build desktop applications using Flex/Flash and HTML/JavaScript.
During this time we’ve been hard at work building the next ColdFusion, and the above events (and more) helped shape what is now ColdFusion 8.
 
Earlier this year, I was fortunate enough to present ColdFusion 8 to thousands of developers as part of our pre-release user group tour. And while preparing the presentations and demos I was struck by just how much there is in ColdFusion 8 to talk about—this is no incremental update, this is leaps and bounds further than we’ve talked about ColdFusion before (and ColdFusion MX 7 already leapfrogged the competition). For the user group tour we cherry picked the features we wanted to demo, and changed the presentations and demonstrations weekly (both for our own sanity and to keep the content fresh). And here too, I am going to only highlight a subset of the features and technologies that make up ColdFusion 8.
 
And so, here are my Top 8 reasons why ColdFusion 8 is important to you:
 

 
Reason # 8:A better CFML

We love CFML (ColdFusion Markup Language) because it is clean, easy, productive, and fun. But that doesn’t mean that it can’t be improved. ColdFusion 8 introduces lots of little goodies that just make working with CFML easier and more intuitive.
 
Here’s one example. In the past ColdFusion expressions did not support operators like ++ and -=, but in ColdFusion 8 CFML supports ++, --, %, +=, -=, *=, /=, %=, &&, ||, and !. In addition, in the CFSCRIPT tag blocks, ColdFusion 8 also supports ==, !=, <, <=, >, >= as evaluation operators.
 
Here is another example, consider creating an array and populating it with values. Here is current ColdFusion syntax:
 
<CFSET myArray=ArrayNew(1)> <CFSET ArrayAppend(myArray, "Adam")> <CFSET ArrayAppend(myArray, "Ben")> <CFSET ArrayAppend(myArray, "Tim")>
And here is the equivalent in ColdFusion 8:
 
<CFSET myArray=["Adam", "Ben", "Tim"]>
Here’s how to create an initialize structure currently:
 
<CFSET myStruct=StructNew()> <CFSET myStruct.product="ColdFusion"> <CFSET myStruct.version=8>
And here is the equivalent in ColdFusion 8:
 
<CFSET myStruct={product="ColdFusion", version=8}>
Of course, the old syntax still works, but for those of us who work with multiple languages (including JavaScript and ActionScript), this makes the code cleaner and more consistent.
 
One more example, and this is one of my favorite CFML enhancements. Consider a situation where you are using CFML tags and sometimes need to use optional attributes (maybe the CACHEDWITHIN attribute in a CFQUERY tag or SERVER attribute in the CFMAIL tag). There is no way to conditionally append attributes to a tag, and so you’d likely end up with multiple sets of tags, each with differing attributes. But in ColdFusion 8 you can do the following:
 
<CFSET args=StructNew()> <CFSET args.name="myQuery"> <CFSET args.datasource="myDSN"> <CFIF needCaching> <CFSET args.cachedwithin=CreateTimeSpan(0,1,0,0)> </CFIF> <CFQUERY ATTRIBUTECOLLECTION="#args#"> ... </CFQUERY>
In this example, the CFQUERY tag has a single attribute named ATTRIBUTECOLLECTION. This structure contains NAME=VALUE pairs for the attributes usually passed to the CFQUERY tag, and is used in lieu of those attributes. What’s the advantage of doing so? For starters, the code is cleaner and simpler. But more importantly, members may be added to the structure conditionally, as seen here, solving the problem of how to handle conditional attributes once and for all.
 
These are just a few examples, but as you can see, CFML has gotten a whole lot more powerful. And of course, all of these enhancements are optional, and you can continue to write code as you did before too.
 

 
Reason # 7:Access to even more back ends

Integration has always been an important part of the ColdFusion story, ever since we added support for writing your own tags in C/C++ back in Cold Fusion 2. Over the years we added support for COM, CORBA, Java, JMS, XMPP, SOAP, AMF, and much more. In many ways, ColdFusion is middleware, the glue that binds all sorts of back-ends allowing us to write apps that leverage them all. It is in this vein that ColdFusion 8 adds some important new integration options.
 
If your organization does any .NET development, then you’ll be pleased to know that ColdFusion 8 is a full .NET client. This means that CFML code can invoke any class or assembly running within the .NET CLR (local or remote, and even from a non-Windows server). Here is a code snippet:
 
<!--- Get System.IO.DriveInfo class ---> <cfobject type=".NET" name="sidiClass" class="System.IO.DriveInfo"> <!--- Get drives ---> <cfset drives=sidiClass.GetDrives()>
This code obtains an instance of the .NET System.IO.DriveInfo class, and then invokes the GetDrives() method to obtain a list of hard drives on the ColdFusion server. Obviously, this is a very simple example, but the truth is that ColdFusion 8 makes invoking .NET code really simple. In fact, ColdFusion 8 is in the enviable position of being the only platform that will let you invoke CFML, Java, and .NET code all from within the same page, perhaps even combining the results into one result set. Powerful stuff indeed.
 
Another example is Microsoft Exchange integration. If your organization uses Exchange, then ColdFusion can connect to the Exchange server like any other Exchange client, making adding tasks, setting up group meetings, and more, all a matter of calling CFML tags. The following snippet gets all calendar entries for user Ben:
 
<CFEXCHANGECONNECTION SERVER="192.168.10.10" USERNAME="ben" PASSWORD="p@$$w0rd" CONNECTION="con1"> <CFEXCHANGECALENDAR ACTION="get" CONNECTION="con1" NAME="calQuery">
Creating calendar entries, filtering data, accessing sub-folders, and more, is no more difficult than this.
 

 
Reason # 6:Sophisticated PDF integration

ColdFusion first introduced PDF integration in ColdFusion MX 7, with the ability to create PDF documents using the CFDOCUMENT tag and the CFREPORT tag. ColdFusion 8 adds two new forms of PDF integration.
 
The new CFPDF tag can be used to merge PDF files, add or remove pages, password protect files, flatten PDFs, create page thumbnails, and more. This example merges all of the PDF files in the reports folder and two additional PDF files into a new PDF file named new.pdf:
 
<cfpdf action="merge" destination="new.pdf" overwrite="yes"> <cfpdfparam source="reports"> <cfpdfparam source="sales/jan.pdf"> <cfpdfparam source="sales/feb.pdf"> </cfpdf>
The new CFPDFFORM tag makes working with PDF forms just as easy. The following populates an existing PDF form with values:
 
<cfpdfform action="populate" source="my.pdf"> <cfpdfsubform name="form1"> <cfpdfformparam name="employeeName" value="Ben Forta"> <cfpdfformparam name="date" value="#now()#"> <cfpdfformparam name="department" value="ColdFusion Team"> </cfpdfsubform> </cfpdfform>
The CFPDFFORM tag can be used to both populate form fields, as seen here, and also to extract values out of electronically submitted forms.
 
And this is just the start of it. There are dozens of attributes and options that provide ColdFusion developers with all sorts of sophisticated PDF integration, all exposed by a few simple tags.
 

 
Reason # 5:Debugger redux

ColdFusion used to have an interactive debugger back in ColdFusion 4 and ColdFusion 5 days. But with the move to ColdFusion MX we lost the interactive debugger, much to the dismay of many developers. Well, now, after a seven year hiatus, the debugger is back. And this time it is built in Eclipse (the same engine that drives Flex Builder).
 
The new debugger features:
 
  • Debugging against local or remote ColdFusion servers
  • Setting breakpoints
  • Variable inspection
  • Step-into, step-over, and so forth
  • Debugging of applications launched from any browser
  • Multiple debugging sessions against the same ColdFusion server
The debugger is made available at no extra cost, it is delivered as part of ColdFusion itself. All you need is an Eclipse installation, ColdFusion 8, and RDS access, and you’re all set.
 
Oh, and we also added a client-side Ajax debugger, but more on Ajax in a moment.
 

 
Reason # 4:Improved security

ColdFusion 8 allows administrators to empower users to manage their own applications, while providing tighter security than ever before. Some of the new security features include:
 
  • Multiple configurable ColdFusion Administrator logins, allowing users to access some parts of the Administrator tool while restricting them from other parts, as defined by the admin.
  • Multiple RDS logins, and the ability to associate RDS logins to sandboxes, making RDS safe for use in shared environments.
  • Per application settings, without needing access to the ColdFusion Administrator.
  • FIPS compliant encryption.
In preparing ColdFusion 8 for release we had the product thoroughly analyzed by a third-party security risk analysis firm, who declared that "ColdFusion 8 exhibits a high degree of resilience to application layer attacks with no compromise on functionality provisioned by the new features." We couldn’t have said it better ourselves!
 

 
Reason # 3:Ajax delivered

Lots of ColdFusion developers have been asking for Ajax support, and what they are asking for falls into two categories.
 
Some users want to build full-blown Ajax front-ends using Dojo, Prototype, JQuery, and so on. These applications are split in two, the client portions are written in DHTML/CSS/JavaScript, and the back-ends are written in a variety of back-end technologies, including ColdFusion. The integration is usually via an XML format called JSON, and data sent back and forth between back-end server and the browser are formatted as JSON packets. ColdFusion makes this type of integration incredibly easy by providing built-in support for JSON, allowing data to be converted using simple functions, and even automatically encoding CFC results as JSON packets.
 
Other users, and indeed most users, want something far simpler. They want Ajax type controls and widgets, ways to leverage Ajax type functionality quickly and easily. And ColdFusion delivers this too.
 
Let’s start with a simple example, the auto-suggest control. Look at this code snippet:
 
<!--- Get data ---> <cfquery datasource="cfartgallery" name="data"> SELECT artname FROM art ORDER BY artname </cfquery> <!--- The form ---> <cfform> Art: <!--- Populate auto-suggest control ---> <cfinput type="text" name="artname" autosuggest="#ValueList(data.artname)#"> </cfform>
This is all that is needed to create a database-driven auto-suggest control. The control looks like a regular text field, but once the user starts typing, a pause will cause a list of suggestions to pop up. This is not an Ajax control (as data is all client-side, there is no asynchronous callback) but it is a fully-functional example.
 
Here is the Ajax version of the same example:
 
<cfform> Art: <cfinput type="text" name="artname" autosuggest="cfc:art.lookupArt({cfautosuggestvalue})"> </cfform>
Here the auto-suggest control points to a ColdFusion component on the server which is called asynchronously for auto-suggest lookups. The CFC in question could look like this:
 
<cfcomponent output="false"> <cfset THIS.dsn="cfartgallery"> <!--- Lookup used for auto suggest ---> <cffunction name="lookupArt" access="remote" returntype="string"> <cfargument name="search" type="any" required="false" default=""> <!--- Define variables ---> <cfset var data=""> <!--- Do search ---> <cfquery datasource="#THIS.dsn#" name="data"> SELECT artname FROM art WHERE artname LIKE '#ARGUMENTS.search#%' ORDER BY artname </cfquery> <!--- And return it ---> <cfreturn ValueList(data.artname)> </cffunction> </cfcomponent>
ColdFusion generates the needed client-side JavaScript and the example just works, it’s as simple as that.
 
Here is another example, related the SELECT tag’s controls, make a selection in the first control and the second is updated with relevant options:
 
<cfform> <table> <tr> <td>Select Media Type:</td> <td><cfselect name="mediaid" bind="cfc:art.getMedia()" bindonload="true" /></td> </tr> <tr> <td>Select Art:</td> <td><cfselect name="artid" bind="cfc:art.getArt({mediaid})" /></td> </tr> </table> </cfform>
Here two CFSELECT tags are used, and each is bound to a CFC method. The first is pre-populated by the getMedia() method. The second is populated by a call to getArt() whenever the first changes, and the value in the first is passed automatically as an argument.
 
Here’s an example of a live data grid, one that supports sorting and paging and more:
 
<cfform> <cfgrid name="artists" format="html" pagesize="10" striperows="yes" bind="cfc:artists.getArtists({cfgridpage}, {cfgridpagesize}, {cfgridsortcolumn}, {cfgridsortdirection})"> <cfgridcolumn name="lastname" header="Last Name" width="100"/> <cfgridcolumn name="firstname" header="First Name" width="100"/> <cfgridcolumn name="email" header="E-Mail" width="200"/> </cfgrid> </cfform>
Again, data is loaded by making an asynchronous call to a CFC method, and the method is called again whenever a page is changed or when data is re-sorted.
 
The new ColdFusion Ajax support is powerful and sophisticated and far beyond what can be covered here. You can read more about it in Designing and developing with Ajax features in ColdFusion 8, and I'll revisit the subject in future articles.
 

 
Reason # 2:Powerful server monitoring

ColdFusion has long been a black-box, a sealed machine that worked its magic but which never exposed those inner workings. This has created challenges for users. Consider the following scenarios?
 
  • Have you ever wanted to know exactly why a page was running slowly?
  • Have you ever wanted to know which pages or parts of your site generated the most load on the server?
  • Have you ever tried to determine how to best cache database queries, so as to cache those that are used most and not those that are not?
  • Have you ever had a problem that required you to restart a server, knowing that in doing so you would lose all evidence of what exactly was wrong?
  • Have you ever tried to determine which of the applications on your server is using the most memory?
  • Have you ever needed to kill a request?
  • Have you ever had to deal with a server that was out of memory, or had too many long running threads, or suffered some form of JVM corruption?
You get the idea. All of this information, and more, is now available via the new ColdFusion Server Monitor. You can keep an eye on one server or multiple servers, you can drill-down and access all sorts of stats and specifics (via a provided Flex front-end), and you can even create alerts so that your server can monitor its own health and take action before problems occur.
 
Oh, and if that were not enough, you can also write your own monitoring front-ends by taking advantage of the monitoring API.
 
ColdFusion is a black-box no more!
 

 
Reason # 1:Speed, speed, and more speed

If all of this were not enough, here is one of the most compelling reasons to deploy ColdFusion 8—it’s faster, much much faster. Your existing applications, without any code changes at all, will run faster under ColdFusion 8.
 
We took lots of customer code, over 2.4 million lines of CFML, and ran extensive tests against them to see how code is executed and where bottlenecks occurred. And then we set our developers loose, challenging them to squeeze out every last drop of performance.
 
Look at these stats:
 
  • Structure manipulation in ColdFusion 8 is twice as fast as it is in ColdFusion MX 7.
  • List manipulation is ColdFusion 8 is three times as fast as it is in ColdFusion MX 7.
  • The CFSET tag is more than four times as fast as it is in ColdFusion 8.
  • The CFPARAM tag runs 35 times faster than it does in ColdFusion MX 7.
  • Date functions are about 6 times as fast as it is in ColdFusion 8.
  • Regular expression functions are more than twice as fast.
  • CFC instantiation is over 20 times faster in ColdFusion 8.
And these are just a sampling of some of the stats.
 
What does this mean in practice?
 
Every ColdFusion application we tested runs faster in ColdFusion 8. Most applications see an average of 30-40% performance gain, and some applications are seeing performance 3 or 4 times that of ColdFusion MX7.
 
Oh, and your ColdFusion 6 and 7 code will work as is, no breaks, no deprecations to worry about, it’ll just work.
 
All upside, and no downside. If that’s not a reason to upgrade, I don’t know what is!
 
ColdFusion 8 is not just another upgrade, it’s the most important and dramatic release to date, and a solid testament to Adobe’s commitment to this important product. Be it for the new integration opportunities, the language enhancements, the improved security and administration, or the amazing performance gains, you owe it to yourself to take ColdFusion 8 for a spin. It really has never been a better time to be a ColdFusion developer!
 

 
More about ColdFusion 8

Check out new resources in the redesigned ColdFusion Developer Center:
 
And check out the new and updated articles, all about using ColdFusion 8: