"At times I think and at times I am." |
With recent articles proclaiming Coldfusion to be dead or dying, there have been several 'rebuttal' posts by members of the CF community defending it from misinformation that every author seemed to have (go figure). Many of those posts did a really good job of showing the readers that CF is alive and kicking and talked about some of Coldfusion's amazing qualities. One of those qualities that seemed to come up in almost every post was that Coldfusion enables you as a developer to be more productive. This is a completely true statement (as you will see) and I totally agree with the authors when they say it. The problem however is that none of the statements made those posts, were backed up with examples.
I think it's really hard to drive home the point of Coldfusion and productivity to non-CF developers without throwing concrete examples in front of them to see first hand. Many of the skeptical readers won't spend the time to figure out on their own if that statement is true or not, most will probably see it as "my language is better than your language" flame bait. I don't blame them for thinking that way given the pretense of the article and no examples to prove it.
My attempt with the rest of this post is to help back up the claim that CF enables you to be more productive. I tried to choose examples of task that are sometimes trivial but also part of the average everyday development.
Language Verbosity
I want to first briefly mention this aspect of Coldfusion as many claim that it is a verbose language. For simple operations it can seem take more characters than needed, but as you will see in the examples below Coldfusion is actually very non-diffuse and abstract. This makes your code much cleaner and concise, improving readability which helps save time overall in your development and refactoring efforts.
Keep this aspect in mind when you think about how you solve the examples below in your favorite language.
Querying the Database
This example shows how easy it is to establish a connection to the database, retrieve data from it and cache the result set for a specified length of time.
On top of the connection handling bit, the attribute 'cachedWithin' will cache any given result set for a specified length of time. No extra classes, frameworks or sql semantics are needed, Coldfusion gives you caching capabilities with a single attribute.
Displaying a Result Set
After executing a query Coldfusion will return you a data structure containing the result set (if applicable) and a ton of additional metadata (if specified). Unlike other languages Coldfusion provides a very elegant way to iterate over your result set. The example below will show you how easy it is and some of the metadata elements you have access to.
'Dumping' an object
Coldfusion has a tag which I consider to be a killer feature, I have yet to find it's counterpart in any other language (that is built in). <cfdump> is a tag that will take any object and serialize it into a collapsible HTML structure for display. <cfdump> works with almost every type of variable simple or complex including non native objects come from Java or .Net... pretty much anything CF can work with can be dumped. This is an extremely useful feature for debugging which painstakingly prevents you from having to write an HTML friendly serialization of objects. Below is the example of the HTML displayed from dumping a complex array:

Uploading a file to the server
In a single line of code you can upload a file to the server, have Coldfusion rename it if another files exists with the same name and to give you container fill with tons of metadata when the operation is complete. Take a look at the following example:
In addition, the
Working with Web Services
Working with web service can sometimes be complex and a pain. This is especially true when dealing with SOAP based service. Many developers are shying away from them for the more simplistic REST model because they are easier to consume and publish but with Coldfusion, working with SOAP services couldn't be easier.
Publishing Services
To expose any piece of functionality as a consumable web service in Coldfusion, you simply provide a value of "remote" in the 'access' attribute of a <cffunction> tag... Thats it... In other web based languages you either need some sort of configuration set-up, extra classes or external mods to achieve what CF can give you in one simple attribute:
Consuming Services
Just like publishing, consuming a service is extremely easy. The example below shows how you might consume a service that looks like the one above.
The examples that I covered are only a small subset of the many ways that CF can enable you to be more productive. It's combination of features and abstractness make it possible for developers to get more done in less time, hence Coldfusion enables developers to be more productive.