Live data from Hacker News

Why critics of Rails have it all wrong (and Ruby's bright multicore future)

unlimitednovelty.com

21–30 of 127 posts

Re: Why critics of Rails have it all wrong (and Ruby's bright multicore future)

#21
post #5

"Rails is great for JSON APIs" Rails is good for simple APIs (especially adding an API to an existing HTML site). However, if you want to do more than that, elegantly - it isn't great yet. You quickly end up with some fairly messy serialization hacks and confusion between what should sit in the controller and the model. The active_model_serializers gem is a really good start, but there is a way to go to get to the le…

Use decorators. Draper is my personal favorite, and it very cleanly solves the issue of serialization nightmares and controller/model confusion.

(I hope that it ends up in the Rails core someday, because it really is a gamechanger in how Rails is used for non-HTML content!)

Re: Why critics of Rails have it all wrong (and Ruby's bright multicore future)

#23
post #5

"Rails is great for JSON APIs" Rails is good for simple APIs (especially adding an API to an existing HTML site). However, if you want to do more than that, elegantly - it isn't great yet. You quickly end up with some fairly messy serialization hacks and confusion between what should sit in the controller and the model. The active_model_serializers gem is a really good start, but there is a way to go to get to the le…

Why not use a format-specific DSL, like DHH does with jbuilder? That's not messy at all, it's basically just another TemplateHandler.

Or RABL if you want both XML and JSON output

Re: Why critics of Rails have it all wrong (and Ruby's bright multicore future)

#24
post #6

Earlier quoted context omitted.

Agreed, when you want to build an API use Sinatra, and when you want to do web MVC there is Padrino which turns Sinatra into a very competent MVC framework.

I really enjoy Sinatra and am indeed using it for REST style API hosting, but the counter argument might be all the security stuff that is built into the Rails routes/controllers. this might be a great case for a stripped down rails app as opposed to a Sinatra app.

I thought most of the security in Rails is provided by the rack-security middleware? Or am I forgetting something which Rails provides here?

Re: Why critics of Rails have it all wrong (and Ruby's bright multicore future)

#25
post #20

I love Ruby, but I have no love for Rails. Want to write a nice JSON API using something light and nice? Use Sinatra, pick your favorite ORM (even ActiveRecord) and go to town. Why mess with all the other Rails junk when you can have a simple app.rb for your sinatra app and just write simple little controller actions and you're good to go? You don't need all the ceremony and structure of Rails and MVC to write a JSON…

"Rails" is a collection of libraries and conventions, just as "Sinatra + ActiveRecord" is. There's nothing inherent in it that makes it "worse" than Sinatra (which I love, by the way) for JSON APIs. Use Rack, pick your favorite gems, and go to town. Why mess with all the other Sinatra junk when you can have a simple config.ru for your app and just write a simple call method and you're good to go? You don't need all t…

Sinatra has a lot less boilerplate than the typical Rack app.

Re: Why critics of Rails have it all wrong (and Ruby's bright multicore future)

#26
post #6

I love Ruby, but I have no love for Rails. Want to write a nice JSON API using something light and nice? Use Sinatra, pick your favorite ORM (even ActiveRecord) and go to town. Why mess with all the other Rails junk when you can have a simple app.rb for your sinatra app and just write simple little controller actions and you're good to go? You don't need all the ceremony and structure of Rails and MVC to write a JSON…

Agreed, when you want to build an API use Sinatra, and when you want to do web MVC there is Padrino which turns Sinatra into a very competent MVC framework.

I've used Padrino for a couple of projects now, but unfortunately it slips into "Uncanny Valley Rails" territory (particularly when it comes to the rake tasks you expect to have but turn out to be missing, eg. db:test:prepare).

Re: Why critics of Rails have it all wrong (and Ruby's bright multicore future)

#28
To pour a little cool water on this bombastic post -- I have much love and respect for Rails. We (NYT Interactive News) continue to use it for nearly everything we build that requires a server-side component.

All I was trying to say (in a direct reply to Jeff) was that I think that putting Rails on hold for 2-3 years while merging in Merb (or the Merb team, depending on how you want to look at it) wasn't, in retrospect, a wise decision.

But that's old news, and doesn't need to be re-hashed now -- it's great to see Rails 4 starting to pick the pace back up, and exploring new features like improved streaming, granular cacheing, built-in queues, and more.

Re: Why critics of Rails have it all wrong (and Ruby's bright multicore future)

#29
post #20

Earlier quoted context omitted.

"Rails" is a collection of libraries and conventions, just as "Sinatra + ActiveRecord" is. There's nothing inherent in it that makes it "worse" than Sinatra (which I love, by the way) for JSON APIs. Use Rack, pick your favorite gems, and go to town. Why mess with all the other Sinatra junk when you can have a simple config.ru for your app and just write a simple call method and you're good to go? You don't need all t…

Sinatra has a lot less boilerplate than the typical Rack app.

Because it has a lot more "ceremony and structure". Sinatra is a Rack app. It hides the raw boilerplate from you just like Rails hides a lot of the boilerplate you end up putting into a Sinatra app of any significant size.

There's a continuum of "more manual work" "more framework", and there's no one right answer, even for something like a JSON API.

Re: Why critics of Rails have it all wrong (and Ruby's bright multicore future)

#30

As far as using websockets with Rails goes, I just wanted to mention that I've been having a really good experience using the websocket-rails gem ( https://github.com/DanKnox/websocket-rails ) in a text game (MUD) I'm working on as a Rails 3 app.

That sounds amazing! When you've got this MUD on Rails going, please do submit it here. Similarly, I'm working on a MCaaS (MUD Client as a Service ;]) half tongue-in-cheek to learn more about Node. There's no feeling like using new & exciting tech to solve the problems of our neckbearded forefathers.
Post reply on HN