ColdFusion meet Ruby on Rails

posted August 9th 2005 at 0057 EDT in All, Articles, ColdFusion, Rails, Ruby

I may make the third ColdFusion developer to begin switching to Ruby on Rails behind Michael Buffington and Greg Narain.. but why?

I am certainly no stranger to programming – especially web development – it has been my bread and butter for numerous years. If you are curious why I am going to continue using ruby, read on, but I don’t think anyone should criticize rails without having developed in it.

The probjects I have done in Java have been a pain. I never liked the language much as it always seemed to be fighting against me. I might just hate explicitly compiling, or it could be the nature of a static typed language. I attempted to write a Java version of the memcached deamond, and did actually get parts of my code working; but I was never able to get it stable or fully working. [1] Java may be good for some crazy complex things but I havn’t found them yet, and Java is clearly not designed for web stuff. (Though it does seem to be a good middle layer language for ColdFusion to be written in.)

Steady readers will know that am now doing web development in Python for various reasons. I have been happy with the language as far as a language is concerned, and especially happy with zope page templates, and how form validation is done therein. It also seems to be a good language to work on in a team setting.

Before I get to what I like about Ruby, I’ll cover what has kept me in love of ColdFusion for many years. Pete Freitag puts it this way :

… CFML has been the king of RAD web development for the past 10 years. CFML is a language that was designed for rapid development.

He is right. ColdFusion was designed for web development and it shows. It shows clearly for me in how webservices are dealt with. The seamless integration of components and webservices was simply brilliant. Alot of other things are great in CF as well. I love mixing functional tags in with my html tags. Easy readability is a plus!!

The libraries and functions are good, and It really shines as a application for making web interfaces to existing [legacy] corprate applications by just sneaking in through the database. You don’t have to do much to get data back from the database in coldfusion, yet it is flexible enough to let you do any of a million crazy things to match up with other systems.

Those types of tasks are all enjoyable. What shows the weakness of the language is the things that a programmer (myself in this case) finds tedious. I hate creating the “simple form” type apps where It is just your standard add/edit/delete/list operations on a single table or two. These apps make you feel like a human cookie cutter.[2]

Cue Ruby from stage left

There are many advantages to the language Ruby itself. It is crazy flexible, and allows you to make additions to the language itself. (yes I know thats an odd programming concept). Jim Weirich gave an awesome talk at OSCON05 titled 10 things every java programmer should know about ruby. He clearly outlined some of the ways Ruby challenges us to think about programming, and illustrated wonderfully how it increases our ability to express programs through that language. Every example he gave (yes they were real examples) blew away the java code in simplicity and clarity of implementation.

Cue Ruby on Rails from stage right

Ruby on Rails has gotten some huge buzz recently, but it’s for good reason. Ruby on Rails makes the simple things (which require extra steps in CF) simpler than you could have imagined.

In ColdFusion you generally do the following things to setup a simple Add/Edit/Delete/List type app on one ore two tables : 1) Create database table(s) 2) Create an Add form, 3) do serverside validation, 4) write sql to insert into database 5) create list page 6) create search page 7) create search sql 8) create edit page 9) create update sql 10) create delete sql

Those are the steps. yes all 10 of them. What’s hard to realize though is that almost 90% of the work is just plugging in the field names into the database. Users hate it, and rightfully so, when they have to re-enter data more than once, it’s about time programmers start thinking the same way.

In Ruby on Rails all the add/edit/delete/list pages are generated by your the columns in your database. Wow isn’t that nice. Yes the framework dictates database design, and you might end up with long column names, but they are gauranteed to be descriptive. Note that this is also exactly why Ruby on Rails will never work for many of the things people do in ColdFusion :sometimes you can’t dictate the database structure. But when you can ColdFusion has a ways to go in automagically doing the rest.

The following steps are what you need to do in Ruby On Rails: 1) Create database table(s), 2) Generate scaffolding – more on that later 3) Generate search form.

Thats it, you don’t have to create sql statements for all the simple stuff, and you don’t have to create the forms (Assuming you actually use descriptive column names. Forget abbreviations, just use the real name)

Cookie cutter no more, Ruby on Rails to the rescue

So what is that scaffolding stuff? Scaffolding is just the part of Ruby on Rails which does the cookie cutting for you.

Not that rails isn’t without it’s quirks or problems or difficulties in learning curve. It has those, but now I can actually enjoy writing simple applications because of what the application does, not dread what I need to do to get it working.

Footnotes

1 : Should you care to fix/finish my java memcached app, drop me a line

2 : ColdFusion frameworks like fusebox may help. (that is what I’m actually advocating) I really don’t have any experience with the frameworks that exist with coldfusion. I acknowledge this and hopefully will be able to rectify this.

12 Responses

  1. #1 ike
    4 years, 11 months ago

    You might want to have a look at the Power onTap presentation for the onTap framework. I know you mentioned in your footnotes that you’re hoping to improve your knowledge of ColdFusion frameworks. While I’ll admit it’s not perfect, there are a lot of similarities between the onTap framework (particularly the XHTML tools) and Ruby on Rails.

    I started working on these before hearing about Ruby and I opted not to dictate any of the database structure which of course eliminates some of the automation, although much of the automation is there. I still write forms, but when I write my forms, most of the validation is automated, as well as the values of the input elements, so I never have to write value=”#htmleditformat(attributes.myfield)#” because the framework already does that for me.

    Here’s the demonstration:
    http://www.fusiontap.com/docs/index.cfm?netaction=articles&article=200

    The first half is overview and slides — the last half is demonstration of working code.

  2. #2 jehiah
    4 years, 11 months ago

    Hey Ike, thanks for the feedback. It does look like a framework I will have to check out.

  3. #3 Marlon
    4 years, 11 months ago

    I’ve been playing around with RoR for a couple of weeks, and as a longtime CF developer (since ver 3) I’m always comparing and contrasting them.

    Things that I’ve found that are missing from RoR is Application & Server level variables, easy query caching, win32 based server support.

    I’ll keep playing around with it, maybe I’ll find the replacement to these things.

  4. #4 Simon WJ
    4 years, 8 months ago

    Have you seen this – ColdFusion on Wheels

    http://www.cube6media.com/weblog/entry/2005/11/14/coldfusion-on-wheels

  5. #5 Adrian Gonzales
    4 years, 6 months ago

    You’re very right about the tedious normal tasks. Even with ColdFusion’s simplicity and ease, normal everyday applications grind you down.

    I am a major supporter of ColdFusion, but RoR is starting to get my attention. Thanks for the nudge in that direction.

  6. #6 Syeda Uzma Gardazi
    4 years, 4 months ago
    1. Evaluation of Ruby language based on syntactic structure, i.e. evaluate the Ruby language with respect to all syntactic goals, readability, write-ability etc.

    2. Write different bindings in the Ruby language. Elaborate Ruby Language design time bindings and storage bindings in detail. Give examples with each.
      Can any one can guide me in this reference where i can find this material on web/book.
      regards,
      Syeda Uzma Gardazi

  7. #7 Sam Naqvi
    4 years, 4 months ago

    Ruby language evaluation can be obtained from ask. furthermore the bindings in ruby are determined by the interpretation of the language, but not limited to the class (or varialbe) evaluation time. This allows for less distinct binding times and more power being each limited bind that is present as multiple constructs and syntactic stuff has to be binded in a single pass,as ruby IS a single pass interpreted language.
    The design time bindings would obviously be the object and builtin variable type bindings, however the

  8. #8 Joe Seeley
    4 years, 4 months ago

    Ruby on Rails does not dictate the database design, otherwise it would only be able to support new or completely redesigned applications. It should really be looked at more in the perspective that Rails “strongly suggests” a specific database design. There are many things in Rails that you get for free through reflection and introspection that rely on you using Rails preferred way of designing the database, however there are ways to override this default behavior for legacy databases.

  9. #9 TiM
    4 years, 2 months ago

    Wow, could’nt agree more. Having developed with Coldfusion for the past two years or so I can testify to both my love and hate for coldfusion. For example, the cfquery tag. Ugh, simple to get going but you end up creating mountains of CRUD, granted there are now one or two libraries for working in a manner similar to Active Record but still. Too much glue code to stitch up your model to your view’s among other tedious things. RAD, yeah… assuming you can type fast, hahah.

    Rails isn’t perfect (yet). Unobtrusive Javascript, client side validation for example you will have to roll your own or use experimental code but it’s a sweet framework where minimal code is in. I’ll still keep Coldfusion in my backpocket tho ;)

  10. #10 Dave Honsvick
    3 years, 7 months ago

    There is something special about any framework that brings the MVC paradyne to the table. Its just clean.

  11. #11 James Allen
    3 years, 4 months ago

    Interesting article although I’m not sure about this part:

    “Those types of tasks are all enjoyable. What shows the weakness of the language is the things that a programmer (myself in this case) finds tedious. I hate creating the “simple form” type apps where It is just your standard add/edit/delete/list operations on a single table or two. These apps make you feel like a human cookie cutter.[2]“

    I got sick of just those operations when building admin backend’s and frontend forms years ago..
    So, the solution? I built an admin builder module that takes care of building the forms and updating / inserting records automatically. It then makes creating new admins a 10 minute task – rather than 3 hours worth of work. I’ve been developing this module with new ‘knowledge’ for the past 4 years.

    I do the same for a frontend form builder. Super easy to add new forms to any site with minimal code.

    Surely, as we all develop in our chosen language we refine our skills and find ways to speed up development with libraries, tags and components? I know I do.

    I may take a look at Ruby, although I’m finding Coldfusion continues to blow me away with it’s sheer power and ease of use.

    Jehiah, this blog doesn’t work right in IE 7. The comments text go down in font size until you can’t read any of them.

  12. #12 ike
    2 years, 6 months ago

    Hey, just came across this article again today… Wanted to mention briefly that I released version 3 of the onTap framework recently, but that it’s moved at least for now to http://ontap.riaforge.org. The primary domain for the project is on hiatus.