1,105,375 Community Members

Ruby Vs PHP

Member Avatar
Amr87
Junior Poster in Training
77 posts since Feb 2011
Reputation Points: 1 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 0 [?]
 
0
 

Hello Everyone,
I`m a PHP developer, These days I`m thinking seriously about learning ruby , but I`m not sure if it gonna add to my knowledge , so i have few questions about it and hope that a ruby specialist will answer me

1- Do I need to learn ruby to become more professional web developer?
2- What ruby can do while php can not do?
3- does it offer more features and capabilities over php?
4- does it need deep learning curve?

thank you very much

Member Avatar
ChaosKnight11
Light Poster
33 posts since Jul 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Hello and welcome to the Ruby forum :)

This is a very common question, so be assured that you aren't the only person battling with this. Ruby and PHP (like you already know), is two very different languages, designed with different goals in mind. I too (just like many Rubyists) is an ex-PHP developer.

Unfortunately I am not a "Ruby specialist" as I am switching between Python and Ruby to fit the project's need. But I can assist you with picking Ruby.

To answer your questions:
1) These days (after 2005) Ruby is a very popular language thanks to 37signals' Ruby on Rails framework. Ruby on Rails is Ruby, so if you know Rails syntax, you'll know Ruby syntax and vice-versa. So obviously you'll need to learn one of them to be a better professional in Ruby. But as many Rubyists before me, I suggest you just start with Rails straight away, since that's what you're probably aiming at. (Ruby has a lot of additional features, that you won't need for general web development, and Rails is already a complete web framework that specializes in web apps).

2) Ruby and PHP are languages, and if you are good in a language, you can almost do anything in it (I know PERL programmers that are much more efficient than many C++ programmers), so you don't have to compare features for languages. But what I do like about Ruby or Python that PHP can't do, is that it can allow you to script native looking apps. You can even install IronRuby and battle complex problems with the power of .NET or Mono. (That's an added bonus ^_^).

3) If you want to know anything more specific, just message us and we'll assist you :). One thing that is worth mentioning here though is community. I know PHP's community is gigantic, but the Ruby community is not very far behind, and I heard that companies in some cities in the US are looking for Rails developers more than any other web developer (excluding Java and C# of course). So it won't hurt to learn Ruby. Rails 3.1 also brought an entire arsenal of new features, and Rails now handles almost everything, from static files to images, and CoffeeScript and SASS is now baked into Rails, making you aware of the tools you always wish you had. There are also LOADS of gems available for every task. There's facebook integration gems, OmniAuth gem for one-time login via the social networks, etc.

4) No. PHP for me was much more difficult than Ruby (especially PHP 5 OOP). But there will definitely be a learning curve but luckily for you, there are books available like Rails for PHP Developers. OOP in Ruby is just awesome. Everything is OO so objects are always used, and the way they are handled is much more elegant than in PHP. Also the syntax is much more elegant than PHP's rubbish spaghetti syntax. But once again, I suggest you start to learn Ruby via RoR, and then learn everything you didn't learn in Rails only if you have to. (Only for your own gems and if you want to go beyond web to native apps).

One more thing. If you are going to learn Rails, keep track of the community. It's easy to get lost as time progresses. Add @dhh on Twitter (David Heinemeier Hansson - The creator of Rails), and it's worth reading Agile Web Development with Rails (it's the best Rails by example book I have encountered). And if you want a book about anything Ruby or RoR oriented, check Pragmatic Books. If you want to know anything else, just let me know.

I know my answer is very Rails biased, but it's because Rails brought me pure web development joy. It makes your day FUN :D

Just remember that the more tools you have in your toolbox, the better your chances of picking the right tool for the job.

And welcome to Ruby (and RoR), it's good to have you on board. I am sure you'll never look back :)

Member Avatar
Taywin
Posting Maven
2,632 posts since Apr 2010
Reputation Points: 134 [?]
Q&As Helped to Solve: 378 [?]
Skill Endorsements: 17 [?]
 
0
 

Well, I am a Ruby on Rails (RoR) developer and I do Ruby & Perl scripts as well to assist the background work that Rails cannot do. I also did PHP about 5~6 years ago for about a year. If you are going to compare Ruby and PHP, you should compare Ruby on Rails to PHP instead. If you want JavaEE (I do it for my hobby), it is also a very good to be used for a web frame work, but the learning curve is really steep.

1- Do I need to learn ruby to become more professional web developer?
When I started doing RoR (at work), I started from coding only a Ruby script (web scraper) to be familiar with the language. It took me 3 days to finish the script. Then I went on Rails right afterward. The syntax used in Rails is actually very similar to Ruby. The only difference is the structure of the application. You need to understand MCV (model, control, view) concept and that's all you need for learning a frame work. However, you will need more knowledge and understanding if you are going to do the "set up" for a web server with the frame work application.

2- What ruby can do while php can not do?
As ChaosKnight said, they both are languages. You can do most anything with it depending on how much you know about it. However, one may have advantages over the other on certain features/circumstances. Still, both should be able to do the same work but may have to take different approaches.

3- does it offer more features and capabilities over php?

To me, PHP web application is a bit messy and seem to be more client oriented. I mean your code is usually mixed in the view page with HTML elements. You also tend to have database query call directly from the view page. One obvious advantage for PHP is that it is very easy to create a web page regarding the design of the frame work. However, it is too easy to do and that is dangerous for hacker to attack and inject malicious code in your page because many people over look the security. I am not sure if there are many plug-in you can use for PHP though...

For RoR, there are many plug-in called "gem" to be used with the frame work. Also, when you implement a web application, you would try to separate the code from business logic. In other words, most of the code or computation/data retrieval are in the model/controller parts. As a result, you need to only format the display in the view page. Also, RoR offer what they call "partial" which is very useful when you want to display a portion of the page in multiple places and you may use different data in it.

4- does it need deep learning curve?
I am not sure about learning curve. I spent around the same length of time learning both PHP and Ruby. It is not very difficult but there are tons of tricks to learn too. That is what you would have to think about. :)

Member Avatar
Amr87
Junior Poster in Training
77 posts since Feb 2011
Reputation Points: 1 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 0 [?]
 
0
 

Guys , You are really awesome!
Thank you very much :)

Question Answered as of 2 Years Ago by Taywin and ChaosKnight11
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article