Comparison: Ruby vs PHP, the Pros
Just to be clear, this is NOT a fanboyism post nor do I encourage the debate between which language is superior. My personal belief is to use the appropriate tool for appropriate projects.
PHP Pros
- Widely available libraries (including PEAR and PECL)
- An absolutely outstanding online manual
- Relatively easy to learn (can hack together some code without deep understanding of the language)
- Widely used (easy to find clients, etc)
- Most if not all control panels have PHP integration
- Development packages (XAMPP, WAMP, MAMP, LAMP, etc)
- C style syntax (easier transition for people with C/C++/Java background)
- Powerful array feature (Ruby’s equivalent to PHP’s associative array is Hash, which is not interchangeable with array)
- PhpDoc is better than RDoc (this might be because I am too used to PhpDoc)
Ruby Pros
- Fully object oriented
- Rake (Ruby’s Make)
- RubyGem (Ruby’s apt/yum)
- Code blocks
- ‘Ghost’ classes
- Modules (aka namespace/package, PHP 5.3 will have namespace too, but with much uglier syntax)
- lambda functions (PHP 5.3 will have this too, but not as powerful)
- Children-aware parent classes (’inherited’ hook)
- Multi-inheritance through Mixins (PHP is single-inheritance)
- Ruby 1.9 is unicode friendly (PHP 6 will be)
- For what I do, Ruby on Rails > all PHP frameworks combined
- Regular Expression built into the language core
I am pretty sure there’s heaps of pros for both PHP and Ruby missing from the list, but at least it gives you a rough idea on what to look for if you are not very familiar with them.
Please share your experience with us too (and I will update this post accordingly). :)