Rails or Sinatra? Which is good to start learning for a PHP programmer? [closed]
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 have to decide between Rails and Sinatra, so which one would you recommend? Is it true that Sinatra can't be used to build complex apps, and it's only for simple apps?
If you are a "very newbie" with Ruby maybe you should approach Sinatra first: it's really small, well documented and easy to learn. Then, for more complex web applications, you should try Ruby On Rails.
http://railsmagazine.com/issues/5 is a free PDF introductory article I wrote for Rails Magazine.
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.
While 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.
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.
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.
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.
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 October 2009 (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.
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.
精彩评论