views:

490

answers:

7

Let me start by saying I know that both Ruby and Php are great languages and this is not intended to start a flame war. My question involves learning web development fundamentals and I have heard that Ruby on Rails can allow too much to be done in the background via Magic. I have so far done some learning in both Php and Ruby and while Ruby does seem a little easier or straightforward or whatever, I don't want to short-change my learning by doing anything that omits too much and thus sacrifices the fundamentals. I've also looked into Python and I would ultimately like to learn that as well but I'm not sure what to begin with to build the right foundation. I've done some C# but I don't know if I should try a interpreted language just for simplicity but I am definitely open to going back to C#..whatever is best for building.

I would really appreciate the guidance.

Thanks.

+1  A: 

This question is kind of ironic, as both languages have a type of magic. PHP's is the magic_quotes, mysql_escape_string (not to be confused with mysql_real_escape_string), special global arrays, weak-but-inconsistently-so typing,

Rails is the don't repeat yourself style.

Matthew Flaschen
HAHAHAHA. ROFL :) +1 from me.
the_drow
magic_quotes, mysql_escape_string and register_globals have all been deprecated. Apart from that, anyone with an IQ above -5 is aware of the dangers of using them.
karim79
Yes. As of PHP 5.3, you should use GOTO instead: http://us2.php.net/manual/en/control-structures.goto.php
wvdschel
The main difference is that Rails' magic generally makes sensible decisions for you. PHP's generally seem intended to blow up in your face, and little else.
jalf
+2  A: 

I think the Rails framework, if you study its conventions, offers an awful lot of guidance in terms of best practices.

I'd start with Ruby on Rails and then learn PHP based on the knowledge and experience you gain from your Rails education. It'll make your PHP much less haphazard (mine was pretty shaky when I started, and I could have benefited from doing this).

ChristianLinnell
+2  A: 

I was put off by Rails' magic at first as well, since there is a lot going on in the background. I then learned Ramaze, which has less magic in a default app, but allows you to add any magic you happen to need.

However, I've experienced that Rails, with all its magic, is better than anything else I've tried, if you're going to be working on it with more than one developer. It's enforcement of conventions and best practices improve maintainability, while it's magic allows you to focus on the task at hand, and not the grunt work of building a webapp skeleton.

wvdschel
Good to know. Thanks for your help.
Mackristo
A: 

PHP is a language, Rails is a framework (with Ruby as the language), so the question might not be a good one. Anyway PHPs usage of "magic" is usually considered bad programming practice, while Rails's style of "magic" is part of the framework, that tries to make your program more bug-free.

Actually I prefer merb over rails, because it actually has less magic, but those are more relevant to get the job done. Lot of "rails magic" will hit you back, if you have to circumvent them (like doing lot of RJS scripting, and then find out that you want something that can!t be done using RJS and you just have to learn JavaScript)

SztupY
That's a good point, I guess the question would be insofar as someone will use Rails along with Ruby as opposed to using Php without a framework (or even with--such as Cake or Symfony etc)thus, all things being equal.
Mackristo
+10  A: 

I have repeatedly objected to anyone who spouts nonsense about Rails being magic. Like here in this thread. As mentioned Rails is not magic, there is no puff of smoke, there is no rabbit in a hat. If you can read, you can read what all this "magic" does, just because you haven't read it or don't understand it doesn't make it magic. Have a read of some things that you use in Rails, you will get a better understanding of the framework and how it works.

There are lots of plugins that do a lot of work for you. Use them if you want, but, guess what, if you'd prefer to learn how to do the same thing, you can write it yourself. Or you can download the plugin, and read it, and learn something about how it works. All the source code is there, it's just up to you to read it.

If you don't like that Rails takes care of a lot of generic tasks for you, then don't use it.

railsninja
I agree - very well said.
John Topley
Since Rails is open source you can also look at the code to see how the "magic" is done
Kathy Van Stone
+2  A: 

If it's Ruby on Rails or PHP without a framework and the goal is to learn ... then I have to go with Ruby on Rails everytime.

Rails is opinionated. It will force MVC on you and require that you do things The Rails Way.

When you are learning it is liberating to not have to make so many choices. To not have to think about how to get started or what your overall design should be. Rails (and many other frameworks - including PHP ones) give you that. Take it.

More pragmatically -

You will eventually need to ask someone for help (or consult a book!). Using a common, well defined, framework like Rails makes that much easier. The people you are asking are already familiar with your application (to a limited degree).

When you want to add a feature but don't want to implement it (say you want to add user profiles and security) you will find it much easier to add that functionality into a Rails application with a well defined framework than into a PHP app with no framework.

In the end - no matter what you choose you will learn things, make mistakes, solve problems and have some fun. That's a pretty good place to be.

Bubbafat
Thanks for your answer. That's very helpful.
Mackristo
A: 

I don't thing there's too much magic, and I'd (strongly) suggest learning Rails for several reasons.

  • Rails and Ruby are great fun as a framework/language pair. Enjoying yourself doing web development is surely the best way to learn.
  • Ruby on Rails is powerful, and you'll get results quickly. Producing a web site that does what you intended is the purpose of web development, and Rails is very good for that.
  • When you're still learning, everything has a little bit of magic about it. You have to choose which bits you're going to dig into and discover the techniques behind the magic. Rails provides a very powerful but clean way of doing web development, so you don't have to dig into the magic all at once - you can let Rails take care of things initially, and look more deeply later.
  • There's a very accessible book that I found really helpful when learning Rails. If you're willing to shell out a little cash I'd highly recommend it (you can download a PDF, so no waiting for Amazon) as it will lead you through the magic one step at a time (but quite fast steps, so you don't get bored!).
David Waller