views:

474

answers:

7

I've been working far too long with php and getting bored with it. I also want to learn a new language. I've been using Ruby and like it. I've to decide between Rails and Sinatra, which one would you recommend? Is it true that Sinatra can't be used to build complex apps, and its only for simple apps?

+7  A: 

Go with Rails, it has a lot more documentation/books than Sinatra. It is also more "mainstream" and many IDEs treat rails in a special first-class-citizen way, so it's a good idea to start with it.
Wile one can write any kind of application on any of the two, Sinatra is designed to be more simplist, so on Sinatra a complex case app might require extra effort.

clyfe
From what I've read so far, Sinatra just gives the basics and gets out of the way, whereas Rails forces you to do things in a certain way. How true is that?
Indeed Sinatra gives the basics (routing and controlling in a simple DSL), but Rails does not "get in your way" at all, *au contraire*. And btw, a Sinatra app can be embedded in a Rails app: http://gist.github.com/81199
clyfe
does this mean, that I cannot use Sinatra for complex projects?
You *can* use Sinatra for for complex projects, but the effort would be slightly higher than in Rails, in this case. NB Once you know Rails you'll understand Sinatra very fast, but viceversa is a little harder.
clyfe
higher effort doesn't matter, if it gives me flexibility to do things my way.
I strongly advise you to learn Rails. After Sinatra will be a breeze. Then you can decide for yourself what suits you. When I started rails I saw that "rails way" was better than "my way", I agreed it's patterns instantly and it gave me a lot of insight. It might be the same for you.
clyfe
+2  A: 

you should definitely know both, because they were made for different purposes. sinatra is a micro-framework for small applications. rails is a full-blown mvc-framework with lots of helpers for almost everything.

i would say sinatra is easier to learn if you know ruby, because it's very small and follows common ruby idioms. but it's not much more difficult to learn rails as well. the documentation is great and you will find lots of tutorials and howto's on the web.

as i said, it's really good to know both so you can pick the right tool for the job.

rubiii
+7  A: 

If you are a "very newbie" with Ruby maybe you should approach Sinatra first: it's really small, well documented and easy to learn. Than, for more complex web applications, you should try RubyOnRails.

Here you can find an introductory article I've wrote for Rails Magazine (FREE pdf): http://railsmagazine.com/issues/5

Enjoy! ;)

Carlo Pecchia
+2  A: 

First go with Sinatra. It is really simple and easy to understand, plus it covers the basic principles of Rails (MVC architecture, etc). Then, you can move onto Rails. Plus, with your Sinatra knowledge, you can write Sinatra apps in Rails metal, which can make it easy to create APIs.

Ethan Turkeltaub
A: 

You might want to look at Ramaze in addition to or instead of Sinatra. Ramaze seems to sit between Ruby on Rails and Sinatra as far as features and usablility.

Greg
oh, now I am even more confused...I have to choose between three, instead of two :(
+1  A: 

Oh please Oh please don't start with rails. It's like going into battle for the first time against a Panzer division. Better to start with some restless natives and work your way up. Okay that's not a great analogy but rails is big time overkill for learning. You can pick up Sinatra very quickly and then migrating to rails is a reasonable step up. Same stuff just more useful things. With rails there is at ton of confusing things. They add lots of stuff onto the language, etc. If you don't know Ruby and the foundation classes then just do Sinatra. It's fast, easy and you don't have to learn about migrations, rake, etc.

John Baker
A: 

Either Rails or Sinatra is a great learning choice.

I began working on a project in Rails where I literally knew nothing of web development or Ruby last October (my cofounder helped me break though some initial hurdles and got me to RTFM). I ran into some problems but could code up business logic fairly easily. Recently I began porting a project over to the app engine and using Sinatra as a framework and it's been an incredible learning process. Mostly for learning about all the things that Rails did automatically. It also was useful for seeing a simplified definition of class members and their persistence method (migrations are unfortunately a pita though, background processes to change the format).

You may wish to consider where you will deploy.

Since I'm primarily interested in straight forward apps at a low server cost both Heroku and the Google App Engine fit well. Rails/ActiveRecord/Sqlite and Heroku works swell Sinatra/Datamapper/Datastore on the Google App engine flow well.

Rails is also successfully running on the app engine so this choice is open too. IMO Heroku's a little easier to deploy to.

Mark Essel