Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Philip Powis
Philip Powis
7,625 Points

Rails VS PHP

What are the high level differentiators here? Why would one choose to use one over the other, and then what should someone use to help them make a decision on which one to learn first?

I was originally planning on learning rails, but my brother is working on a project in PHP so might change my plan so I can collaborate on a real world project that way...

Just curious to hear what folks have to say. I know that there is learning available for both here on treehouse.

Thanks!

Phil

3 Answers

Hunter MacDermut
Hunter MacDermut
15,865 Points

How timely! I was coming to the forum to ask this very same question. The abundance of Ruby and Rails content found here on Treehouse and over at CodeSchool would indicate that it's where these educators believe the future of the web lies. But when looking at what employers are looking for in job listings, I only ever see PHP. I'm also curious how they differ and what advice you could give to a newbie who wants to get started. The short answer is probably to learn both, but if I'm interested in finding a gig soon would I be better served learning PHP over Rails?

Philip Powis
Philip Powis
7,625 Points

exactly! Is there a better order to tackle in and why?

If you're looking for a gig now, learn PHP.

PHP rightly deserved scorn in the pre PHP4 days, but the language has improved massively in recent versions and I honestly don't mind working with PHP 4.4 and up.

I'll answer the bigger question in the main thread.

Why You Should Learn PHP

It's the most popular language for web development outside of perhaps Java and most of the major CMSs are programmed with it. Getting your PHP app to run is mostly a no-brainer, you just give Apache a PHP handler or you simply enable modPHP. Junk shared hosting even supports it. If you're looking to work right now, you'll want to learn PHP.

There's been a lot of support thrown behind Laravel, which attempts to hide a lot of the PHP syntactical cruft behind a Rails-like framework. It's a very high quality framework and although I've not used it for a serious project yet, I could definitely see myself doing so quite soon. I don't think it's a stretch to say it's the closest thing to a Rails equivalent in PHP.

Why You Should Learn Ruby

Even if you don't program in Ruby on the backend, you'll be using a ton of tools in the Ruby ecosystem, I promise. Ruby is a wonderful language that's very terse and expressive. You'll notice when you start reading Ruby code it tends to be easy to read. That's for many reasons but partially because Ruby has expressive keywords. Instead of saying like in most languages that if not equal to x you say unless x. This seems like a small thing but it really adds up in terms of clarity. You tend to be able to almost think in Ruby once you get good at it. You're not fighting with syntax like you are in PHP and Java.

Why Beginners Should Probably Not Try to Use Rails

I strongly disagree with beginners trying to use Rails because there's too much magic involved. Ruby is a very complex language with a ridiculous amount of capability. Rails is exponentially so.

You might learn how to crank out an app but you're not going to understand much about programming. Most of Rails is in fact not programming. There's nothing programming about has_many :categories, you don't really understand what's going on at all. You're basically a glorified Visual Basic code jockey and you don't want that. Be a programmer.

The Rails ecosystem is incredibly powerful and has so much you need to learn apart from Ruby to really get the strongest benefits out of it. In order to really blow up on Rails 4, you need to understand Ruby, Sprockets, Sass, CoffeeScript... All of these things are optional but if you're not utilizing them you're leaving so much power on the table that IMO it's not worth using Rails.

I'm NOT Saying Beginners Should Not Learn Ruby

While much easier to find a PHP job, especially an entry level one, Ruby is great. If you like it, and you like the tools learn it. I actually recommend you learn both eventually. What I'm saying is try vanilla Ruby and see how far you get. Learn about Rack or a simpler framework like Sinatra. Once you're comfortable there, you can revisit Rails with a much better foundation and understanding of what the magical parts are actually doing so you can understand if you're doing it correctly.

Hunter MacDermut
Hunter MacDermut
15,865 Points

Terrifically helpful answer, sir. Thank you. I've got a decent amount of HTML, CSS, and JavaScript under my belt and was trying to figure out some of the back-end stuff. I've been through some RoR tutorials and I agree that it all seems a bit too magic-y. I suppose if I was only interested in learning to throw pieces together so I could share an idea with a real programmer it would suffice, but I want to be that real programmer. And I'm looking to get into a job where I can work with a team and improve my skills, so it seems like PHP is a slightly better place to start. I will definitely work on both eventually, but you've given me the confidence I needed to start getting serious about PHP and not worrying that it wouldn't be the best use of my time. Thanks again.

We developers tend to suffer from some pretty serious web hipsterism, claiming the newest technology and software to be the solution to all our Internet problems. If you feel comfortable with JS, you might want to start playing around a little with Node.js and server-side JavaScript. Server side JS is the future of the web more than Ruby is, although Ruby is not going anywhere.

I don't however think it's the best career move right now as Node jobs are somewhat hard to come by in most areas and it's all very very new. You're going to find that unlike PHP and Ruby, a lot of the problems devs have have not been solved in Node yet.

James Barnett
James Barnett
39,199 Points

This is a favorite topic here on the forums, in fact there's a whole tag just for php vs ruby on rails

Including a very popular answer from Randy Hoyt

That's a good response, having the ability to switch between HTML and PHP is really nice for beginners. I also agree Python is a great language, I only didn't mention it because there's not many materials on Treehouse about it yet.