Hacker News new | ask | show | jobs
by pmontra 4372 days ago
For any project worth talking about Sinatra is too skinny. Basically you have to hack your routing in about the same way you do with Node's Express, enumerating the bindings between routes and methods. Obviously there are clever ways to do it but you end up reimplementing the resourceful routes of Rails.

Another problem is that you really want to use ActiveRecord to access the database. Anything else it too painful. So you end up creating AR models and you have to manually include them.

Finally there are views. I won't even enter into that.

Soon you end up with a worse engineered Rails. I've been using Sinatra only for serving API requests for small projects. I won't touch it for anything else.

3 comments

I've built large projects with Sinatra. I've done the same with Rails, many times. The idea that you can't build something substantial with Sinatra is hogwash.

It is not a given that Active Record -- I presume you mean the pattern -- is necessary, but AR is available in Sequel, which is the usual choice of ORM when build with Sinatra. (In addition, Sequel has myriad additional benefits over Rails' ActiveRecord, particularly if you want to use raw SQL.)

Views in Sinatra are not much different to Rails, so whatever issue you have, I'm unclear what they are.

If you end up engineering a worse Rails then, as they say, you are doing it wrong.

As I mentioned, I use both, and you can achieve the same results with either. They are both, in effect, rack stacks these days; they simply have different conventions, one more opinionated than the other.

Sinatra is the perfect REST API server language for a client application. Given the way apps are going these days, I'm not sure why everyone isn't building single-page web apps that put 90% of the responsibility on the client and use only simple JSON communications with the server for persistence or authentication.
One of the problems with always doing things the 'Rails Way' is that people start thinking there are no other ways. Plenty of people build significant apps with rich and engaging interfaces with much lighter frameworks than Sinatra even.