A couple of weeks ago I had the pleasure of having a conversation with Carl Franklin and Richard Campbell on .NET Rocks!, one of the premier .NET podcasts out there. While I ColdFusion is definitely my first love, I do plenty of .NET development, mostly C# WinForms and plain ole C# objects. That said, I think the show is great for more than just .NET – I can’t tell you the number of times I’ve learned new information on their site unrelated to .NET.
The Show
Our conversation was a follow-up to some email I sent them regarding a show where Rey Bango was a guest (talking about JavaScript). Rey, currently at Microsoft, was a ColdFusion guy back in the day, and on the show, ColdFusion was referred to as a “blast from the past”. I think that’s far from true: while ColdFusion is an “old” technology, it’s highly relevant today. So… a few emails later, they brought me on the show to talk up some ColdFusion.
When you speak in a public venue, you generally have an unlimited list of things you want to discuss, but a limited amount of time. So as you can imagine, there were tons of things I wanted to talk about that I’ll try to touch on here.
To the ColdFusion community: You’ll probably find a lot of things I failed to mention, which I did, but the focus was to emphasize that ColdFusion is a modern day language that is as relevant as .NET, PHP, and others. I think we accomplished that purpose. Also, the conversation was a very candid one, and looking back, I fear I may have come off as bashing Adobe a bit. I hope that’s not how my comments were received, but rather, but in the spirit they were given: a desire that Adobe more eagerly embraces its role as a server-side leader and putting ColdFusion more front and center.
To the .NET developers: Based purely on what you heard on the show, you probably have some impressions about what ColdFusion is, and what it isn’t, and how it’s deficient. I’ll attempt to address some of those ideas here
Event handling
ColdFusion does have a large degree of event handling, but it’s more like ASP.NET’s page lifecycle approach: onServerStart/End, onApplicationStart/End, onSessionStart/End, onRequestStart/End, etc. There are error events as well: onError, onMissingMethod, etc. There is also event handling inside of ColdFusion 9′s Hibernate integration, based on various ORM events. It also has an event gateway, which let’s you respond to various non-request events (such as watching a directory or message queue and responding based on defined listeners).
Moreover, the various MVC frameworks add more. (In speaking on MVC, I’ll be referencing ColdBox, which I know best. However, I’m certain most or all of what I address with apply to the others.) These frameworks have additional events (or extend the ones built into ColdFusion) accessible via framework methods, and you can even define your own events.
What you don’t really have are client events triggering events on the server. (I’m not talking things like jQuery events, but rather, ASP.NET code-behinds) ColdFusion doesn’t care about your markup, or how it received it’s headers: it just responds to what it’s given. This how all languages work, and it’s purer to the heart of what HTTP really is. (Hence, the movement away from WebForms towards ASP.NET MVC)
Tag-based syntax
Many think of ColdFusion as HTML++, since it has a tag-based syntax. This is true, but this in no way takes away from the language – it is a fully featured programming language. (Looping, calling web services, threading, PDF integration, database integration, objects, etc….)
However, for those who don’t like this syntax, ColdFusion has an C-style syntax that anyone familiar with C# should feel comfortable with. In the past, it was simply a way to do basic variable manipulation. However, over time, it has grown to include more and more of the language. As of the most recent version, you can query databases, send mail, write log files, create threads, and pretty much everything you’d do in tags, with only a short list of exceptions (rarely used platform-specific tags). You can even write objects fully in “CFScript” (while that goes back to CF’s roots, it’s now a misnomer in my opinion, as it’s more of a “second language” than scripting)
I had an app doing a lot of crazy things with Selenium RC. Originally the app was written in C# (because iterations of it used WebClient and then the iMacros .NET object), and I was utilizing the Selenium .NET object. However, I recently migrated over to using ColdFusion, relying on CFSelenium. I was able to copy and paste this code from C# directly into ColdFusion, and it ran with very little modification (in the catch block, the Exception type is different, and I removed “System.Threading.” from my Sleep() calls).
ORM
ORM has extensive use in the .NET space, whether you’re using the built-in Linq-to-SQL, or Entity Framework, or an add-on framework like NHibernate. ColdFusion integrates Hibernate as a core feature. You can even create objects, give them a “persistent” attribute, and they’ll become entities with no boilerplate needed. In addition, there’s a couple of great custom ORM frameworks that came out in the years prior to the Hibernate integration, Transfer and Reactor.
What about the rest of LINQ, where you can use SQL-like syntax to query non-database resources? ColdFusion has a feature called Query-of-Queries. This allows you to take a recordset, perform an in-memory query of it, and create a new recordset. Yes, ColdFusion has its own built-in SQL parser. This is cool, but this can be used for more than databases, as a number of ColdFusion functions return query objects, such as <cfdirectory>. Moreover, ColdFusion allows you to construct your own recordsets using functions like queryNew(), querySetCell(), etc, so you could mold any data structure into a format that lets you query, essentially doing what LINQ-to-Objects does.
.NET integration
You can integrate .NET classes into your ColdFusion applications – it can call them the same way it can call ColdFusion objects you’ve written, Java classes, or SOAP web service, via createObject().
Some of ColdFusion’s winning moves are the integrated features that other platforms require add-on components for: easily sending and receiving email, image or chart generation, PDF file generation, etc. ColdFusion exposes a number of these features (known as ColdFusion as a Service) via a series of SOAP services.
ColdFusion is a great platform, and like all platforms, it has its pros and cons. I hope I’ve helped the intelligent developer out there see that most of the worn-out arguments about the platform don’t hold much water or are outright incorrect, and that it’s a valuable thing to have in your toolbox, like .NET, Ruby, etc. I want to thank Carl and Richard for having me on .NET Rocks!, and want them to keep up the awesome work.