May 23, 2016

I've been using Rails for a decade now, across many jobs, and one thing I've experienced fairly consistently is the worst Ruby web apps I have ever dealt with are the ones that weren't written in Rails.

I've both seen and spent a lot of time rewriting overgrown Sinatra monstrosities with assorted non-AR ORMs. These apps were generally riddled with XSS since they didn't handle escaping correctly, often had unmaintainable code that sometimes was thousands of lines long crammed into a single file, and lacking any sort of basic structuring principles mixed parameter handling with business logic all over the place.

I've seen several attempts to "build a better Rails" that's "more OO", but even frameworks that solve the problems I've just described in the previous paragraph have one huge drawback: Rails is a lingua franca for web development in Ruby, and whatever incremental gains you get from having a better framework are heavily outweighed by the costs of making people learn a new framework-per-project, the lack of features and documentation, and the lack of the library ecosystem that surrounds Rails.

At points I've tried to keep three ORMs/DB libraries in my head at a time: AR, DataMapper, and Sequel, which just left me wishing I was dealing with AR (the devil you know...)

ORMs need massive feature sets to jam the proverbial square peg of relational databases through the round hole of objects, and AR is the only one I've used that's both expressive enough to cover all the cases I'm interested in and mature enough to even have a story around database concurrency, even if most Rails developers are getting database concurrency wrong with AR (e.g. http://www.bailis.org/papers/feral-sigmod2015.pdf ) At least AR has any story around things like optimistic and pessimistic locking and lets you build apps where you can read an object and persist your changes without silently clobbering another requests's database writes with your locally cached copy of stale data.

tl;dr: if you want to do web development but dislike Rails, your best bet is probably to switch to a different programming language than Ruby.