views:

474

answers:

13

i know nothing about ruby but a lot about php.

when you code in ror...do you actually understand what is going on under the surface if you are a beginner? and do you HAVE TO understand it or is it good enough just to know enough to build something fast?

Looking for experiences from people who have made the transition.

+3  A: 

You'd be alright if you picked up "Agile Web Development with Rails" - http://www.pragprog.com/titles/rails3/agile-web-development-with-rails-third-edition

Eric the Red
+5  A: 

I would also suggest picking up a copy of The Ruby Programming Language. For me it's the php.net of ruby.

Frank Schmitt
Add the Ruby Cookbook to it as well.
Swanand
TRPL is very *ok* book IMO , I would suggest looking The Well-Grounded Rubyist:http://davidhayden.com/blog/dave/archive/2009/06/06/TheWellGroundedRubyistBookReview.aspx
Pavel Zaitsev
+1  A: 

Get the book (+1 to Eric). Also check out http://railscasts.com/

Jarrett Meyer
+8  A: 

IMO having gone from C# to Ruby on Rails back to C#, is that you can get by with simple apps that fully meet the Rails "opinions" without knowing what goes on. However, you'll run into roadblocks the minute you have to do something that's not a trivial CRUD task or need to implement a CRUD task in a different way than the normal render a form, user hits post, basic scaffolded create controller action way. Once you hit that, you'll need to learn more of Ruby itself to figure out exactly what Rails is doing.

Wayne M
A: 

Taking the questions in order -

These days I understand a fair bit of what's going on inside the framework - not something that was at all true when I began working with Rails (although I had been dabbling with Ruby for a few years previously)

You don't have to understand Rails, but it really, really helps to understand the MVC (Model-View-Controller) pattern. You can get a long way very quickly, but as with most things, producing something really high quality is going to require the hard work.

There are substantial differences in philosophy between Ruby and PHP as languages (IMO). Ruby is more consistent in syntax but its strong OO background means there's a non-trivial learning curve to negotiate. I think it's worth it, YMMV, why not take it for a test drive?

Mike Woodhouse
+1  A: 

Ruby can be tough, writing Ruby with Rails is easy! The language is natural and reads really nicely. Deploying Rails apps is where (IMO) the challenge lies. You'll have no problem if you know PHP well, especially when you have a book like Rails for PHP Developers

Typeoneerror
Phusion Passenger makes deploying really, really easy. Without that, I'd say you were 100% correct.
Steve Klabnik
A: 

The Programming Ruby book is essential. You need to have a reasonable understanding of Ruby to write apps in Rails, or you'll be hitting your head on a wall for most of the day. I also recommend that you look at other Rails projects on GitHub to better understand how things are done, best practices etc.

Then when you get stuck, post your specific question on Stack Overflow and we'll be here to help out :)

bensie
+3  A: 

To answer your basic question, as like in all things, you will learn as much as you want to. Do you need to understand what is going on under the hood, no. Do you need to know how ExpressionEngine works in order to create a web site using it?

As for learning Ruby, this is highly advised. Anything beyond trivial websites will require you to know and understand Ruby and its idioms.

I think the biggest problem with going from php to Rails is the method of development. Far too much PHP is created with all, or a lot, of logic sitting in the view. Rails applications are created with all the logic existing in the models. If you understand this, then you are already a long way into understanding Rails.

As for resources, I would recommend getting the book Ruby for Rails: Ruby Techniques for Rails Developers by David Black. It is designed to take you from a Rails developer to being a Ruby developer.

+1 for all the other resources listed above.

Chris Johnston
Very sound advice!
wentbackward
+5  A: 

Like most things, once you understand something fully, you look down at a small step and remember the mountain you saw when you first looked up at it. I would say, yes Ruby is hard to understand for most developers, for these reasons:

  • Ruby has some very powerful, but less common programming concepts. So there some conceptual learnings to be had.
  • On top of this, most programmers I come across, with some experience under their belts, are already building foundations and concepts about what programming is, except those concepts are being built using constructs from the particular language or domain they are working within.

The best advice I can give is that each language/framework/dev environment only provides one way of manipulating the facets of the machine/network. The mistake is to think that this is the only way. If you approach Ruby thinking, how does this relate to PHP, then expect to struggle, because in many cases, just below the surface, it won't.

A concrete example is:

  • Where's my 'for' loop? et struggle vous

however if you ask

  • How do I run this piece of code for each element of this array? You'll find many wonderful answers and wonder why you ever had a for loop in the first place. But remember, there are even better ways than Ruby has today!

So with all that power in Ruby and also the rails framework, you owe yourself some time to learn the basics. Yes you can work wonders with things like rails, with very limited knowledge. Imagine what you can do with a couple of years of solid ruby learning under your belt.

Peter Norvig wrote a very good paper called Teach yourself programming in ten years. I'd recommend taking a look at that.

wentbackward
+1  A: 

Oh yes and as you specifically address rails, there is an up to date, magnificent set of resources at Rails Guides. In addition to a lot of great advice in the many answers here.

wentbackward
A: 

Quote from you

... when you code in ror...do you actually understand what is going on under the surface if you are a beginner?

PHP and RoR is incomparable. Ruby itself is a programming language with its syntax just like PHP and others, Ruby on Rail however, is an application framework using MVC architecture which itself is much more complicate then the language written by.

If you are familiar with any PHP MVC frameworks such as CakePHP, CodeIgniter or Zend Framework, then you shouldn't have too much difficulty trying to figure the syntax difference as they (variations of MVC frameworks) are all fundamentally similar.

rockacola
I wouldn't say a framework `foo` written in language `bar` is more complicated than `bar` itself! Languages are definitely more complicated to understand (to learn to use is a different case).
Swanand
@Swanand,No disagreement on that. It is just that I have seem developers aways compare PHP to `a packpage` eg/ .NET library or RoR, which is incomparable.If @unknown were asking from PHP to Ruby, then I'll say that it won't be as difficult as he/she may have already grasp fundamental of computer science and programming languages are just like different flavors.
rockacola
A language is basically a framework in and of itself, so I don't see how that comparison is invalid. You can write a web application in plain PHP (without a framework). You can write the same web application in Rails. What's the problem?
musicfreak
A: 

I came from PHP to Ruby, and it wasn't difficult at all. I recommend playing around with Rails, getting a feel for how Ruby is generally written. Then, once you really start building something real, you're going to have to dive into Ruby to understand how to make things better. Learning Ruby itself isn't very difficult, it's made to be very readable and understandable. However, it's important to make sure you understand some of its most important features, like blocks and metaprogramming.

For me, the one thing that really opened my eyes to Ruby was when I first came to understand blocks. It's been all good things since :).

Kyle Slattery
+3  A: 

Being a PHP developer for a few years now, and coming from a C and C++ background, I can tell you that learning Ruby after PHP is not very hard at all (subjective, but so is the question). Ruby, of course, has it's own idioms and 'best practices' which vary from PHP, but I think you'll find Ruby fun and easy to learn. Many of the 'gotchas' in PHP aren't present in Ruby, so it makes learning the language a bit easier. Plus, if you have any sort of OOP background, you'll be that much better off in understanding Ruby.

As others have pointed out, you can build simple apps with Ruby on Rails quickly enough, but if you need to do any heavy lifting you'll have to begin to understand what lies underneath and how Rails operates. This is no different than with PHP and one of it's various frameworks, such as CakePHP or CodeIgniter.

I also suggest checking out the book Rails for PHP Developers if you are interested in learning RoR.

machuga