Making the Case for ColdFusion
After a decade of Web development, I’ve played with just about every language. I’ve dabbled in ASP, spent considerable time with PHP and, just recently, jumped into the world of ColdFusion.
When I was first introduced to ColdFusion, I was against it. It was version 5.x at this point, and I couldn’t see anything about it that I liked. My counterpart on the East Coast had been using it for years and was a seasoned ColdFusion programmer. I was a seasoned PHP programmer who had just completed a major project for my department, and was now being asked to move to ColdFusion to come into line with worldwide operations. I was a rogue developer with my FreeBSD PHP Web server and I didn’t fit with the Microsoft world I was working in.
My company sent me to the East Coast to talk to this developer and to learn more about ColdFusion and why it would be a good move for us. Of course, I was skeptical; ColdFusion was a rich man’s language in my eyes. With the server costing $1,300 or more, not including the cost of MS Windows, etc., I couldn’t see how my little section could afford to make the leap. I spent a week on the East Coast shadowing this ColdFusion programmer, and when I left to come home, I had a stack of ColdFusion books and a new respect for the language.
Many of you, I’m sure, have at some point had to look at an alternative language for Web development. It’s not easy to move from a language you know, love, and have spent months or years mastering, to one that seems completely foreign. This is what faced me when I was asked to switch from my happy PHP world to the dark side of ColdFusion.
Just over two years later, I’m a 100% ColdFusion shop. Sure, I still talk about PHP, and I still recommend it here and there, but I’ve learned that I can do things faster, cleaner, and — believe it or not â€“ more cheaply than I could with PHP. You might be skeptical now, as I once was, but I hope that by the end of this article, you’ll start to see enough of the light to realize ColdFusion isn’t the dark side after all.
First, some background on the ColdFusion language for those who are totally in the dark about it.
ColdFusion was originally developed by the Allaire brothers in 1995. This then started the Allaire Company, which was later bought by Macromedia. Like most Web languages, it was meant to provide Web developers with a way to talk to a database and display data on Web pages. As with many such languages, in the early days, it was not the most advanced technology, but it was one of the more simplistic to implement, understand and use. This vision still holds true with today’s ColdFusion MX (version 6.x of ColdFusion). In fact, ColdFusion was the reason Microsoft released ASP, which was being developed by Aspect Software, a competitor of Allaire that was later bought by Microsoft. So, in a round about way, all you ASP programmers have the ColdFusion developers to thank for your programming language!
Now, let’s get back to the background of the ColdFusion language. Besides a history of acquisitions and changes, ColdFusion has always been a Rapid Application Development (RAD) language built for the Web. ColdFusion accomplishes this RAD claim by providing the language in a tag-based usage, which will be familiar to any HTML programmers.
Many of the other languages out there use a programmatic approach to server side scripting, which is great for a seasoned programmer, but, to someone who’s spent most of their time with HTML tags, this can be a little daunting. A ColdFusion tag always looks like
<cfTagName> with the “TagName” being replaced with the actual tag you are using. Similar to the way PHP uses the
<?php and ASP uses
<% to signify the start of code, the
<cf tells the ColdFusion server, “Hey, here’s some ColdFusion to process”.
Most ColdFusion tags have an ending tag that makes up a tag pair. Like HTML tags, CF tags end with
</cfTagName>. So, for example, you could use the following code:
<cfloop index="i" from="1" to="10">
<cfoutput> tags are the starting tags; the
</cfoutput> are there respective ending tags. As you can see from the above example, you can have code between tags, and you can even nest tags if your application so needs them.
You’ve just seen a very short snippet of ColdFusion code. It’s not my intention to teach you ColdFusion here, but to provide you with enough knowledge to make you curious to check it out further. To learn more about ColdFusion tags, aka ColdFusion Markup Language (CFML), visit the Macromedia Website or browse many of the fine articles here at SitePoint.
ColdFusion Myths Debunked
You now have some very basic background information on the history of ColdFusion and how its tag-based language works. But, I’m sure you are not sold on ColdFusion yet — in fact, you’re probably thinking much like I was as this point. Let’s dive into some of the myths and misconceptions about ColdFusion, so we can clear the air a bit.
Myth #1: ColdFusion is a Rich Man’s Language
False! Yes, if you go to Macromedia’s Website and look up the ColdFusion server, you’ll see a sticker price of $1300 for the standard edition, and if you head over to Zend’s Website you can purchase their PHP Performance Suite for around $1875. I know you don’t need the Performance Suite to run PHP applications, but the Performance Suite gives you “Dynamic content caching, Code acceleration and File compression technologies, as a single solution”, which is what the Macromedia ColdFusion server gives you out of the box.
This is a good time to point out that Macromedia doesn’t charge for development servers, just for the actual production server. So, what happens when you go to production? Well, if your group has the budget, you can purchase the Macromedia Standard or Enterprise versions, or you can opt for a free version of the ColdFusion server. Besides the developer edition, download any Macromedia ColdFusion server and, after 30 days, it becomes a full-featured developer edition.
A company named New Atlanta has its own version of the ColdFusion Server. This ColdFusion server is called Blue Dragon and it comes in 3 flavors, just like Macromedia’s servers. New Atlanta has a Server Edition, a Server JX version and a J2EE version, while Macromedia has Standard, Enterprise and Enterprise J2EE versions. The great thing about the New Atlanta Server version is that it’s currently free, and there are no signs of this changing any time soon. Why is it free? It doesn’t have all the CFML tags you’d get in the New Atlanta JX version or the Macromedia Standard Edition.
I’ve worked on the New Atlanta free server and I can tell you, it’s great. It does place some limitations on the tags you can use, and the kinds of databases you can connect to (it’s currently limited to MySQL, PostGreSQL or ODBC via ODBC / JDBC Bridge), but none of this is really going to impact on your development — most of the missing tags are Macromedia-specific. Performance-wise it was really hard for me to tell a difference, though it will probably vary from application to application, and server to server.
The New Atlanta product does offer budding ColdFusion programmers the ability to deploy applications with little cost to the end users. You can even bundle the New Atlanta server with your application and deploy it all at once (special licensing is needed to accomplish this). So, ColdFusion is no longer just for the rich. New Atlanta has brought it to the masses.
Myth #2: ColdFusion is Slow
False! ColdFusion is very fast, even for someone who is just starting out and hasn’t learned all the tricks.
Currently, ColdFusion MX is built using Java (in the past, it was developed on C++), and when your pages are run for the first time, they are compiled into Java bytecode. In layman’s terms, your ColdFusion pages are compiled when they are first run, much like a program, and are then stored on the ColdFusion Server as binary files. If your ColdFusion server is configured with Trusted Cache turned on, then your files will be compiled only once. If Trusted Cache is turned off, your files are compiled with each page load, or when the page expires (again, a discussion of the CFML code and server configuration details to do this are beyond the scope of this article).
So, what’s so special about the pages being compiled into bytecode?
Bytecode is computer object code that is processed by a program, usually referred to as a virtual machine, rather than by the “real” computer machine, the hardware processor.
(Definition from Whatis.com)
Once the ColdFusion code is compiled into bytecode, your server can interpret the instructions of your program faster, since it’s in a language it already understands. Many current Web languages are interpreted at runtime, which means that they’re processed and compiled each time they’re run. Typically, the difference between bytecode and interpreted code on a Web page is milliseconds to seconds. Yet, these differences can add up quickly in a Web application, and could easily mean the difference between a happy customer and an unsatisfied customer.
Myth #3: ColdFusion isn’t supported the way <insert language> is!
Wrong again! ColdFusion has a huge community of followers and is backed by one of the largest Internet companies. You can find loyal ColdFusion followers in just about every major city across the world. They typically belong to the local ColdFusion User Group (CFUG), and are always willing to lend a hand or some teaching to help you along the way. There are also ColdFusion communities springing up all over the place.
You can always find help at Macromedia’s Developer Center for ColdFusion, and here at SitePoint there’s also an active CF community. Some are now starting to offer ColdFusion classes and, of course, there are many sites offering courseware for ColdFusion and for ColdFusion Certification.
Myth #4: ColdFusion doesn’t have the ability to <insert cool feature of another language>
False! I have yet to find something that ASP, PHP, or JSP can do that ColdFusion can’t. ColdFusion has all the programmatic ability of the aforementioned languages, as well as a tighter integration with other Macromedia technologies like Flash or the new Flex language.
One of the biggest things ColdFusion has over these languages is that most of these special features are built into ColdFusion. Take charting, for example. With a simple database query and a CFChart tag, I can create a bar, line, pyramid, area, cone, curve, cylinder, step, scatter or pie chart in Flash, JPG or PNG formats, and that graph can be 3D or 2D! This facility is offered out of the box with very little or no configuration needed.
ColdFusion also has hooks into other Web languages and objects such as C/C++, Java, COM, CORBA, XML, SOAP and more! You’re never limited to programming only in ColdFusion, thanks to all these hooks and APIs. Take my current employer, for example. Their code is 99% Java but, thanks to ColdFusion’s hooks into Java, I can take a Java developer’s class file and use it in my application, thereby increasing our code reuse. That’s pretty snazzy, if I do say so myself.
Myth #5: ColdFusion encourages poor programming practices.
False! ColdFusion provides all the building blocks necessary to develop highly scalable, modular and maintainable code. ColdFusion does not enforce any particular development methodology but, instead, focuses on getting the job done. Many programmers who start out with ColdFusion do typically write less than perfect code, but you can find the same problems in ASP, or PHP.
Two major development methodologies now exist: FuseBox, and MACH II. A developer using one of these methodologies can, over time, learn better coding practices, but it’s really up to the programmer and the project to determine what works best.
That’s it for the top 5 myths about ColdFusion. For more Q&A, check out the CFFAQ site.
The Benefits of ColdFusion
Now that we’ve cleared the air, let’s talk about some of the strong points of ColdFusion and why it could be a good fit for your company, or a good path for you to investigate.
A Java Base
As I mentioned before, the ColdFusion Server is built using Java and is a Sun J2EE verified application. This means you can deploy and run ColdFusion and your application on a wide variety of application servers, such as Sun ONE, BEA, IBM WebSphere and many others. Macromedia even includes a fully licensed copy of JRUN 4 with the Enterprise Edition of ColdFusion.
What does this mean for the average developer? Well, let’s say you create a really cool application and you sell it to a big company that, in the following months, decides to standardize on Java. If you had a PHP or ASP application, you might be in big trouble and lose your contract, but, with ColdFusion, you can rest easy. You application will run on their application server — it will even interface with their present and future Java code.
Errors and Bug Fixes
Another big issue for developers is debugging and receiving error messages from their applications. With ColdFusion, you can catch exceptions and respond to them however you like (just as you can in Java), or you can allow the server to display error messages to the user. From your ColdFusion Administration panel, you can set the level of detail you want the errors to contain, identify which IP addresses can see detailed errors, and even set up custom pages to handle errors or missing templates. With ColdFusion debugging, you receive a detailed error message that tells you exactly where your error is, what the stack trace was (the order of files called prior to the error), and a suggestion as to what the problem could be. It is very rare that you will receive an error message that causes you to think more and debug less.
On top of the great error messages, you also get a plethora of debugging information. When I load up a ColdFusion page on my development environment, I see the name of my application and the template I’m currently looking at. I can also see a complete stack trace, which includes page execution times and full paths to these pages. I see a full listing of all my Application, CGI, Cookie, Server, Session, Form, and URL variables. There is very little reason for me to print out a variable just to see its value when I can simply scroll through my browser and have a full report.
ColdFusion Components – CFCs
With the release of ColdFusion MX, Macromedia introduced the idea of ColdFusion Components (aka CFCs). These are a great leap for ColdFusion, and are one of the most popular features of the new system. See ColdFusion Components, an Introduction for more details.
One of the greatest features of CFCs is the ability to document your code without having to throw in a bunch of comment tags. By using the “hint” attribute in your CFC files and <cffunction>s, you can tell future users what your CFC does, what the individual methods (also referred to as functions) do, and what kinds of data they take (input) and display (output). You can then browse directly to the CFC, type in your administrator credentials and receive a very nice output of this information.
If you’ve ever had to document your code, you’ll know what a royal pain it can be. I’ve found this feature to be invaluable in my day to day operations. Since the documentation changes with the code, it’s also very dynamic, so you can rest assured that your current documentation will include the new features you just added.
I hope that, by now, you’re looking at ColdFusion in a different light and see it as something to investigate further. I highly recommend you download a copy of either the Macromedia ColdFusion Server or the New Atlanta Server, and play around with it. I’m sure that with an open mind and a little time, you’ll see ColdFusion as a viable alternative to your current Web development efforts. If you have any questions, please feel free to contact me directly or follow up with a post in the SitePoint Forums.
For those who are ready to jump in and get started, here are some great resources:
- Macromedia ColdFusion – Begin your journey here by downloading the various server versions. Be sure to grab the developer edition, which is good for 1 IP address.
- New Atlanta Blue Dragon â€“ Find the Free ColdFusion server as well as alternatives to the Macromedia Standard and Enterprise versions.
- Forta.com â€“ This guy is the chief evangelist for ColdFusion. Consider him the ColdFusion Godfather. Ben Forta has been doing ColdFusion and other related programming for many, many years. He has written many books on various ColdFusion subjects and other Web technologies, and is considered an expert in his field. His site offers links to his books, tips, tricks, hints, hosting links, and a Weblog where you can keep up with him and ColdFusion.
- MXNA â€“ The Macromedia XML News Aggregator is a central point for many of the Macromedia related blogs on the internet. Here you’ll find blogs for ColdFusion, Dreamweaver, Flash and many more Macromedia topics. This is a great central point for Macromedia knowledge.
- SitePoint ColdFusion Blog and Forums â€“ You can never go wrong with any of the sitepoint.com resources and these two are no exception.