ColdFusion 8: Believe The Hype

Tweet

Rather than succumb to the many premature rumors of its impending demise, ColdFusion continues to thrive, even more so under the auspices of its new owner, Adobe. With the release of ColdFusion 8, Adobe has reaffirmed its commitment to ColdFusion by releasing the most feature-rich version in years.

Whether you’ve never used ColdFusion before, you’re considering coming back to the fold, or you’re looking for a good reason to upgrade, ColdFusion 8 definitely deserves your consideration. Indeed, ColdFusion 8 represents a major release, with more new features than I could possibly cover in a single article. In short, now is a very good time to be a ColdFusion developer, and in this article we’ll look at my favorite reasons why.

Speed Improvements

What’s that you say? Speed is not a feature? Well, when the improvement is as dramatic as it is in ColdFusion 8, it can definitely be considered a feature. The ColdFusion team analyzed over 100 actual customer applications to find and eliminate bottlenecks. This resulted in an overall improvement that makes the server up to 4.25 times faster than ColdFusion 7.0.2. In fact, some specific areas and tags are 39 times faster than prior versions. In particular, if you’re undertaking object-oriented development using ColdFusion components (CFC), you’ll notice a marked improvement.

The best part is that you don’t need to do anything to take advantage of this feature other than install ColdFusion 8. Without changing a single line of code, your existing ColdFusion application will see a huge performance boost. So, here’s the plan…

  1. Sell your boss on a plan to dramatically improve site performance, budgeting four weeks of work.

 

  1. Buy and install ColdFusion 8.

 

  1. Spend four weeks improving your ranking on World of Warcraft.

If you aren’t already developing with ColdFusion, it’s important to keep in mind that ColdFusion has long since outgrown the accusations of being slow or unscalable. As a developer at The Economist who recently upgraded to ColdFusion 8 noted, “…the whole thing is ridiculously stable.”

Server Monitor

Sometimes, when diagnosing application performance issues in previous versions of ColdFusion, it felt like you were a doctor trying to diagnose an internal injury without access to an x-ray machine. You knew something was generally wrong inside, but you had no way of seeing (and therefore, of treating) the issue. Well, the good news is that ColdFusion 8 (Enterprise and Developer versions) comes with an x-ray machine … er … a server monitor that allows you to peer at the internals of your ColdFusion server on which you’re running your application.

The ColdFusion Server Monitor is a Flex application that allows you to examine a variety of statistics related to the overall health of your server. It provides you with details about specific applications, sessions, requests, and queries. For example, you can get reports on slow requests, and drill-down into those requests to see variable memory usage for each request, as well as the performance of any includes, custom tags, and components within the request. This can help immensely when you’re trying to locate bottlenecks within a slow request. In my opinion, this feature alone will have a huge impact on how developers will build and debug ColdFusion applications going forward.

In addition, the Server Monitor offers customizable alerts that allow you to receive notification when certain undesirable behaviors occur, such as low JVM memory or excessively long-running threads. You can even customize the response that the Server Monitor implements when this behavior occurs, configuring it either to send an email, create a snapshot, kill threads running longer than a specific timeframe, or even execute a set of custom code from within a ColdFusion component that you specify.

Ajax Integration

With the release of version 7.0.2, ColdFusion added Flex integration, which made it the language of choice for building Rich Internet Applications (RIAs) using Adobe’s Flex. This was great for those of us who love Flex (as I do!). However, building RIAs with Ajax required the integration third-party open-source libraries if you wanted to work natively with ColdFusion data types and JavaScript. It also meant that you had to include and learn the syntax of one or more external JavaScript libraries like Ext, Spry or the Yahoo User Interface library (YUI). With ColdFusion 8, this is no longer the case.

ColdFusion 8 has added a long list of new tags and features that have been designed specifically to allow you to rapidly build Ajax-based Rich Internet Applications using a comfortable and familiar tag and function syntax. In fact, the libraries that I mentioned above are built into ColdFusion 8, making it possible, for example, to create an Ajax grid using Ext simply by using the cfgrid tag. You can even bind this grid to a dataset that’s returned by a CFC method simply by putting a reference to the cffunction into the bind attribute of the tag. ColdFusion 8 really does make it incredibly simple and intuitive to add some glitz to your application by integrating rich user interface elements.

Even better, in my opinion, is that the Ajax integration in ColdFusion 8 goes much deeper than simply adding fancy UI elements to your application. ColdFusion added tags and functions that allow you to easily move data back and forth between JavaScript. For example, with the cfajaxproxy tag you can make functions that reside within a CFC callable directly from your page, using JavaScript. This feature will even automatically convert data types (such as a ColdFusion query object) into a type that’s usable within your JavaScript block, such as an array or as JSON packets. The created proxy also contains built-in methods for setting a callback handler for the asynchronous method calls. All of this makes working with Ajax and ColdFusion feel completely seamless.

The following example code shows how the cfajaxproxy tag can be used to create a class based upon a component that can be used within JavaScript:

<cfajaxproxy cfc="path.to.cfc" jsclassname="MyClass" />   <script>    function myFunction(id) {        var myClass = new MyClass();        myClass.setCallbackHandler(populateWindow);        myClass.getSomeData(id);    }    function populateWindow {        // this function can be used, for example, to populate the returned data into a javascript window generated with the cfwindow tag    } </script>

 

Debugger

A long time ago, ColdFusion had its own IDE called ColdFusion Studio, which included a step debugger. When that tool moved on from this world, ColdFusion programmers became experts at trying to debug through the cfdump/cfabort method, which basically entailed dumping the value of a variable on-screen and aborting the request. While this was effective, it has some major drawbacks, the primary one being that it was an extremely slow and tedious process to debug an entire page this way. Nonetheless, many ColdFusion programmers like me grew accustomed to the drudgery and forgot what we were missing … Well, we’re without a serious debugger no longer!

The ColdFusion 8 debugger was built in the Eclipse IDE, which is a tool that will be familiar to anyone using either Flex Builder or CFEclipse. The debugger allows you to set breakpoints and to debug requests running on either a local or remote ColdFusion instance. Once a breakpoint is encountered, you can inspect the value of any and all variables within any scope contained in the request. Additionally, you can step through the request and watch certain expressions to look for inconsistencies in the value settings. I believe this, combined with the Server Monitor, not only makes the debugging process much easier, but allows us the insight to create much more efficient and bug-free applications. Not that I ever write bugs! (Ahem! — Editor.)

Multi-threading

I liken the addition of multi-thread capabilities to ColdFusion 8 to being bitten by a radioactive spider. It provides the developer with a great deal of power, but we all know what comes with great power … yes, usually fame and money, but in this case I’m referring to great responsibility. Additional threads are used to improve the performance of a request that contains some sort of long-running process which is passed off to a thread. Typically, threads can either be:

  • created and then rejoined to the current request thread when they have completed
  • created and then simply forgotten about when they have completed
  • created and run indefinitely, being alternatively put to sleep or put to work as needed

ColdFusion makes it very easy to spawn new threads with the cfthread tag. Any code contained within the cfthread tag is executed asynchronously, with the current request existing in an independent stream of code execution. The remainder of your request can continue to process without the need to wait for the thread’s code to finish unless it’s instructed to do so. Any experienced programmer will have run into a multitude of situations where the page request shouldn’t need to wait for a particular process to run before continuing, so clearly this is a very useful function (despite its propensity to be misused).

To give you an example of how this would work, the following example shows some code that loops through an array of RSS feed URLs and uses the new cffeed tag to parse the RSS XML. It processes each feed on a separate thread so that they can all run simultaneously, reducing the overall time it takes to process the page. Once the threads are complete, another cfthread tag is used to rejoin them to the current thread, where we can output the values. Those of you who are already familiar with ColdFusion might also notice that I’m using the new implicit array creation to build my feed array:

<cfset feeds = ["http://www.remotesynthesis.com/blog/rss.cfm?mode=full","http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml"] />   <cfset threads = "" />   <cfloop from="1" to="#arrayLen(feeds)#" index="i">      <cfset threads = listAppend(threads,"thread"&i) />      <cfthread action="run" name="thread#i#" feed="#feeds[i]#">          <cffeed source="#feed#" properties="thread.myProps" query="thread.myQuery" />      </cfthread>   </cfloop>   <cfthread action="join" name="#threads#" timeout="6000" />   <cfloop list="#threads#" index="thread">      <cfif structKeyExists(cfthread[thread],"myProps")>          <cfoutput>#cfthread[thread].myProps.title#<br/></cfoutput>      </cfif>   </cfloop>
Even More…

As I said earlier, there are so many new features in ColdFusion 8 that I can’t possibly cover them all in detail here. However, here’s a handful of the key features that might pique your interest in this new release:

  • Deeper PDF Integration: As one would expect from an Adobe product, ColdFusion 8 contains the most sophisticated PDF integration of any application server. It goes beyond simply creating PDFs on-the-fly to proving developers with the ability to create PDF forms and accept PDF form submissions, merge PDF files, add and remove pages, create page thumbnails, and much more.
  • RSS/Atom Integration: As shown briefly above, the new cffeed tag makes it easy to read and create RSS or Atom feeds.
  • Image Manipulation: ColdFusion 8 finally includes a long list of tags and functions to create and manipulate images.
  • Zip/Jar File Manipulation: Create, modify and extract both .zip and .jar files.
  • Presentations on Demand: Build on-the-fly presentations that work just like Adobe Presenter.
  • Language Improvements: Version 8 introduces a number of syntax and general language enhancements that include JavaScript-style operators, implicit array and structure creation, and the passing of attributes into tags as collections. These improvements can make your code faster to write, easier to read, and much less verbose.
  • .Net Integration: Work natively with .Net assemblies that exist either locally or on a remote server.
  • Exchange Server Integration: Programmatically manage email, calendar items, contacts, and tasks on a Microsoft Exchange Server via ColdFusion tags.
Summary

As you can see, so many new features are included in ColdFusion 8 that your five favorites might be entirely different from mine. If you haven’t tried ColdFusion 8 yet, what’s stopping you? The Developer Version is free, after all. Give it a go!

Further Reading

Performance
ColdFusion 8 Performance Brief (PDF, 172K)

Server Monitor
ColdFusion 8 server monitoring series:

Ajax Integration
An overview of Ajax features in ColdFusion 8

Debugger
Using the ColdFusion 8 step-through debugger for Eclipse

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

No Reader comments