On Rails, Sinatra, and picking the right tool for the job. Pedro Belo, of Heroku fame, finds Rails is way better for pure-web apps and Sinatra is way better for pure-API apps. Most of it comes down to Rails has better tooling and Sinatra is better for scratching itches, which happens a lot more in APIs than applications. I’m not ready to pronounce this the final word, but what he’s saying lines up with much of my experience.
That said, you can get pretty far with a Rails API by segregating it from your application. That is, your app controllers inherit from ApplicationController
and your API controllers inherit from ApiController
. This keeps the often wildly different needs of applications and APIs nice and distinct.
Interesting discussion. Sadly, sufficiently complicated API projects can wind up dragging in pieces of Rails module by module.
Kind of reminds me of this quote: “Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.”
I see what you’re saying, but I’d love to know more. Which modules? Is it unavoidable, or as a shortcut?
ActiveSupport, ActiveRecord/Migrations (your mileage may vary), something for emails (but maybe not ActionMailer).
Ahh, so all familiar things orthogonal to Sinatra. Into every application, dependencies must fall.