On the wide and beautiful roads of the Internet, there seems to be a huge cat fight over which is better, Ruby or PHP? These days, with clients wanting to receive the ultimate, most cutting edge, most performing and stable applications, with the developer desiring clear, straight to the point documentation, a good debugging system, and as much as functionality possible without requiring to read much upon them. Keeping this in mind, both the clients and the programmer want to know, which is better to use on your website? Which is faster? Which is stable? Which is blah blah blah blah…..
So it is our duty to have a pro and con description on both of them, for example, while Ruby-based Web applications can give you much more control over the development process, it is shown many time that it’s frameworks like Kohana have a good relationship with crashing and being unstable in general.
Dispelling the most common myths about Ruby:
It is more mature.
First, good software doesn’t mature like good wine, an non-maintained project for example, can survive for 20 years and still have it dysfunctional, because the server for it isn’t alive anymore, there are no updates existent, it has become insecure, or plain simply doesn’t link with the libraries in your new operating system. I am not claiming that Ruby is non-maintained, but PHP has been around since 1995, and it is still in active development, becoming better and better daily.
It is really easy to create new websites with it.
Sure, we can all take a template, hack together some basic functionality in it, then voila! You have a new website. But that doesn’t mean that it has proper functionality, it will be stable, or even look original. It’s a known fact that once something has been made popular in the Web Development community, chances are your competitor uses a modified version of it, much sooner than you had the chance to implement it on your own website. People have been fooled by the RoR demo on YouTube and yes, you can create a simple blog with a simple input functionality for searching articles, but in real life, the Ruby syntax is complex, there are two thousands of additions, and you need to have intermediate knowledge of the HTTP protocol in itself.
Dispelling the most common myths about PHP:
If it started using frameworks as default, it should be left to die:
Not so fast cowboy, as the most popular content management systems and frameworks are built upon it, and it does not have any chance to die with all this market share surviving upon it. I really can’t imagine WordPress on Ruby (it would be funny to see it), neither the guys from EllisLab porting CodeIgniter to it without a big headache combined with suicidal tendencies. It is still one of the easiest to use and feature rich scripting language for the Web to this day. And with the thousands of frameworks and content management systems that are at the top of the food chain accompanying it, i don’t think it’ll be easy to take down the king.
Improper object inheritance:
Since PHP 5.2, With the invention of the Traits functionality, this argument became invalid and now there’s a better way to inherit functionality, and that without having to track your inheritance tree between classes like, say in C# or Ruby. Also some frameworks such as Zend Engine have implemented an inheritance solution for the object system so there’s no need to worry about multiple inheritance anymore.
Now there are thousands of pro’s and con’s for the both of the scripting languages, but i have neither the time or sheer power to write them.
But i’ll be quick and swift in the claim that most of them don’t depend on the language, but do depend on the programmer. You can write scripts that use resources inefficiently on PHP and you can write applications that are very fragile on Ruby by using improper URL handling or object structure. Clients should have at least basic knowledge for the both scripting languages and the Programmers should be always correctly documented and follow the best practices as much as possible.
Now i’ll quickly describe the pro’s and con’s for both languages:
Pros and Cons – PHP and Ruby
I’ll start with Ruby as there is more controversial emphasis on it.
- Clear, good documentation for both the language itself and it’s frameworks,
- Having a complex syntax gives possibility to more functionality in less time,
- Very good performance if the code written well,
- Big enough community to give newbies a pat on the shoulder.
- The complexity of the syntax might also mean incorrect usage of it,
- Not enough popularity, you might not get everything you want from it
- More development time and having to write the functionalities that are easily implemented on, say, PHP or Perl
- Steep learning curve
Now all that Ruby needs is a push for the popularity and more users contributing with things such as, more powerful content management systems overall, more stable frameworks, more functionality for developers to implement quick solutions, and more community support. I believe it has the potential of becoming a GREAT language once it gathers what i described above.
Lets get to the other language, the one people love to hate 🙂
- Huge community support,
- Very smooth learning curve, it will take a new user 1 week to have a proper grasp on it,
- Popular: most of the popular frameworks and content management systems use it,
- HTML Integration: most of the web servers support including PHP code in your HTML with just a .htaccess edit. Not so much with Ruby.
- Easy learning curve might lead to bad programmers: Someone who doesn’t have a good knowledge of programming (algorithms, logical decisions, OOP, web protocols such as SOAP or HTTP) might would be able to write really insecure code,
- Object Inheritance not in the direct syntax: Programmers coming from another language such as C# can’t directly integrate their knowledge, such as using a keyword like “extends”.
Both languages have enough time to solve these problems but might upper hand goes to PHP, because of the huge market share and just-get-it-done mentality. The emphasis on security also makes me quite happy with it.