3

If I learn Sinatra or Padrino, does that help me with Ruby on Rails?

I assume that for all of these I need to get a better understanding of Ruby itself, but does (say) Padrino translate directly into skills I would use in Ruby on Rails or is it indirect?

I am a PHP programmer, but, as I have used PHP frameworks which are clones of Ruby on Rails, I am finding it not too difficult.

Community
  • 1
  • 1
PurplePilot
  • 6,652
  • 7
  • 36
  • 42
  • Well when i first ran rails i was gobsmacked at the structure it built and if anything somewhat offended that an application would do that for me. However after using Symphony and Zend (and gaining experience and retaining the lessons learnt) the standard layout suits me fine. But if anything Rails/Sinatra/Padrino have a lo more "helpers" than in PHP so there is less to write but maybe more to know? – PurplePilot Sep 24 '10 at 16:09

8 Answers8

6

You can't skip the step to learn Ruby, because every Ruby MVC extend it, and if you have to do some important customization/optimization you'll do it in Ruby.

My advice is to learn a Ruby base (variables, blocks, modules, hashes,..), use Ruby on Rails in the real world, learn Rack and then choose the best "pieces" of the Ruby world that suit your needs.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
grigio
  • 167
  • 11
  • Rack? (the extra words to allow a short comment to be posted) – PurplePilot Sep 26 '10 at 21:43
  • 1
    Rack is a middleware shared among ruby frameworks, it means that some kinds on interactions can be done in a lower level and shared among ruby frameworks. To understand better the pieces of Rails3 see http://www.slideshare.net/wycats/rails-3-dashing-to-the-finish and http://github.com/rack/rack-contrib for rack – grigio Sep 26 '10 at 22:43
5

This might be a more controversial opinion, and I'll admit to being new to both still, but as someone who just spent a week on Sinatra and then moved on to Rails, I would recommend going straight for Rails. Initially, it will seem like there's a lot more to learn about Rails, but if you're going to write something moderately complex, you're going to move to Rails eventually, and it's less work 'unlearning' from Rails what you need to write a Sinatra app than it is to relearn things to do it the Rails way. You save yourself the pain of having to shift gears when it turns out that your project you started in Sinatra was best done in Rails after all (which happened to me).

This does mean it's going to take a little longer to get up to speed on Rails. I recommend starting with Michael Hartl's tutorial and the official guides. However, my advice is specifically geared towards existing developers who already know how to develop web apps and are more likely to have more complex projects in mind than beginners. Someone brand new to web app design may very well appreciate the immediate gratification that building a basic Sinatra app will offer, but that doesn't seem to be you.

Experienced developers will probably argue that you can definitely write 'moderately complex' apps in Sinatra too, and they will be right. I think Sinatra's strengths are in being a fallback for experienced developers who want to knock out a quick app without Rails 'overhead', and not as an introduction to Ruby/Rails based web app development.

Joost Schuur
  • 4,417
  • 2
  • 24
  • 39
  • Thanks. As a supplementary question i nearly asked, but it was a bit fuzzy, was how soon do you run out of steam on Sinatra and Padrino and need to go to the full Rails? And think you answered this in that experienced Rails devs can use the S and P tools to perhaps Proof of Concept without the full Rails baggage and then 'upgrade' with Rails????? – PurplePilot Sep 25 '10 at 06:40
  • 1
    Me moving on to Rails had more to do with me realizing that eventually I would want to learn full blown Rails than hitting an immediate technical limit. I was quickly creating a number of different views, subdividing my code into different individual files that the main file included and at 15 files, started to wonder why I wasn't just using full blown Rails, when a 3 day old project already branched out this much. Sinatra just appeared too lean for the job, especially after I saw that the main .rb files for it were barely 75k in size. – Joost Schuur Sep 25 '10 at 07:15
  • 1
    I think an experienced developer would have a better feel for what tools is suitable for what app and pick the right one before they started, so they wouldn't have to switch from Padrino or Sinatra to Rails later. – Joost Schuur Sep 25 '10 at 07:17
  • Sinatra, and to a lesser extent Padrino, are a little closer to the metal - I think getting comfortable with Rails will make you want to see other ways of doing things, or sometimes even feel constrictive. Then you'll go looking for stuff like Sinatra, more freedom, less hand-holding.. – craigp Feb 25 '11 at 19:26
4

Padrino is based on Sinatra, which in turns is based on Rack which is also the same ruby web server interface implemented in Rails. So yes, they have some common features, but no, learning Sinatra won't help you much in learning Rails if you don't learn Ruby before.

If you have used web frameworks before you are already familiar with MVC, templates and models. What you need to know now is the framework specific syntax so you need to work directly with the framework you want to learn.

Rails and Sinatra shares some common principles and habits which belongs to the Ruby ecosystem. But you would need to learn Ruby before in order to better appreciate these frameworks.

Don't assume the "learning Ruby" step to be an optional task.

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
  • Thanks, initially i thought i could 'avoid' Ruby but with what i have done so far i can see it is integral not only for the actual coding but for the 'Ruby Way' concepts as well – PurplePilot Sep 24 '10 at 16:20
  • 4
    Trying to work in Sinatra or Rails without knowing Ruby would be extremely difficult. All you could really do is generate basic erb or HAML templates and maybe write basic routes. Moving beyond the basics would require understanding how Ruby handles loops, variables, how to create classes, talking to databases or reading files, etc. Once you know Ruby you'll see how it influences Sinatra and Rails and things that were confusing will become clear. I tried to learn Rails without knowing Ruby, and it was really confusing until my Ruby knowledge improved. – the Tin Man Sep 24 '10 at 21:09
2

Rails => Ruby => Sinatra => Rails

I did Rails + Bootstrap first, and while my deliverable at the end was really glossy, my ability to customize and upgrade was really shaky and REALLY REALLY slow. From there I moved onto the Ruby language syntax, some _why books and whatnot, and that sort of had me making sense of some things that initially just appeared as "magic bullets." After some time spent with Ruby I picked around at Sinatra, which was really fun. Sinatra made it possible to push a local server with a fully functioning webpage with a single page of code! It made it possible for me to experiment with databases and datamapper in a very intimate way. Currently I've shifted back to Rails, and things like scaffolding, model generation, controller generation, etc... these things are magic in a totally different way now. So I say:

  1. Rails

  2. Ruby Syntax

  3. Sinatra

  4. Rails

Rinse, Repeat...

EliCash
  • 95
  • 1
  • 9
1

Lean Sinatra, then Rails.

Rails has a lot of built in "magic" which means you don't really need to know HOW anything is working to get it up and running.

Next, when you decided to pick up Rails, you will have a better understanding of what is actually happening. The "magic" still exists; you just have a better understanding of how its doing its thing. This way if something breaks, you'll have a better understanding of how to fix it.

Good luck!

user3245240
  • 265
  • 4
  • 10
1

I don't think Rails is a guaranteed final destination for a web developer using Ruby (though it is likely (: ). I worked with a software company that used Ruby and not rails for the web application. I started down a similar path as you (PHP). I wanted to develop using Ruby and began looking at Rails but found it pretty daunting. I started learning basic Ruby stuff and early in that process I discovered Sinatra. I loved it from the start. Learning using Sinatra allowed me to piece by piece add in various gems like an ORM or authentication and see how they worked individually. There are way less "moving parts" in an early stage app using Sinatra and for me that was preferred. I interact with a lot of Rails guys and from all I gather from our conversations I think it would be quite painless for me to develop a project using Rails now.

So my two cents is that for some people, learning Sinatra first may prove very helpful. But different people learn differently, so I don't think there is a one size fits all answer to this question.

wuliwong
  • 4,238
  • 9
  • 41
  • 69
0

Just wanted to add my opinion that yes, learning Sinatra or Padrino will definitely help you learn Rails. In the sense that it will make the transition from PHP (or whatever) to Rails a lot less daunting. As wuliwong said, Sinatra and Padrino are way less complex than Rails. In fact, Rails is too complex for its own good in my personal opinion, routing in Rails is a bit of a nightmare, but let's not get sidetracked.

Also, while it is true that you cannot learn Rails without learning Ruby, there is no reason whatsoever why you couldn't learn Ruby as you lear Rails (or Sinatra/Padrino), it's a fun way to learn the language.

I started with Rails directly, with no knowledge of Ruby at all, coming from PHP. Did a lot of the tutorials out there, bought a few books and kept slogging on. After about 7 months of work with Rails I moved to Padrino to build an API and immediately loved its simplicity compared to Rails.

Once you get good, Rails has a lot of high-end magic that is awesome, but while you're starting out it's very overwhelming. Sinatra/Padrino allow you to start out smaller, easier and keep adding.

Good luck!

kakubei
  • 5,321
  • 4
  • 44
  • 66
0

If you want to learn rails a good way is to follow the road map that is mapped out on this blog post. It is what I used and it was a great start. Obviously if you already know PHP there are steps that you can most likely skip, but overall it is a really good approach to taking little steps towards learning rails http://techiferous.com/2010/07/roadmap-for-learning-rails/

Danish Khan
  • 1,230
  • 1
  • 10
  • 13