My Experiences with Ruby off Rails

Ruby Off Rails

I was recently pointed to Ben Singelman’s post on Why Nobody Should Use Rails For Anything, Ever.

We seem to never get enough of arguing about application frameworks: I’m not going to do that. What irks me is when Ruby get thrown out with the Rails bathwater. As one commenter on Singleman’s post demonstrates:

“Interesting perspective. I agree on your general points — Ruby’s fine at an MVP stage I think, but when it comes to creating something for market, it just falls over.”

(This despite the second sentence of the post stating “Independent of ruby, I see Rails as the emperor with no clothes on.”)

I see posts like this a lot. It’s an opinion piece — the goal is to sway the reader to have the same opinion. Like many similar posts, the title is hyperbolic, the conclusion a tad more pragmatic. Which is fine. I read it because we write a lot of web apps at Atomic, and we frequently choose Rails. I wasn’t reading to learn facts about Rails, and I wasn’t disappointed. But it did get me thinking about my time with Ruby: most of it was not using Rails.

Don’t pick on Ruby just because you don’t like Rails

Despite making use of Ruby since 2004, I’ve never personally written a Rails app for a customer.

I was an early advocate for Rails, discovering it in 2005 and attending RailsConf in 2007. I’ve built Rails apps occasionally in my spare time, for my own use, mostly to keep up with major changes since 1.x days. I helped estimate a project that was eventually written with Rails. I’ve helped upgrade and maintain a few apps that we use internally at Atomic (and even some we sold as pre-packaged CMS-a-likes, circa 2005.) I’ve written many web apps (at least a handful that used Sinatra) and a lot of Ruby apps.

On my current project, we sort of tried to use Rails but ended up using just the asset pipeline to make an Ember app backed by a Grape API. (Our app/models directory still has a .gitkeep in it.) Rails just wound up being marginal and superseded by other, more loosely-coupled components.

Today I wouldn’t reach for Rails as my first choice in writing a web app either, although maybe not for the same reasons as the article above. But I love using Ruby.

Language and framework wars aside, there are many other ways to make Ruby useful

I usually recommend people who are steering towards Rails to try using it with JRuby first, as supported by a relevant opinion in the Hacker News discussion for Ben’s post.

That detail aside, here are some of the more diverse examples where I’ve used Ruby that didn’t involve Rails:

  • A scrappy SQL Server scripting tool using Ruby 1.8.0, ODBC, and Cygwin. Yay “scripting languages”!
  • A business rules engine running inside a Java app on a big enterprise J2EE container. JRuby and Cucumber were critically useful here.
  • A couple of JRuby/Swing/SVG desktop applications with complex graphical simulation interfaces
  • Sinatra web app using Sequel for a medical industry customer. (I think it was later converted to Rails… C’est la vie!)
  • A make-like build system for a large C++ project on Mac OS X, Linux, and Windows. This was before Rake was very useful…
  • An iPad app using ReactiveCocoa and… RubyMotion!
  • A system test suite for a pure-Javascript app—using Celerity
  • Routing the status of an internal continuous integration system to a giant MDOT traffic light hanging in our office
  • Messing with cross-platform 2D games in my spare time

Even with so many exciting alternatives I still use Ruby today. It’s a wonderful tool but remember that Rails isn’t the only way to wield it!

 

Conversation
  • Giant Elk says:

    So what would you recommend for anyone that wants to slap together a prototype of a client-server web app/site? Stay away from Rails? I’m looking at Angular.js and Dart, and see people using both with Rails, but why and where still eludes me.

    • Karlin Fox says:

      Hi,

      My honest first answer is to use Sinatra if it’s a prototype. Everything else you’ll need to provide data to your Angular/Dart clients can be bolted on as you go from prototype to production. Another alternative I’ve used is Grape, which helps orient you towards a service layer instead of just bare Rack handler methods.

      At Atomic, we do a lot of prototyping in Middleman, which I can also recommend. They have a great community, and some useful templates that are great for bootstrapping a quick prototype: http://directory.middlemanapp.com/#/templates/all

      All of these tools are not going to lock your prototype down so much that you can’t switch to Rails later if you need it. If you’re doing a web app and you like Ruby, there’s really nothing wrong with Rails, this post is just pointing out that there are many other great ways to use Ruby. As I mentioned in the post, I’ve even used a bare Rails app as a placeholder and asset pipeline before, without writing and Rails MVC code at all!

      Cheers,
      Karlin

      • Giant Elk says:

        Hi Karlin,

        Why did you convert your medical customers web app from Sinatra to Rails? I mean, if you like Sinatra better than Rails, what were the reasons? Was it for the MVC in Rails (I read on Wikipedia Sinatra is NOT MVC)? I keep reading about Rails poor scalability, and that the big sites (i.e. Twitter) rip out the back end and only use it for Views.

        I chose Rails due to the amount of books and blogs to get help, I figured Rails is going to get better if people keep using it more than other frameworks (I know there’s no guarantees). Yet Rails is still a big learning curve (at least for me), and I need an app that can scale huge, think Facebook huge, but just need to start off with something to get going. My issue is it’s a matter of not wanting to learn a new framework to grow beyond the prototype ver1.0, I want to pick a stack that will grow if/when my project takes off, so I don’t have to re-invent the wheel. I know I ask a lot :-)

        I’ve read a few blogs where guys scrapped Rails and went with Angular and Node.js, I don’t know enough about Node.js, but it seems like you’d have to write your own SQL queries to access the database, where Rails makes that super easy with it’s Models and Controllers.

        Here’s a good discussion on Dart vs Angular:
        https://plus.google.com/104771776404197897488/posts/6NHqfT8xvYM

        btw – here’s my blog post, Messy Web:
        http://giantelk.wordpress.com/2013/09/07/messy-web-angular-js-ruby-on-rails-dart-gwt-almost-forgot-closure/

        Cheers & thanks for the great answers!

  • James OKelly says:

    I’ll chime in here, as this is an excellent point.

    Ruby is my love. I get paid to do a lot of Rails, because Rails is what made Ruby commercially successful in the US. However, the #1 thing I fix time and time again, is to move a “Rails” site to a “Ruby” codebase that is used in a rails application.

    Ruby is king. Modules, dynamic typing, anon classes and methods, lambdas, mixin inheritance and parental inheritance, meta programming and inspection, functional methods in stlib, enumerators, and the ability to write concurrent multi-core applications are just a few of the reasons why.

    However you have to KNOW HOW TO RUBY, or you just end up writing kiddie scripts. This is why most “Rails developers” suck. You have to become a ruby craftsman if you want to develop good ruby based code. You can’t just “Rails” it and be done.

    Rails, however, is awesome. For what it is. But if you don’t write your business logic in ruby, write a complete test suite, and stick to golden path rails shit, you will end up with a messy pile of steaming yumminess.

    Sinatra is awesome and slick and small, and will teach you better ruby habits then rails, but all sinatra apps that need more features become a rails app. (Or you build a small army of single purpose sinatra apps)

    But again, Ruby is king.

  • Matt says:

    I believe what we’re seeing is the productisation of programming environments (languages, frameworks, libraries) and Ruby on Rails is leading the way. Companies has been looking for Ruby on Rails development (not Ruby developers) for years now, blind to the fact that a Ruby developer can pick up Rails quicker that a so-called Rails developer can truly master Ruby.

    A similar phenomenon is happening in the mobile world—iOS developers are in very high demand and someone marketing themselves as an Objective-C developer might struggle in the market unless they find a company which can appreciate the distinction.

    Some of the best developers I’ve had the privilege to work with learnt Ruby first and I wish more people would go off Rails first.

  • jruby says:

    JRuby?

    A file with nothing more than sleep 100 in it takes 200MB of RAM

    What a joke

  • Comments are closed.