she swears <i>geek</i> is a term of endearment

Setting the Active Record straight

June 19th, 2008 Rusty

I was asked yesterday whether my new site, beta.ockhamresearch.com, was developed using Ruby on Rails.  In a very indirect way, sort of.  Ok, no, not at all!  Its Asp.Net MVC

Mvc stands for Model View Controller, a popular design pattern for modern website architecture.  I feel it is significantly more productive and effective than the page-centric architecture you find as the default in most web programming languages.  Ruby’s first popular website platform was Ruby on Rails.  There were other MVC implementations out there already for platforms such as Java and Smalltalk.  However, Rails maid it intuitive, productive and even fun.  This led other programmers to favor the pattern for developing websites (such as myself) and led to the development of Castle Monorail in dot net and other variants as well as on other platforms.  Many of these were ports of Rails for folks who weren’t able to use Ruby as their target language for one reason or another.  I had been using Monorail for some time when Microsoft announced the development of Asp.Net MVC.  Microsoft isn’t well-known for open development initiatives and often does things the Microsoft way rather than the conventional way.  The Microsoft Asp.Net team deserves much credit for the current quality of Asp.Net MVC and the integration of tremendous community feedback. 

Why not just use Rails?

Competency

I have very little experience with Ruby.  When I need to write some Ruby code, I need to look up each construct and find examples to work from.  I can code C# in the woods on the trunk of a tree.  Of course, compiling it would be a challenge.

Confidence

I know where Asp.Net and SQL Server limitations are and that the platform can achieve high performance.  I know that Ruby has known performance issues and no roadmap for reconciling these issues.  I’d rather not be the person responsible for overcoming performance issues on a production web server farm when we have paying clients expecting service.  If I can run a commercially supported platform with current licenses and support contracts, I have someone to lean on if anything goes wrong.  Furthermore, I can fix almost anything on Windows but my experience with Linux is feeble.  I aim to change that but, for now, I can provide confidence to my constituents that my web app will not fail due to memory leaks or unusual bugs that are not a result of my code.  Yes, there will definitely be errors in our future but using NUnit, Cruisecontrol.Net, WatiN, Visual Studio.Net and SQL Server will minimize the risk to a more than acceptable level.  I don’t know where to turn for the same thing in Rails.

Community

This is the most important factor.  The above two points are true for all the programmers I’ve worked with over more than the last decadeWe’re all very familiar and invested in Microsoft technologies.  There is no reason to switch if the features are available and productivity is commensurate with alternatives.  If I need help modifying some code because I have too much to do myself or we have an awesome contract pending, I don’t want to be searching in a small pond for good people. For every good programmer, there are a hundred terrible ones that will make a mess of my beautiful code :)  I can’t have that. 

Why Use Rails at All?

I can’t find current data that indicates the trend for what programmers are using but I can tell you my gut feelings and personal observations.  No community growth, in my technology career, has struck me with as much fervor and excitement as the Ruby and Rails explosion has.  These people aren’t Windows haters like Java programmers were.  They aren’t choosing Ruby because that’s where the jobs are (yet).  They are choosing Ruby because they get hooked!  They love working with it.  More often than not, a Ruby programmer dresses hip, is very laid back, uses a Mac, drives a Hybrid.  These are all traits of people with both time and money.  I want more time and money and would like to be hip.  However, I still prefer to burn more gas in exchange for fast times to sixty.  Glutinous, I know.

When do you switch?

Rails still needs to be proven in the enterprise.  My prediction is that this will happen in 2008.  Sites using Ruby on Rails will publish numbers and costs of operation that make it a very attractive alternative to the company standard.  The best place to try Ruby is on a new, small scoped project with just a few very close end users in a highly agile environment.  Don’t be silly and just announce that you are now Ruby and expect all your devs to just pick it up.  On the other hand, it would be a good idea to get some very intense training for your old school programmers (if you have them) because they are accustomed to working within the constraints of their strongly typed, compiled, high performance environment and will not naturally make the appropriate transitions necessary to achieve success, maintainability and scalability in a Rails environment.  Ask yourself if your compiled apps (yes, Asp.Net is compiled) are as fast as they should be and then ask yourself whether your app will still be acceptable at 50% of that speed.  On the other hand, if you have 80% of your hardware capacity remaining, you can probably virtualize and take advantage of your current infrastructure with very little cost.

Try it on like deodorant.  Give it a few days and try a few different activities and then ask your wife if your pits stink.  If not, take it a little further.

DotNet Junky on Ruby Exploration - chapter 3

November 26th, 2007 Rusty

History of Vous Ruby

I’ve investigated Ruby several times. I’ve gone through the online Ruby tutorials and installed Instant Ruby (no longer supported, replaced with Bitnami RubyStack). My first real ruby experiment was to try to create an object-based text file parser to open a text file, look for a reg ex pattern, replace it, then save the file. Sounds simple enough? I was able to get 80% of the way there with very little code. In fact, I did this in iRuby (interactive commanline where you define classes as you go). This was compelling because I can’t imagine doing this in c# without a compiler… Oh yeah, its compiled, need compiler. However, I reached an abstacle as I tried to interact with the filesystem and wasn’t satisfied with the accessibility of documentation while I Googled for solutions. I finally completed my task in c# using TestDriven.net as my execution interface. TestDriven.net, by the way, wins tool plug-in of the decade award for all the benefits its brought me.

As the World Turns (Ruby)

I quickly returned to the warm bossom of my Visual Studio IDE and the C# language. However, the Ruby on Rails 15 Minute Intro kept on haunting me, asking me whether I really needed stored procedures, parameter lengths, data readers, streams, request objects, page lifecycle, etc. It’s not that these things don’t have their place but I couldn’t help but feel as though the cutting and pasting I was doing to create data access and user controls wasn’t somehow repetative. DRY?

Rails for Microsoft Junkies

So I love C# but I wanted to experiment with rails. Monorail, y’all!

I started there. The first thing I discovered was how easy simple things were. That sounds pretty trivial but sometimes I am astounded by how much crap I have to add to get data to a page in Asp.Net without violating every principle of good software design ever captured in a UML diagram. Data in the presentation tier just makes me feel dirty, I can’t sleep at night, I can’t eat. I just won’t do it. Even DataTables eak me out. Strongly-typed datasets? Who thought it was a good idea to take something dynamic and unstructured and compile the ugly thing? Intellisense, I know. I am addicted to it, too.

Of course, monorail is a gateway drug. I used monorail with Active Record to create a simple website. When I defined my business classes and used them exclusively to bring data to the view, I was excited. Then I genereated the schema for the first time. It was a dirty chunk of code in global.asax but it generated a database that was compeltely prepped for persisting every class I’d defined with no more than simple attributes. WOW!

Of course, I am a control freak and didn’t like the 1 to 1 requirement of Active Record so I learned about NHibernate. Many months later, and a significant amount of trial and error, not to mention a significant repository infrastruture, plus tremendous development and advancement by Mr. Rick Caldwell, and we now have abandoned our previous belief that all data accessmust use stored procedures and that ORM was for lazy programmers. It rocks. I LOVE database modeling. It is downright orgasmic to design your class structure according to your domain model and then generate a database schema that perfectly matches the normalized data model that you would have coded if you were required to do that by hand. Watching the sql in Log4Net is also quite entertaining and rewarding. Being able to focus entirely on the business domain and not worry very much about data access is just efficient.

Back on the Rails

For a period of time, rails was shelved in favor of asp.net using NHibernate. Recently I spoke with Mark Jones (blog link forthcoming) and he helped reinforce my belief that there is something very exciting happening on the Ruby side of the world.

He was excited about the Monorail possibilities and inspired me to explore the framework further. I dug into the ajax helpers and compared ashx handlers with controller actions and found it truly a pleasurable way to create a website. It almost forces you into good design. MVC frameworks encourage you to separate concerns. A little good practice and inversion of control is as simple as a one line code change (load from config rather than in code).

…and back to Ruby

I have been excited about a ruby port to dotnet so there must be something in that Ruby community that fosters creativity and innovation.

I am installing the RubyStack now and will begin my now far more enlightened adventure through the language. I now understand that you don’t need to compile ruby, you execute the ruby.exe commandline runtime. It will launch whatever components you need for your app. I can’t tell you how long I’ve been confused as to how exactly to execute my ruby app without visual studio. Where is F5?

I’ll keep you posted