Take the 2-minute tour ×

Here's my situation: I'm an ASP.NET Developer first and foremost. That's not going to change anytime soon. I have built my small business on it. With that being said, I'm looking to add other technologies to my arsenal. Not just for learning purposes, but to one day be able to offer clients an alternative solution. For this reason, I have gone back and forth between the PHP/Framework world and Ruby on Rails.

I'm going to list a set of pros and cons that I have found with each, based on my research and personal needs. I'm hoping you can be objective as you read through these, share YOUR personal experiences, and then provide me with advice.

(running Mac OS X)

Ruby on Rails

-Ruby is OOP through and through
-Ruby and Rails was a piece of cake to setup for development
-Rails Framework is modern and encourages the best practices for today's web dev
-Cutting edge and has influenced major competing technologies to push the envelope like PHP Frameworks and now ASP.NET MVC
-Convention over Configuration makes development a bit easier, cleaner, and more efficient
-Very Agile

-It's a moving target. AWDWR book was just released and already there are changes in v2.3 that make the book dated. And the Rails/Merb team are gearing up for 3.0. Yikes!
-Hosting. Although, this may be improving (haven't done a ton of research here)
-Not a lot of jobs from what I've seen.
-Documentation. This appears to be getting better though. The Rails Guides is very promising but it's still a pain point I believe.
-Rails almost has too much 'magic' for my taste

PHP [insert Framework here]

-It's been around forever. So the community is HUGE and the documentation is plentiful.
-Options. You can code without a framework, roll your own, or use any of the several popular ones out there.
-Jobs. Probably THE most popular technology powering websites out there. I don't think there is or will be any shortage of PHP work.

-Because it's been around forever, it does seem to suffer from spaghetti code with its procedural programming roots. OOP functionality feels like a band-aid.
-The bar to entry is very low, so naturally there is a lot of bad code out in the wild.
-Syntax is just ugly.

That's what I have right now. I'm really torn. Again, I want to pick up one of these so in the future I have more options. What would you suggest?

share|improve this question
I wouldn't say that PHP's syntax is 'just ugly'. It takes a while to get used to, but you will be amazed at how elegant it is :) I personally like PHP but am going to investigate RoR during the oncoming summer, so you have no idea how much you've helped with the list of pro/cons for RoR. Thanks –  Peter Perháč Apr 8 '09 at 13:57
I imagine when Java showed up a bunch of COBOL guys were sitting around saying: You can write beautiful code in COBOL, it's easier to get hosting, I've heard Java leaks memory and supports Nazi war criminals, it's much easier to get a job with COBOL, COBOL is more mature and stable, the Java interpreter has all this magic stuff going on, blah blah blah –  DigitalRoss Oct 29 '09 at 17:00
Having coded in both, Rails is more elegant than PHP. I haven't played with any PHP frameworks, though, and some of which, I hear, has MVC features. Rails, being based on Ruby, has more of a programming feel, while PHP, being only loosely based on Perl (which I love) and C (I believe), has a more duct tape of features and "features" feel to it. As an added bonus, Rails has built in testing features. –  Elizabeth Buckwalter Nov 20 '09 at 17:37
one reason I hate PHP syntax is because it uses the under_score instead of camelCase –  adardesign Dec 28 '09 at 17:23
add comment

closed as primarily opinion-based by halfer, andrewsi, Ahmed Siouani, Karl Anderson, Salvador Dali Nov 2 '13 at 1:56


20 Answers

up vote 8 down vote accepted

I was exactly where you are now. It came down to picking between Rails, Codeigniter, and CakePHP. I decided that I wanted to go with PHP, because the hosting was cheaper. I learned that I love codeigniter. It's simple, clean, fast, big community and has great documentation.

On later projects I started using Rails and fell in love with programming all over again. Rails is so nice. I would use rails anywhere I could.

When it comes down to it... Cake PHP, Codeigniter and most other web frameworks these days are copying Rails. Why not use the original?

share|improve this answer
This I would argue is the best argument of all of the ones I read and there were 17 at the time I wrote this. Here is someone that unlike most of the responders has actually tried Ruby on Rails and PHP (complete with Cake, said by many to be the best framework) and he says Rails. I would listen. –  John Munsch Apr 8 '09 at 18:53
How is CodeIgniter copying Rails? –  Paolo Bergantino Apr 10 '09 at 23:42
Scaffold, Routes, Helpers, Just to name a few. I'm simply saying that Ruby (and more specifically Rails) works for me. I like Ruby better then PHP and rails better then Codeigniter. If I was forced to use PHP (which I have been in the past), I would pick Codeigniter and be happy. –  Kevin Kaske Apr 13 '09 at 19:47
add comment

Really, the only reason for choosing PHP over Ruby (or Python, for that matter) is because you don't have a choice — either you want to work at a company that's PHP-only or you know PHP and don't want to learn something else.

PHP can be a moving target too. Just Google PHP 5 and you'll find a lot of people who had the rug yanked out from under them. Rails is picking up features like any actively developed software, but it's not really a moving target in the sense that a lot of working code is going to wind up broken. Rails has been fairly stable for a while.

PHP isn't a bad language per se, but Ruby is objectively more powerful and expressive. I've never heard anyone argue this point, though I'd be interested to see it. Python is also more powerful and expressive, but it's beside the point here. It's easier to do things right with Ruby, and especially with Rails. PHP inadvertently encourages tons of antipatterns (not a problem for a good programmer, but how much you want to bet all your coworkers and predecessors will be that good?) and lacks some useful features that can make code more expressive.

I don't think host support is an issue, because most major Web apps are not hosted on a $5/mo service, and any dedicated server can be set up to support Rails.

BTW, if you do want to use PHP but like Rails, I suggest you take a look at CakePHP. It's a really nice-looking PHP framework that's strongly inspired by Rails. I haven't used for any real projects myself, but it looks quite Rails-y and I like what I've seen of it.

share|improve this answer
Anyone is free to make a counterargument. The only pro-PHP answers here actually bear me out — their crux is that PHP is useful for getting work at places that use PHP. No booming praises for the superiority of the language. –  Chuck Apr 6 '09 at 7:49
php's main forces are that 1) it works, 2) even a bad programmer can use it 3) it has a huge library-support. It may be ugly, but it beats Ruby on those points. –  troelskn Apr 6 '09 at 14:29
The fact that a bad programmer can use your language isn't really a plus. If it were "A bad programmer can write good code in PHP," that would be something, but all of us who have worked with PHP know that isn't the case here. –  Chuck Apr 6 '09 at 16:11
CakePHP is neither Rails-y nor really nice. Otherwise, I agree. –  Jim Puls Apr 9 '09 at 21:44
@Paolo: you don't actually know Ruby, do you? Choosing PHP over Ruby or RoR is simply not done willingly, except by people who haven't seen or haven't understood Ruby or RoR. I'm sure there are a few people out there who would have written bad Ruby code and just don't understand the difference, but for most people it's hard to go back to PHP. –  DigitalRoss Oct 29 '09 at 16:52
show 1 more comment

Try Django. It builds on many of the same concepts as rails, but it's lighter and tighter than Rails is; no annoying Ruby memory leaks and no wacky "magic". It runs on Python which is a lot more stable and battle hardened. But the most important aspect, it has amazing documentation.

Django Documentation

And try reading a few chapters of this:

The Django Book 2nd Edition

share|improve this answer
+1 Django homer vote. –  Paolo Bergantino Apr 5 '09 at 18:21
I'm getting a lot of downvotes on this. I'm not trying to flaunt Django too much. Just letting the OP know there are other options besides rails. –  Soviut Apr 6 '09 at 15:55
I agree Django and Python are good. But "a lot more stable" is stretching it. Also, as far as documentation goes, have you seen the Rails guides? guides.rails.info There are a lot of very good Rails books out too. –  insane.dreamer Apr 6 '09 at 15:59
For a long time, it was impossible to build a Ruby application on the MRI that did not leak memory. Perhaps this has been fixed in 1.9.x, but Python is generally more stable. –  Ryan Duffield Apr 6 '09 at 21:55
It used to be common practice to have to run cron jobs to restart many rails applications nightly to cope with the memory leaks. And Rails has an ungodly amount of magic happening in it. –  Soviut Apr 7 '09 at 3:43
show 1 more comment

PHP certainly isn't the best language by any objective measure, but it is one of the most popular. A great article on why: http://startuplessonslearned.blogspot.com/2009/01/why-php-won.html

PHP is popular for all the reasons why it is a "bad" programming language. The barrier to entry is minimal. There is no build process to learn, no compiling to run, no restarting services to reload libraries. Very simple for high school/college kids to play with.

I've been doing PHP for about 6 year now, and have seen some very bad code. I've gotten lots of work to rescue people/companies from the bad code that worked at first, but wouldn't scale. Especially with Facebook applications.

Many open source projects are written in PHP, WordPress for one. That opens other doors for customization work.

But whether it's PHP, Ruby, Python or some other language, you should learn the language first, not a framework. If you know the language, picking up the framework will be easy.

The fact that Ruby is progressing through versions should not be a worry. Perl is no longer progressing through versions and where is that? Perhaps PHP is the new Perl and will go the same route. But not this year or next likely.

Pick one to learn now and learn the other a year from now.

share|improve this answer
add comment

There are lots of answers, my nickname will obviously give away what language I use and would will now advocate :)

One thing I want to address is the Rails "magic". Rails is not magic, it has a lot of methods written for the express purpose of making common tasks easier. Calling these methods doesn't mean you can't go and look at the source code and find out exactly what they do.

On the hosting front, if you are writing something substantial in any language then hosting on a shared host is not really going to cut which means you have any number of VPS hosts that have good plans, root access and amazingly reasonable prices which you could use to host Rails, django or PHP applications, look at Linode or Slicehost, both brilliant providers.

As for being a moving target, yes Rails is at 2.3, the Agile Web Development book is now up to date for Rails 2.2, and for the basic tutorial application that they have in there I am fairly certain that the APIs that you will be using and needing are the same, if they are not then there are excellent sites out there to help you, Rails Brain is a great site that has the API as they existed in many versions of Rails.

TBH the Ruby community as a whole can be a little sensitive, the reaction to Twitter writing a message queue in Scala is a good recent example, since none of us really know what goes on at Twitter and what they tried and why they wrote what, so who knows who did what and why. The only thing I want to come from that is they publish what queues they tried, why they didn't use them and why they use their new queue Kestrel instead, this is the nature of open source software and could help me choose my new tool.

But don't let that turn you off Ruby either, it's a great language with a great wealth of information, and flame wars and a bit sulking aside, for the most part the community is pretty good too and documentation has come a long way with sites like Rails Brain, Ruby Brain and the Rails Guides which are pretty good now.

Good Luck with your choice and I hope it works out great for you.

share|improve this answer
add comment

I'd say PHP would give you the most flexibility and earning potential. Look at some of the cons you list:


That is true but it has nothing to do with how YOU would code with it and the top frameworks do not suffer from this. Thus, I see this as a non-issue.


Same thing, think about how you yourself will be utilizing PHP. You won't write bad code so unless you anticipate spending a fair chunk of time dealing with other people's code (and that code turns out to be of the bad sort) this will be a non-issue.

Frankly most of the code work I do is stuff generated by myself and the guys I usually work with. We do ok, quality wise, so the issue of legacy code that was spahgetti has no bearing on our day to day work. We also use Zend Framework and it is clean, well documented and object oriented so really, from my perspective, the only con that matters is the ugly syntax one and frankly that one doesn't bug me, personally. It can be ugly but it doesn't bother me much at all.

share|improve this answer
true indeed, spaghetti codes are self inflicted wounds we all did once :) –  Ed_ Apr 5 '09 at 18:41
add comment

I saw stuff today that suggested Twitter's moving away from Ruby:

http://lambda-the-ultimate.org/node/3261 http://www.theregister.co.uk/2009/04/01/twitter_on_scala/ http://www.artima.com/scalazine/articles/twitter_on_scala.html http://blog.obiefernandez.com/content/2009/04/my-reasoned-response-about-scala-at-twitter.html

For web development, I would vote for Python before either of these. It's one of Google's supported languages and it has several nice web frameworks, like Django.

share|improve this answer
Who gives a toss about Google? The asker didn't say he works for Google. This smells of FUD –  Chuck Apr 5 '09 at 18:03
FUD? No, just an opinion. Google's endorsement (and support in their cloud) can be accepted or ignored, but it's telling that they don't support Ruby. If you're a Ruby supporter perhaps you're reading too much into this. Are your biases showing? –  duffymo Apr 5 '09 at 18:06
@Chuck - going to vote down Soviot for recommending Django, too? –  duffymo Apr 5 '09 at 18:07
It's not for recommending Django, but for using spurious arguments (these companies don't use Ruby, so nobody should) that amount to rah-rah-Python, die-Ruby FUD. It's possible that my biases are showing, but I don't think so. –  Chuck Apr 5 '09 at 18:17
Plus twitter isn't moving away from Ruby to Django/Python. It's moving to Scala for the backend. I'm guessing they will probably stick with rails for their front-end (I don't know because frankly language wars are about as useful as the real ones) –  srboisvert Apr 5 '09 at 18:37
show 13 more comments

Nobody of course can tell you what to chose, and with that being said.

If i would have small business and was looking to add something else to my potential, i would go for PHP. As you mentioned it easy to learn, and entry level is low and very popular, so with PHP you will never be without work. I am currently studying on web development program and we have students who after the first semester (we were learning php) went out and found themselves clients and started to work as freelancer on regular basis. So i would go with PHP.

share|improve this answer
You can do the same thing with ruby, most clients don't care what language they use. –  George Mauer Apr 5 '09 at 20:08
I agree, i just gave a real life example that i witnessed. –  Dmitris Apr 6 '09 at 1:03
add comment

One thing to keep in mind is that while PHP is often considered messy, it's quite stable. If you need a library for something, chances are that it already exist, and it's fairly bug free. That is not always the case with Ruby. For example, the only soap-client that exists for Ruby, is slow and buggy. It's also worth to mention that Ruby is remarkably slower than its peers (PHP, Python etc.).

share|improve this answer
Regarding soap-client, I ended up writing a new soap-client after this post. See: github.com/unwire/handsoap –  troelskn Dec 29 '09 at 9:22
...except for UTF-8 and i18n/i10n. Not the gettext garbage, but the stuff that most international shops use. PHP's intl library is 1/2 implemented and 100% useless. –  BryanH Jan 23 '13 at 23:08
add comment

Thanks for all the great feedback. It definitely helped me to evaluate the situation a bit more. I will say that it's hard to pin-point any right answer here because it's all so subjective.

I've decided to stick with RoR for now as my 'backup' technology. Maybe one day it will become my go-to, who knows? The reason I'm going to learn RoR is because it's modern, very structured, and has a growing community.

Since it's modern, it has the advantage of learning from the mistakes of programming languages and platforms of the past.

Since it's structured, it helps guide and enforce GOOD programming habits.

Since it has a growing community, there will be people, code examples, libraries, documentation, etc. to help along the way.

Bottom line: although PHP is a good choice, RoR seems to be the better choice for me NOW.

share|improve this answer
Ruby is a beautiful language and Rails is a great framework. The leaning towards great practices like TDD and BDD in development in these areas is a total benefit. Don't limit yourself to rails. Look at why rails and merb have had a bit of a competitive relationship. Look at sinatra. Look at rack's entrance and why it has made things even more awesome. There are a lot of brilliant aspects of the Ruby community and I wouldn't be surprised if you get swept up in it. A lot of us have (and I don't think any of us regret it)! –  dylanfm Apr 25 '09 at 13:20
add comment

I've been a similar situation. I've had to use PHP for client work. To be honest, I don't really enjoy it - but the fact I have to use it shows how pervasive it actually is!

I've recently started using Ruby on Rails, and how enjoyed it so far. The ideas it promotes have also helped me rethink some of the ways I use ASP.NET, so it's been a win-win. Just waiting for IronRuby to get to a release stage!

share|improve this answer
add comment

I would lean toward Ruby/Rails, if only because if you move your ASP.NET apps to MVC you'll find a lot of conceptual familiarity with Ruby/Rails. Essentially you'll be able to borrow a lot of the design/architecture and just translate it into the appropriate language/framework. The same might be true of some PHP frameworks, but as you note you'll have to be more disciplined to keep within the pattern.

share|improve this answer
add comment

Another plus for PHP is that finding a server that runs it is very easy. Most shared hosts don't support the other languages and you need to pay more to install it yourself.

share|improve this answer
true, but these days vps are cheap (e.g slicehost.com, linode.com). Rails hosting is also easier with phusion passenger. –  Ed_ Apr 5 '09 at 18:54
I agree with @Ed and really any PHP app that is not just a few pages will probably be crap on a shared host anyway. –  nitecoder Apr 8 '09 at 23:42
@Ed Some people might not want to pay the extra price (which is about 10x more than shared hosting) and some people don't want to have to install everything themselves and set it up. –  Mladen Mihajlovic Apr 9 '09 at 12:06
@railsninje Useless argument. You can run any application written in PHP on any hosting, shared or otherwise (with a very, very few exceptions which might need root access). Are you saying apps like Wordpress and Joomla (and many more) are bad apps? –  Mladen Mihajlovic Apr 9 '09 at 12:08
add comment

I would definitely try Ruby/Rails. If you're used to MVC it's a good fit. It's well-suited for agile development, which today has a lot of value. There's a lot of good documentation, tutorials (try Railscasts), books, etc., to get you up and running, and a good community to help with the advanced stuff. Ruby is a solid and flexible language. The current interpreter generally used (1.8) is slow compared to Python, but the new version (1.9) is just as fast (though many libraries don't yet work with it); but unless you're building computationally intense sites, the speed of the interpreter is not much of a factor. There are less libraries/tools than for PHP, but unless you're coming up with something very esoteric, this won't be a problem. As a second option, I would go with Python/Django.

share|improve this answer
add comment

You should learn both...

If you can learn Ruby on Rails, and know enough about Javascript and C syntax, PHP will be very easy to pick up.

PHP is useful in cases where you just need to make an incredibly simple website on cheap hosting, quickly, using something like Wordpress. It makes sense to know PHP, at least on a cursory level. If you're just painting by numbers with frameworks, then there's not really a difference, but Rails will teach you deeper things about application design and metaprogramming, simply because of the nature of Ruby as a language.

share|improve this answer
add comment

I would look to learn both, in this order:

  1. Ruby/Rails
  2. PHP

The reason being that the first will give you a good foundation for best practices for when you learn the second. There are a LOT of PHP gigs out there because there are a LOT of inexperienced, ignorant folks writing really poor code.

There are fewer folks writing Ruby/Rails because it is just hard enough to learn that the folks who are not serious get scared away (hopefully forever).

PHP suffers from Lerdorf's misunderstanding of C and his lack of knowledge on designing a language, which is why the syntax is not consistant and PHP is "functionally broken" all over the place. If you choose to learn PHP first, you will pick up all sorts of bad habits, which will make things harder for you when (if) you need to think outside of the PHP box and use another language.

In the end, some might say language is simply syntax, and that is true--to an extent--but it is also a mindset, a ways of thinking, and that's where Ruby/Rails absolutely crushes PHP.

share|improve this answer
add comment

learn ruby on rails

then learn cakephp

it'll be easier, trust me, I got back from 5 years leaving php, cakephp is easier to learn after you learn rails etc (this is based on my experience 2/3 years in rails)

share|improve this answer
add comment

When you say bad PHP programer i suddenly think that only professionals uses Ruby, i am not a pro i use PHP.

share|improve this answer
I use "Bad Programmer" to mean people who suffer from Dunning-Kruger. –  BryanH Dec 17 '13 at 18:59
add comment

Php versus Ruby Jobs:

In absolute terms, yes, PHP has a greater number of jobs.

But in relative growth, Ruby is the clear winner.

Just as you don't want to buy into the stock market when valuations have reached their peak, developing Ruby skills when the market has fully embraced it means you also have greater competition because by then more people will also have learned the language.

Also, when you try to decide where you're going to live, do you choose the cheapest place, even if it's in a bad neighborhood? Or do you choose the environment in which you are most likely to feel comfortable? Of course, everyone has a different philosophy.

share|improve this answer
I'd say the competition in the PHP field is much greater than the Rails field. –  Soviut Apr 5 '09 at 20:19
I think that was his point Soviut... the Rails competition is going to start picking up if you don't get a head start now. –  Mark Apr 6 '09 at 0:55
add comment

Try both beyond the 'hello world' experience and then make a decision. Books can only tell you so much. Experience is worth a hundred books.

I had to make the same choice a few years back. I read a few sites on PHP and a few on ROR.

I wrote the 'hello world' program in PHP, and then I did it on ROR. I did another simple project and I decided that the ROR way just 'felt' better.

Heck, both are free (as in beer). Give each one a try. Write the 'hello world' and then write a simple program that uses a database, saves data from a form, and then presents that data to the user on another form, allow for editing after that.

Then make the choice that works for you.

share|improve this answer
You can't really appreciate a good language (and loathe and despise a poor language) until you make a) a web service, b) database CRUD and c) some kind of user authentication. Do both in ROR and PHP and the answer will quickly--quickly! become obvious which way you will want to go. :) –  BryanH Jan 23 '13 at 23:23
add comment
