Article
ColdFusion 8: Believe The Hype
Page: 1 2
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:
- Part 1: Using the Server Monitor in development
- Part 2: Using the Server Monitor in production
- Part 3: Automated monitoring and request management with Alerts and Snapshots
- Part 4: Multiserver Monitor, Admin API monitoring, and more
Ajax Integration
An overview of Ajax features in ColdFusion 8
Debugger
Using the ColdFusion 8 step-through debugger for Eclipse