views:

1460

answers:

19

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

Pros:
-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

Cons:
-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]

Pros:
-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.

Cons:
-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?

+3  A: 

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.

duffymo
Who gives a toss about Google? The asker didn't say he works for Google. This smells of FUD
Chuck
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
@Chuck - going to vote down Soviot for recommending Django, too?
duffymo
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
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
@Chuck - those aren't spurious arguments, nothing more than citations. Twitter has been a long-time Ruby user, the best-known user that I can think of. So the fact that they're stepping away for Ruby at all is relevant. I'm neither a Ruby hater nor a Python fan-boy. Your biases are showing.
duffymo
My impression of Google embracing Python was that it was a choice of convenience and they fully intend to support ruby for google apps eventually. Anyone care to correct this?
George Mauer
No inside dope from me - I base my on Steve Yegge's blog: http://steve-yegge.blogspot.com/2007/06/rhino-on-rails.html
duffymo
Google's resistance to Ruby has nothing to do with any deficiencies in the language — they just want to have a minimal set of languages in use to reduce the mental load of their projects. If they were already using Ruby, Python would be rejected for the same reasons.
Chuck
In other words, out-of-context "citations" with an implicit "...so you can see how much this thing must suck" are nothing more than FUD. I didn't vote down the other mentions of Django. I even voted up Brent's pro-PHP answer. I think I just honestly find your answer lacking in technical merit.
Chuck
You're mistaken about the implicit bit. Don't pretend that you can read anybody's mind. You're opinion of the technical merits of the argument is perfectly valid, but please don't assume you can read minds. I honestly believe that Python has more traction than Ruby, and that does have merit.
duffymo
The OP doesn't ask anything about Twitter or their use of Ruby. This is a poor answer.
railsninja
I think it's pertinent, because if one of the best-known public users of Rails decides to back away from it for any reason I'd want to take that into account when I make a decision about whether to follow their lead. It's info that the OP can decide on. As can you, of course. We have your view.
duffymo
@duffymo, I can't put into words how wrong I think you are, they went away from it because of a message queue. I don't know if it was because their coded queue was poor or because Ruby is slow, and guess what, you don't know which of those reasons it was either
railsninja
That's okay, railsninja. Actually I do know if the article is to be believed, because one of the interviewees said that it was a very bad queue implementation. Believe me, I'm not bashing Rails. But if you think I'm wrong, I'll accept that. It's not the first time.
duffymo
The OP was asking for opinions, so there is a subjective flavor to this question. Here's one that you might answer: Besides Twitter and the Basecamp stuff, what else would anyone know that's written in Ruby/Rails? That's germane - more well-known apps means more acceptance.
duffymo
Yellow Pages is a site lots of people would use, also Shopify. Saying the queue implementation was bad would mean their code for Starling was bad rather than Ruby being bad. I'm done now, I'm sounding like a zealot and that's not what I was going for.
railsninja
No, I appreciate it. I was ignorant of Yellow Pages and Shopify. The article said it pretty well. Neither it nor my post said that Ruby was "bad", any more than another language is bad. I did state a preference for Python. It's just information. Yours is helpful too, in my opinion.
duffymo
+3  A: 

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.

Dmitris
You can do the same thing with ruby, most clients don't care what language they use.
George Mauer
I agree, i just gave a real life example that i witnessed.
Dmitris
+2  A: 

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!

dommer
+10  A: 

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

Soviut
+1 Django homer vote.
Paolo Bergantino
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
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? http://guides.rails.info/ There are a lot of very good Rails books out too.
insane.dreamer
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
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
My post clearly points out the rubbish that is a comment about "magic", just read the source, the fact that there are methods in there to make your life easier isn't magic, and how it does it isn't hidden.
railsninja
+2  A: 

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.

tvanfosson
+5  A: 

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.

Brent Baisley
+2  A: 

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.

Mladen Mihajlovic
true, but these days vps are cheap (e.g slicehost.com, linode.com). Rails hosting is also easier with phusion passenger.
Ed
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.
railsninja
@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
@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
+16  A: 

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.

Chuck
"only reason for choosing PHP over Ruby is because you don't have a choice" gets a -1 from me.
Paolo Bergantino
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
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
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
CakePHP is neither Rails-y nor really nice. Otherwise, I agree.
Jim Puls
@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
A: 

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.

colo
I'd say the competition in the PHP field is much greater than the Rails field.
Soviut
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
+4  A: 

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

Because it's been around forever, it does seem to suffer from spaghetti code with its procedural programming roots.

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.

The bar to entry is very low, so naturally there is a lot of bad code out in the wild.

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.

gaoshan88
true indeed, spaghetti codes are self inflicted wounds we all did once :)
Ed
+1  A: 

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)

Ed
+3  A: 

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.).

troelskn
Regarding soap-client, I ended up writing a new soap-client after this post. See: http://github.com/unwire/handsoap
troelskn
+1  A: 

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.

insane.dreamer
A: 

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.

Brad
+5  A: 

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.

railsninja
+7  A: 

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?

Kevin Kaske
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
How is CodeIgniter copying Rails?
Paolo Bergantino
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
+1  A: 

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

Edin
+2  A: 

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.

Beavis
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
+2  A: 

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.

maetl