There is something in the ColdFusion world I think that many of us have just blatantly missed as developers, and I’ll tell you about something my eyes have just been opened to.
I’d like to say I have a pretty firm grasp of OO design patterns, (hell, even J2EE design patterns) and I swear by them. I LOVE them. I (foolishly) try to fit everything into an over-simplified (and sometimes anemic) architecture models. I swear by Java and its “enterpriseiness” and take comfort in the mindest that “as long as its enterprise-level, I can do whatever I want”, that old mentality, its easier to take away from…
I. Am. Dead. Wrong. (this isn’t new, though…more on this later).
You may have noticed, that my posts have slowed as of late, and there is a reason for this. Lately, I have been having a bit of a “software renaissance”. I have been questioning every single principle and theory I hold near and dear. Why are service layer models a good idea? What is wrong with anemic domain, really? Are business Objects the right approach? Why do I even *need* remote facades?! Well, my first mental response is, “well, its enterprise, therefore, its awesome and scalable and going to last the test of time”. Obviously, there are far more concrete answers that make more business sense and what not, but thats beside the point. In reality, none of that is true. I can create robust, scalable, non-OO code as well..
Recently, I’ve began to compare and contrast ColdFusion to Ruby on Rails. First, I’d like to debunk a common misconception that CFers have: Rails is NOT just a framework (opinion alert), I would definitely consider rails a development platform (a domain specific language, if you would) built on top of the scripting language, Ruby. I think the analogy of Ruby is to Rails as Java is to ColdFusion is definitely a fair comparison. I sat firmly in the camp that the whole web 2.0 movement (fueled by ruby) was rubbish and chose not to look over the fence to “the enemy”, but recently, needs have shifted and ruby has been placed in front of me and so I have begun to investigate it and am in the process of drawing comparisons between the different strengths and weaknesses displayed in the platforms. Also, its never good to just sit there and dislike something without really getting to know it.
In case my fellow CFers don’t know about Ruby (and Rails), Ruby is a fully object-oriented scripting language that was designed to be all purpose (similar to python’s role in the computer world), Rails was really the revolutionary domain specific language that brought ruby to the web with mainstream acceptance.
Now, right here, I see an interesting parallel, Rails is the DSL for the web built on ruby, and ColdFusion is the DSL for the web built on Java. Rails has many web-project-oriented features that we feast on daily in CF, but there are definitely some surface level comparisons that can be made even still.
First off, Ruby IS Ruby. All the pieces of software that float in the Ruby world are written in itself. So, one could argue, if you understand Ruby and Rails, you probably could write a standalone Ruby app with (almost) no problem. This mentality is quite contrary to ColdFusion; ColdFusion and everything around it is written in Java. Now, there is nothing inherently wrong with this, but one could not assume that if you understand ColdFusion, you could probably write a standalone Java app, FAR from it. Most people aren’t concerned with this because they are using ColdFusion for a reason, to get away from the needless complexities of Java. This also is one of the things that makes the Ruby community great, they can actually contribute to the projects around them (including things like rake). Most run of the mill ColdFusion developers aren’t going to know how to help Mark Drew write CFEclipse, how about writing a simple ant task? Not likely. This really hurts our surrounding technology pool as ColdFusion developers.
So, I began my trek to understand what ruby is all about and why it is so revered in the web space today. Honestly, as I’ve read through my books and dove into projects, I have yet to find something Rails can do that ColdFusion can’t. but what I HAVE found is that we are putting ColdFusion in a box it should not necessarily live within, the world of J2EE designs. What do I mean? We find things in our code that are straight from the world of Java; Remote Facades, Factories, and Gateways, Oh my! Hold on a second, didn’t we move to ColdFusion to GET AWAY from these layers of complexity? I thought I did at least. All we’ve done is built a (less robust) toy chest of tools that complicate a robust, expressive, dynamic language. Its obvious that this would happen because a decent amount of the (advanced) people who care about ColdFusion come from Java/J2EE backgrounds…go figure, right? :)
Sean Corfield recently was the first to admit this mentality, He found himself trying to fit ColdFusion into this box and discovered how much we are limiting ourselves with this sort of mentality. Java is (obviously) not a dynamic language, its very much a static and compiled language that does not lend itself to the sort of flexibility you find in languages like Ruby and ColdFusion. So think about it this way, Interfaces aren’t used to dynamic, runtime functionality, factories didn’t originally account for the wonders of typeless environments (read duck typing), etc. These constructs were design with a set of constraints placed upon them, and in ColdFusion we are CREATING these constraints on top of a language that never had them in the first place. WTF?!
Now, of course, who is to say we can’t improvise on factories and make them a bit more flexible and powerful based on our dynamic freedoms, but then I start asking myself, what is this really doing for me now? A lot of the time, I considered relying on things like services layers thinking that I would be able to “account for things I can’t see” in the future. Rails developers are quite different, they develop only what iss needed, and grow and grow as the complexity needs arise. This is of course, a rather obvious approach (again not Rails-specific, just a trend), but often times, I find myself mapping out parts of my code that does not need to be mapped out yet and will lead to the inevitable refactoring nightmare.
Ponder this, should we EVER be able to refactor ColdFusion? Is that a benefit? and if it is, why? Is refactoring in a dynamic language something we should even be considering?
I think that this is one of the reasons we get stupid people coming around saying “Cold Fusion? Isn’t that language dead!?” is because foundationally, we are the same animal we were 11 years ago. Revolutionary at the time, but in 11 years, we have seen a lot of powerful technologies come our way that solve problems differently, and in another 11 who knows if we will even still be talking about ColdFusion, or Rails, or Django, or whatever. Also, maybe its the difference in mindsets that rails and CF people have; The average CFer doesn’t really know what (or use) the dynamic powers of CF, for instance.
Regardless of my decision for ColdFusion or Rails in my future projects, I have definitely had a paradigm shift in the way I think about my code in dynamic languages.