Language War: PHP vs. Ruby

Language War: PHP vs. Ruby

It’s time; queue the “Going the Distance” theme from Rocky. In the red ring: Envato developer extraordinaire, Ryan Allen, who built the original FlashDen with his cold bare hands. In the blue corner: Michael Wales, a well known member in the PHP and CodeIgniter communities. The battle? PHP vs. Ruby. Fight!


Before We Begin

It must be noted that these sorts of debates are purely for fun and educational purposes. There are times when you’ll choose PHP for a project, and there are times when you’d opt for Ruby. The goal of this series, however, is to learn how and when to make these sorts of decisions. Rather than “your language sucks,” these debates are meant to outline why you might, in certain situations, choose one over the other.


The Contenders

Ruby: Ryan Allen

Ryan Allen

Ryan Allen is a web software and systems engineer who’s been working for Envato since forever. He built and supported the early versions of the Envato Marketplaces in Ruby on Rails, and now looks after the Tuts+ systems, amongst other things.

PHP: Michael Wales

Michael Wales

Michael Wales is a web developer for US Government agencies, and is an active contributor to the PHP and CodeIgniter communities.


And…Begin!

1 – How familiar are you with both PHP and Ruby?

Ryan: PHP was one of the first programming languages I worked with (asides from ActionScript and some very brief Visual Basic). I began building things with PHP in 2001. I worked fairly exclusively with it as a backend tool until late 2005, when Ruby (and Rails) took its place.


Michael: PHP was my introduction to the world of web development, in 1999 – so I’d like to say I have a pretty solid understanding of its position within our industry, its history and the direction in which it is headed. Ruby, like many others, caught my eye with the release of Rails and the success of 37signals. I have a fairly solid understanding of Ruby, as a scripting language in my System Administration duties (Capistrano) as well as some personal and fun projects (the Gosu game development library and Rails). I’m ashamed to admit I’m not as familiar with Rails’ latest versions and it is definitely on my list of things to reacquaint myself with.


2 – Do you feel that your language is more suited to beginners or advanced users? For example, if I’m relatively new to the industry, would I have more trouble learning PHP or Ruby?

Michael: Unfortunately, I can’t give a definitive answer to this – at least not as you’re expecting, since PHP and Ruby are two entirely different beasts. PHP is an amalgamation of language and web framework in one package, whereas Ruby is a programming language with numerous frameworks available.

If your focus is web development and that’s all you really wanted to focus on right now, I would definitely advise you to learn PHP first.

So, if your focus is web development and that’s all you really wanted to focus on right now, I would definitely advise you to learn PHP first for a number of reasons:

  1. You don’t really need a solid understanding of System Administration or deployment best practices to learn and get things done. For virtually every host, you upload and you’re done.
  2. You’re going to gain a lower-level knowledge of how the web works; for example, how a request is passed between the client and server (as it pertains to your application), what functionality sessions provide, the limitations of cookies, the difference between the various request methods.
  3. On the Ruby side (and I’m going to assume the Rails framework, based on its immense popularity): deployment can be very difficult at times (although this is alleviated by services like Heroku, but then you miss out on the educational opportunities of understanding the low-level). I think this lack of low-level education is the ultimate downfall of Rails, from both a deployment standpoint as well a development standpoint – you can quickly and easily use sessions, cookies, create insecure and destructive controllers (via the GET request method). Not that you can’t do these things in PHP as well, but Rails actively promotes this knowledge.

As a developer with 12 years’ experience, I appreciate the shortcuts Rails brings to our industry; but, that is only because I understand what is actually going on behind the scenes.

If you want to become a developer (Web Developer, System Administration scripting, Game Developer, API Developer) who understands low-level Computer Science concepts, object-oriented programming and, in general, advance your Critical Thinking skills – it goes without saying, start with Ruby, it’s an actual programming language (remember, PHP is a web framework disguised as a language).

From a Web Developer perspective, I think this is also one of Ruby’s (and Python’s, BTW) downfalls – is that there really isn’t any “mid-level” entry point. You either understand the HTTP protocol, with the ability to write your own stack, top-to-bottom, or you go with one of the “magical, hold your hand to make a CRUD-system frameworks”.

This is really the area in which PHP shines. If you are stepping beyond the boundaries of CRUD, you don’t need to have an extreme understanding of how an HTTP server works to make your dreams a reality.


Ryan: If I were to teach someone programming from scratch, I’d prefer to teach them Ruby (trouble setting up environments aside – though this is getting easier). A common way to start someone off (after perhaps variables and printing them) is to explain arrays with, say, a shopping list example, take this bit of PHP:

$shopping_list = array(‘Milk’, ‘Cheese’, ‘Hovercraft’);

for ($i = 0; $i < count($shopping_list); $i++) {
  echo $shopping_list[$i];
}

When I learnt PHP, I was taught to use for loops (as I was in ActionScript), when a more succinct and less error-prone foreach loop already existed (as it also did in ActionScript). I had to learn all about this $i = 0 thing, this test thing and this incrementor thing. It was all so confusing! The number of times I’ve screwed up for loops is uncountable (no pun intended). Here’s what the same thing would look like in Ruby:

shopping_list = [‘Milk’, ‘Cheese’, ‘Hovercraft’]

shopping_list.each do |shopping_item|
  puts shopping_item
end

There’s a lot less syntax there, and iterators are to my mind, a lot easier to understand and work with. But for completeness sake, here’s the the PHP example but with a foreach:

$shopping_list = array(‘Milk’, ‘Cheese’, ‘Hovercraft’);

foreach ($shopping_list as $shopping_item) {
  echo $shopping_item;
}

Well, that’s not to bad actually! I reckon that you should only use for loops to count to 10 and things like that, foreach is so much easier to read and teach and so much harder to screw up. And iterators are even better, so I’d go with Ruby.


3 - Many PHP developers move on to Ruby after a few years. Have you found this to be the case, and, if so, why do you think it’s so common? What’s the big “selling” point?

Ryan: The selling point for me (in 2005) was the Rails framework. I had tried my hand at web development with Python but being inexperienced I had somewhat of a tough time, not knowing what to do or where to look (but I managed to build some things, so take that!), but I really wanted to use Python day to day because I felt it had a better, more deliberate design and I liked the syntax. And because Snakes are cooler than Elephants.

ActiveRecord was just so amazing!

Having never worked with anything else beyond ADODB in PHP, and trying and failing at making an ORM many times (I had no idea what an ORM was but I knew I wanted something that somehow mapped classes to database tables), when I first saw ActiveRecord it was like all my Christmases had come at once.

I knew relational databases rather well but was sick of writing the same SQL over and over. ActiveRecord was just, just, so amazing! And Ruby was close enough to Python I was happy as Larry (whoever he is) to have a framework I could get busy and start building things. So for me it was the love of a library and a love of the syntax.

Nowadays we have heaps of amazing Ruby libraries written by talented individuals, libraries such as Sinatra (a lightweight web framework), Nokogiri (a HTML/XML parser), Sequel (a high level database library), RSpec (an automated testing library). All these libraries are installable as RubyGems which I found much easier and user friendly to work with than PHP’s PEAR system.

The community is still fairly vibrant, even a few years in, and companies are hiring Ruby developers like hotcakes. Ruby 1.9 is apparently almost as fast as PHP now as well, so there are many selling points!

Ruby 1.9 is apparently almost as fast as PHP now as well, so there are many selling points!


Michael: I think this is just a natural progression of developers (from Web Development to seeking overall knowledge of OOP languages and an overall Computer Science education) in general – I know it was the route I took.

I think the largest downfall, to this day, is the practice of picking a language and sticking to it to the death. That’s not the way the real world works.

I consider myself a “Developer” – therefore, language is an ambiguous a qualification as the brand of television to a Best Buy salesperson. There are instances in which I pick PHP (if there is an extremely short timeline – outside of CRUD, it’s the language I am most familiar in), there are others in which I pick Ruby (deployment via Capistrano or basic CRUD with Rails) and, even further, Python – which I prefer for Server Administration tasks and parsing of various files.


4 - Often times, we consider our current language of choice to be “better” than the previous. But is that always the case, or is it just “new”? Is it possible that your old code looks poor because you’re now a more skilled developer?

Michael: I think developers can very often get caught up in the “new hotness, old busted” craze. This is why my team always sits down before we begin a project, we lay out the requirements (in both user terms and developer terms – which are two vastly different things) and we talk it out, with very little language/framework preferences in mind. Last week we parsed a few GBs of messaging logs with Perl, this week we built an application whose primary view was an ExtJS GridPanel (because we have extended CodeIgniter core files that handle any situation ExtJS throws at us with 3-lines of code).

It’s all about how much time do we have and how can we produce the best product in that timeframe?


Ryan: Absolutely, some people (myself included) get used to designing things in a certain way that they don’t want to re-learn and change all their hard-earned habits. Once you’re productive with something, why would you bother changing it?

Another school of thought is the more languages and tools you have experience, you’ll be able combine the best techniques and ideas no matter what environment you’re working in (they say this about learning LISP, but I haven’t learnt it yet).

Young programmers will jump on the shiny new things but as you get older and more mature, you want to work with small tools that are simple and robust. If you don’t use every feature and every library available to in Ruby you can get simple and robust without too much trouble.


5 - Are there instances when you might choose to use Ruby for one project, and PHP for another (assuming you have 100% control over the choice)?

One word: maintenance.

Ryan: Yes, one word: maintenance. Software projects have a propensity to require modifications over time, and the original author of the program isn’t always going to be the person who’s making the modifications. Let’s say hypothetically teleports are invented and there is a world-wide Ruby conference and every single able Ruby developer in the world is going (teleports rock!). Now let’s also say that Earth hypothetically is Middle Earth, and Smaug the dragon is rather annoyed about this whole Ruby thing (dragons prefer Python, you see) and decides to pay a visit and gobble all of the developers up out of spite. Now there are no experienced Ruby developers left in the world, oh dear! Now you have this problem of not having a pool of Ruby developers available to work on your projects. What are we going to do Gandalf?

When I’m choosing tools, I’m often thinking about who’s going to have to maintain the project if I get hit by a bus (or crash my motorbike, which is more likely).

I certainly wouldn’t write anything in Haskell or LISP or even F# because we’d have a hard time hiring someone who could or would work on it. Availability of talent and existing talent in a company then very much influences my decision.

There’s another situation where I’d consider the language, and that would be if I was selling a product, say, a custom CMS selling on Code Canyon. I wouldn’t write it in Ruby because commodity web hosting doesn’t generally support it. Whereas PHP is pretty much readily available everywhere and web designers and less experienced programmers are somewhat familiar with it.

There’s another situation where I’d consider the language, and that would be if I was selling a product, say, a custom CMS selling on Code Canyon. I wouldn’t write it in Ruby because commodity web hosting doesn’t generally support it. Whereas PHP is pretty much readily available everywhere and web designers and less experienced programmers are somewhat familiar with it.


Michael: See my answers for #3/#4.


6 - If I’m more of a designer who only dabbles in development work from time to time, would you still recommend that I choose Ruby over PHP? Keep in mind that the terminal is a scary thing to some...

Michael: Personally, I would recommend the Django framework for Python. It was designed with this purpose in mind: the ability to get the developers working on data modeling and displaying data on-screen as quickly as possible, with easy to use tags for designers to present that data in a beautiful manner, while the developers continue to work on the business rules in a concurrent cycle.


Ryan: If you have experience throwing together HTML and CSS and uploading these with FTP, then I probably would recommend PHP, as it has low barriers to entry because you’re already familiar with its metaphor (Wrap your code in <?php tags! Upload it to your server with a .php extension! Away you go!). But if you started taking programming seriously, I’d suggest branching out and having a look into other things (such as Ruby) to broaden your horizons.

When things go wrong, your lack of knowledge will come back and bite you.

Oftentimes I see PHP programmers working with relational databases and having very little understanding of how they work. So really you can get things done without a deep understanding of the technologies you’re working with (you rarely use PHP all on it’s own), but when things go wrong, your lack of knowledge will come back and bite you. How much time do you have to invest in learning these things? Can you go to someone for help if you get stuck? Are you learning PHP so you can get work with it, or just for fun? Choice is a fairly open ended question depending on what your goals are.

Regarding terminals, they are, in short, AWESOME. I use them all the time. Yes, they have a learning curve (but what doesn't?). Once you get a handle on them and start writing your own little programs you can’t go on without them. To be fair, I didn’t find the Command Prompt in Windows very useful, but once I switched to a Mac and had access to all the *nix fun under the hood, it’s become rather productive.


7 - What specifically does your language have that the other does not -- if anything?

Ruby has hype, vibrancy, and sex appeal.

Ryan: I’d say something Ruby currently has that PHP does not is hype, vibrancy and sex appeal. Ruby is unequivocally sexy. Women love it. Men want to be like it. Godzilla fears it. I’d suggest hopping along to a Ruby User Group and you’d find a diverse group of people who just love to code, love making things and technology in general. When I began meeting people in the local Ruby community, it was the first time in my life I felt like I was with “my people.” I honestly thought I was the only programmer on the planet who cared about their work up until then. It was very refreshing and I’ve learnt a lot since then, mostly from the people I’ve met through these groups.

Here's a secret: if PHP released an official update with an alternate syntax (more Ruby/Python like), and wrapped the existing standard library in the style of the popular Ruby libraries (and made it consistent), and had backwards compatibility and ability to integrate with legacy code, it'd be a killer product. Don't tell anyone I said that.


Michael: Ease of deployment, a graceful introduction to the lower-level concepts of web development and over a century of documentation and tried-and-true best practices.


8 - It’s common knowledge that PHP is far and away the most popular server-side language on the web. Yet, it’s also the most ridiculed. Why is that? Certainly there’s a reason why it’s so widely used, right?

Michael: Again - ease of deployment, a graceful introduction to the lower-level concepts of web development and over a century of documentation and tried-and-true best practices.

But seriously – because of the low-barrier to entry with PHP it can be hard to discern the difference between someone who actually knows what they are talking about and someone at the same skill level as you that had a spare domain for a blog. Plus, due to PHP’s vast seniority, there’s a lot of content out there – and not all of it is good.

This isn’t a unique problem of PHP’s – one quick look at W3Schools.com will ruin the dreams of any proponent of xHTML, JavaScript, CSS or PHP.

PHP devs suffer from “not invented here syndrome.”

It can be very easy, when you are a learning a language, to find what you believe to be an authoritative resource (which could be out-dated or just plain wrong) and follow along with what they are “teaching” you. This is something the PHP community needs to get much better at – spreading the “right” way to accomplish certain tasks. I’ll admit – the Ruby community has the advantage here, Rick Olson solved authentication for everyone when he released the Restful-Authentication plugin. J

PHP developers, for their first few years, suffer from “not invented here syndrome” – which I don’t believe is a bad thing (until they start selling that or passing it off to others). I think the mindset behind a new developer, experiencing PHP for the first time, is that they really want to understand exactly what is going on – and PHP does a perfect job of “giving them enough rope to hang themselves” – revealing enough to learn, but you’re probably going to hurt yourself. Whereas, and not to discount Rick’s plugin (which is an awesome authentication system), Rails developers are willing to assume this guy got it right and continue on their way.


PHP became immensely popular because it was in the right place at the right time.

Ryan: I’d say PHP became immensely popular because it was in the right place at the right time. The alternatives for server side development back in the day required a fair amount of programming knowledge, yet many people who never thought of themselves as programmers were already throwing things together with HTML and CSS. Following the same deployment metaphor and a basic understanding of how to put websites together you could make moderately useful programs and throw them up on an inexpensive shared web host. Or you could download one that someone else made and tweak it up a bit because the HTML and code was all mixed in together.

Another thing that helped PHP along was the boom of the likes such as the cPanel product and hosting providers white-labelling web hosting. Every man and his dog could become a web host at low cost and without any technical knowledge. Every man and his dog wanted a web site and cheap hosting. PHP and MySQL were stock standard on these shared set ups, and they were everywhere (and still are).

The best doesn’t always ‘win’, a lot of people are still annoyed that SmallTalk lost to Java, though the people I’ve met (serious software veterans) who were around when this happened, say they feel quite at home in Ruby!


9 - PHP is often criticized for its sloppy nature. But, is this a reflection of the language itself, or the users who aren’t familiar with quality code? There are plenty of ways to write clean MVC-based PHP.

Ryan: This isn’t very nice, but I’d say the common criticisms of PHP are quite valid and are due to the way the “language” was designed (or rather, not designed). PHP was born out of a number of CGI scripts that the original author wrote in C (or was it Perl?), and the common case of why PHP went the way it did was so “I could have a C programmer writing scripts for the web in only a couple of days”.

I don’t ever recalling asking a C programmer to make me a web application!

Ruby on the other hand was designed to take the best from a number of languages to create something that was a joy to work with, it has taken cues from Smalltalk, Perl, LISP and others, and it shows.

A very big difference between PHP and Ruby for me was that Ruby encourages you to work with their basic data types like Hashes and Arrays where I never found them natural in PHP. The number of times I had to look up the order of arguments for String and Arrays in PHP is mind boggling.

The number of times I couldn’t remember if this or that function had underscores or not was equally as annoying. I used Zend IDE so I didn’t have to remember but I didn’t like the IDE. It felt like you were damned if you did and damned if you didn’t. There is no consistency in PHP’s standard library and it’s frustrating as an enraged bear in a telephone box. In Ruby, I rarely spend any time in documentation for common data types because the common interactions are so easy to remember.

Once you start using features in Ruby’s Enumerable module, you’ll wonder how you ever lived without it, pinky swear!


Michael: I think this is a reflection of the low-barrier to entry and the inherit curiosity of PHP developers to really understand what is going on. I had read/studied hundreds of white papers, blogs, articles on authentication systems – but it wasn’t until I built my own that I truly felt as if I knew what was going on. I believe new PHP developers are eager to share what they’ve done with the rest of the world and are frequently slammed for doing so, because they didn’t follow best practice or proven security patterns.


10 - Community and documentation are many times more important than the framework/language itself. How does Ruby or PHP’s community compare to the other?

Michael: I think both PHP and Ruby have serious issues in their documentation – and for completely opposite reasons.

PHP has tons of documentation, thanks to its seniority – you can find the answer to any question with a quick Google search and it’s going to work. Is it the best solution? Maybe, maybe not …

Rails has been growing so quickly, that even I have a hard time keeping up.

Ruby has great documentation, but in reality this appears to be a framework vs. framework question, so we’ll assume Rails. Rails has been growing so quickly, that even I have a hard time keeping up. Rails API documentation is great; but when it comes to third-party documentation (books, blog articles, StackOverflow responses) – they’re all out-dated and while following along with this information it is very difficult to debug the problem and fix it.

In this respect, I believe PHP has the advantage as the individual frameworks (CodeIgniter, FuelPHP, Kohana, CakePHP, etc) can mitigate this effect to some degree – if you are using one of these frameworks it is simple to go find the definitive answer for what you are looking for.


Ryan: When I was using PHP, a lot of emphasis was put on how awesome the comments in the PHP.net documentation was. The philosophy seemed to be to ‘write the documentation once, and let people add their two cents’. The problem with this is that comments are laid out in order of posting which means the good ones do not filter to the top, and any insights shared in them were not worked into the documentation in a timely manner (or at all).

So much of the common API is included in the PHP core, which doesn’t change that often, so I think a wiki solution would be more appropriate. That way the community could modify the official documentation, suggest changes, suggest examples, integrate the good from the comments into what people see first. That would be useful (especially to a beginner).

Java courses teach people about polymorphism first and look at what they do – design with class hierarchies as a first cut! It makes me crazy!

In Ruby, a lot of the commonly used libraries are on GitHub, where people can submit small changes and improvements which get rolled into what is generally a regular release cycle. Documentation is paired up in code using RDoc (which is similar to PHPDoc), and when you install a gem it generates documentation on your local system. For much of my work, I’ll either be reading core documentation on rubydoc.info, or locally on my machine, or if any of those fail the libraries’ source code itself.


Conclusion

We've heard Ryan and Michael's thoughts, and you most certainly have your own views. Continue the debate in the comments!

Tags: Ruby
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://blog.awellis.me Andrew Ellis

    In Ryan’s code examples, shouldn’t he have used foreach() as that is what he did in the Ruby example. If you’re trying to teach one similarities across the language… use the same loops. :)

    • http://ringvold.nu Harald

      As far as I can se the last example uses foreach. Do you mean something else?

    • Nick

      As a web developer, it is best to handle arrays with loops (like for loops) instead of functions (like foreach as what you have said).

      • http://ringvold.nu Harald

        Why do you say that? Could you explain it a bit more? I feel that most of the time the for loop is too much hassle and strictly not needed when one can use the foreach. Which I think Ryan tried to point out.

      • Todd

        Wrong.

      • Eduardo Barros

        That doesn’t make much sense.

        Besides, foreach is a language construct, not a function.

      • Tino

        As stated, foreach is a language construct used specifically for looping through arrays. It’s definitely not a function.

        And I’m pretty sure the fact that it was designed specifically to handle arrays says enough about using it over other looping constructs.

      • http://www.sitebase.be Sitebase

        Nick, you are totally wrong.
        Foreach is a much better choise for looping through an array then for-loops.
        Foreach is faster, simpeler and is less coding.

      • http://codeforest.net Codeforest

        Nick, that is so not true.

        If you look at the above code, it counts the array every time in a for loop. That is the most common mistake to make.

        Using foreach construct, you avoid this kind of things.

      • Nicolas

        hm a for statement is faster than a foreach :

        http://www.phpbench.com/

      • http://brettic.us Brett

        I’m actually showing foreach to be faster using the php cli version on my mac:

        http://pastie.org/1634114

        Current PHP version: 5.2.14

        Did foreach in 0.0000388622 seconds

        Did for in 0.0000839233 seconds

        http://pastie.org/1634128

        Current PHP version: 5.2.14

        Did for in 0.0000770092 seconds

        Did foreach in 0.0000340939 seconds

        I think it just comes down to the question, “Do I need an actual counter variable?”

        I see so many benchmarks on this that go back and forth, that you should just use whichever you prefer or fits the task at hand.

  • https://timshomepage.net Timothy Warren

    I’ve been looking at Ruby lately, and would love to try it out, but there’s no good documentation on how to set up an environment.

    • http://www.caseyprovost.com casey provost

      Check out Hivelogic…

    • http://envato.com Ryan Allen

      If you’re on Windows, have a crack at Rails Installer (it’s a new project, support 1.8.7 currently): http://railsinstaller.org/

      If you’re in Mac OS X or Linux, use RVM: http://rvm.beginrescueend.com/

      Either should save you a lot of headaches!

    • https://timshomepage.net Timothy Warren

      I was more referring to setting it up so I can use it web-side. I’ve got a PHP/Java server I’ve set up, but I haven’t seen any good documention on how to set up either lighttpd or nginx for Ruby.

      • http://www.bitcetera.com/en/techblog Svoop

        @Timothy: Take a look at Passenger. It’s the “mod_php” for Ruby (or more precisely Rack-compatible Ruby apps such as Rails). It’s ridiculously easy to install for either Apache or Nginx.

        http://www.modrails.com/

  • http://www.thingsingeneral.com Cody

    PHP rules, end of story.

    I kid, I kid.

    I actually got started as a web designer, then moved into front-end dev, and then took on impromptu back-end duties involving raw PHP. It was great to actually build something functional, but it felt lacking.

    See, I actually got my start early on with ActionScript, and had gotten quite used to a real object-oriented language (with AS3). I can’t count the number of times I had to look up why push wouldn’t work on an array, just to find I was trying to use a class method rather than one of PHP’s global functions.

    (Note: The web outfit I work with on the side recently switched over to Zend, and at least its architecture is better to work with. I’m still not too keen on the language, though.)

    Anyway, thanks for the comparison; it’s definitely got my interest piqued.

    • http://envato.com Ryan Allen

      If you liked ActionScript you’d no doubt like JavaScript, have you had a look at Node.js? It’s currently a hot topic, and has a very active community!

      • Nathan Sweet

        I am with you on this Ryan. While Node is a long way off from being able to be stand alone module in a server architecture Ryan Dahl (the creator) claims it will be done, without even a server (like apache) in the way. The way he says this will be done is by people creating javascript libraries for the server much like we have the on the client.

        What is truly awesome about his project is that he did away with the traditional multi-threading model and instead uses an event loop in a single stack (and forking to different cores, process-dependent) to create non-blocking requests. It is INSANELY fast (faster than NGINX in some test-cases), and insanely scalable (its memory usage is jaw-dropping). All that being said, it’s also insanely underdeveloped.

        I think it represents the future for a couple of reasons. First, it is very fast and will blow the competition away with how parsimonious it is with its resources. Secondly (and most importantly), and along with the first point, since it is non-blocking, and JavaScript, it will create huge suction in the development market from people who could create a server just by loading up their favorite javascript library (like people do with the client, ex. jQuery) and get going, only having to use the language they already know (javascript) in an environment that mimics event based programming (because of the non-blockingness and the use of callbacks). I am really excited to see where it goes over the next year.

    • http://www.thehelliaint.com Brian

      Cody, thanks for mentioning your history as a designer/front-end to back-end.

      There are likely many people reading this article, that are web designers with an HTML/CSS background that are looking at the frightening world of development considering the next big step.

      Even though I don’t understand the development nuances to gauge which language to learn, I think these types of discussion are pedagogical to the laymen. Specifically questions like, If I’m more of a designer who only dabbles in development work from time to time, would you still recommend that I choose Ruby over PHP? Keep in mind that the terminal is a scary thing to some…”

      From this we get the Django curve ball from Michael and PHP recommendation from Ryan (who’s a Ruby pusher!).

      I look forward to future articles in this series!

  • aniss

    At the end Django WIN :D

    • http://vanderbeurse.de Benny

      Yep! But Python wins overall!
      Ruby’s just that popular because of Rails. If there were no Rails no one would ever know Ruby…

      • http://www.bitcetera.com/en/techblog Svoop

        Ruby and Python are quite similar in power, yet different in style. So at least for me it comes down more to a question of gusto than technology. Python wins for you, Ruby for me.

  • http://ringvold.nu Harald

    Interesting read! Gave me som new insights into both languages. Could someone elaborate some more on Rubys deployment issue or rather what makes it more difficult than PHP do deploy? I wasn’t aware of this.

    • http://envato.com Ryan Allen

      Ruby tends to require you to know a bit more sys-adminy type things, and you’d want to be comfortable SSH’ing into a server and fiddling around.

      PHP is ‘easy’ because inexpensive commodity webhosting has it all set up out of the box; all you need to know is how to FTP files up to a server. If you were to set up PHP yourself on a server it’d be of equivalent difficulty to Ruby.

      Another way you can get Rails (and Ruby) web projects up online is with a service called Heroku (http://heroku.com/), it has some limitations as to what you can do (less than running your own server), but you can deploy an application in a few minutes! I highly recommend having a play with it.

      • Amgine

        Wait… wut?

        Setting up PHP on my server, and my laptop, was pretty much exactly the same – sudo apt-get install php5. Done. Tweaking the install for production/development may require almost as much effort as Ruby, but I sincerely doubt it.

      • John

        Webfaction ( http://x.co/SXEi ) has great Ruby, PHP and Python Support, gives you SSH by default, and allows for some really cool admin functions that cPanel doesn’t give you, and is way cheaper than heroku.

      • http://www.bitcetera.com/en/techblog Svoop

        I agree with Ryan. Of course it’s a breeze to have your Linux distro install Apache and mod_php, but you can’t call that a deployment environment. If you run any kind of server, some advanced sysadmin knowledge is a prerequisite or you’re likely to become a target of the bad guys (even of those without any real skills). And with this sysadmin knowledge, deploying Ruby is very doable – specially for projects a little more complex than your mom’s blog.

      • Svoop

        Oops, sorry, I ment Amgine not Ryan.

  • Philip

    I don’t want to choose, I wan’t em both!

  • Brian

    To be honest, Michael sounded as though he leans toward Ruby as well. I’m all for finding a tool that is better for the job at hand, but it seemed a little uneven. I am sure you found who you felt was best suited for the position, just my personal observation throughout the comments. I assumed this series was going to be die-hards from each side that would simply speak to why they like the language in certain situations.

    • http://www.michaelwales.com/ Michael Wales

      I lean to whatever gets the job done. To be completely honest, we rarely choose Ruby because, typically, what we want to accomplish involves much more than your standard CRUD and I feel this is where Rails breaks down and actually hinders development.

      We stick to a lot of Rails-esque conventions in our development, regardless of language (_id field names for foreign keys, created_on/updated_on, plural controllers, singular models) – but that has little to do with Rails and primarily fueled by standards set in place by my team.

      • http://developish.com Brandon Wright

        I’m curious about your statement that Rails breaks down if you go beyond standard CRUD. Can you give an example? In my experience, Rails is great for “complicated” stuff because if so strongly encourages you to put the business logic in the models, and map controller actions to the things you want to do with those objects.

  • http://www.lastrose.com LastRose

    A good read, however it feels more like two peoples thoughts on two languages more than an actual “Language War”.
    Was hoping for insight on the two languages, and more defensive stances by the defenders of each language

    • http://mariocuba.net Mario Cuba

      I agree with this. Is more like a open-ended interview than an actual discussion. Each developer should defend its language, so us, the readers, can have some insight (kinda like “yeah, I thought that too”, or “yeah, I never saw it that way”) and defend it too.

      Still, it was a terrific reading.

  • http://digitale-avantgarde.com chp

    This was interesting, but I think you guys are way to nice. Put a bit more controversy in it!

  • Michael Wales

    Ryan and I discussed what we wanted to achieve with our answers. There’s more than enough “my language can beat up your language” discussions out there. With the format in which this was held, having a decidedly mature conversation on our given platforms seemed to be the best solution.

    • http://jakswebdesign.com Adam

      You certainly did…but when this series was introduced (December? January? who knows….) I thought the “my language can beat up your language” for edutainment purposes was exactly what was supposed to be going on.

      Sounds to me like both of you are saying Ruby is the only one anybody who calls themselves a programmer should know while PHP is just for posers. Not really a two-way debate going on, unless you would count it as you and Ryan vs PHP.

      • http://envato.com Ryan Allen

        Oh no no, that’s not true! Facebook use PHP, and they have heaps of “real” programmers!

        I’d be quite happy to wax lyrical about how JavaScript is better than Ruby. Ruby isn’t all roses and sunshine either!

        If there was the perfect language we’d all be using it, but unfortunately there isn’t one (yet) :(

      • http://www.michaelwales.com/ Michael Wales

        Sounds to me like both of you are saying Ruby is the only one anybody who calls themselves a programmer should know while PHP is just for posers. Not really a two-way debate going on, unless you would count it as you and Ryan vs PHP.

        Interesting, that wasn’t my intent at all, I thought I did a well enough job of explaining my position – sorry it didn’t come off like that. I guess for clarification: I would only use Ruby for Rails, and I would only use Rails if I was building a one-day, stupid simple, CRUD application. If that application needed to do anything remotely more advanced than CRUD operations, I would go with PHP. If it wasn’t a web application, but something along the lines of system administration or parsing of data, I’d probably go with Python or Perl.

      • Remi

        @Michael: Interesting, it’s almost opposite to my choices. I would use Rails for any at least a little bit complicated web app, PHP for a “one-day stupid simple” webpage (or alternatively, some Ruby microframework like Sintra). Also i think Ruby is great for sysadmin and especially for data munging tasks (i used Perl for them 5 years ago).

  • http://johnathanward.com John Ward

    One of the big reason I stick to PHP is the availability of documentation, even if some of it is not considered best practice. When it comes down to it the business expect the app/site to function. If it functions in this way than you have accomplished your goal. They don’t care if you used the best possible backend code (that they will never see) or not. All that they care about is that you accomplish the task within an arbitrary timeframe.

    So I say with the exception of security wholes who cares about best practices if the code works? I guess maybe the poor guy who has to fix your code later, but what do you care. That being said i still tend to try to follow what the latest “best practices” are, but in the end it either works or it doesn’t.

    • Mildly Concerned

      You should care about best practices for many reasons. Security(which you mentioned), Speed, Maintainability, Efficiency to name a few. They are called best practices for a reason. If, say, an automobile didn’t stick to best practices for vehicle assembly the consequences could very well be disastrous.

      Not following and applying best practices, in any project or language, is saying that you don’t care about the product you are delivering to your customer, or what it may cost them in the future.

      • Mildly Concerned

        Automobile manufacturer I should say. ^^

    • http://sethetter.com Seth Etter

      I think the goal of sticking to best practices is to achieve several different things in your code. Such as the speed of your application, security, extensibility, or for catering to other developers who may be working on the code. Best practices ensure a lot of different things in your development. While making sure it functions is top priority, those who put extra work into producing code that is high-quality as well as functioning would worry more about best practice.

    • http://www.wdonline.com/ Jeremy McPeak

      Both points of view are valid. The distinction between the two comes down to what you were hired to do.

      If you were hired to write an application, then the end result is the most important (within the allotted time-frame, of course). Yes, maintainability may suffer, but as long as it works and works well, no one cares what the code looks like. You can get the project finished and move on to the next.

      If you were hired to write code, then obviously you want to take your time and ensure your code is maintainable and follows best practices.

    • http://www.wdonline.com/ Jeremy McPeak

      Both points of view are valid. The distinction between the two comes down to what you were hired to do.

      If you were hired to write an application, then the end result is the most important (within the allotted time-frame, of course). Yes, maintainability may suffer, but as long as it works and works well, no one cares what the code looks like. You can get the project finished and move on to the next.

      If you were hired to write code, then obviously you want to take your time and ensure your code is maintainable and follows best practices.

      • http://www.wdonline.com/ Jeremy McPeak

        Hurray for double post!

  • http://www.ssiddharth.com Siddharth

    This is an excellent read! Thanks for the discussion, guys.

    Also, I imagined them talking with this playing in the background: http://www.youtube.com/watch?v=wlOhC1MiVTQ :D

  • Eric

    “over a century of documentation”

    • Thomas

      Sarcasm maybe? I was kinda taken aback by the statement too. Perhaps if you add up all of the time by all of the documenters on all the versions of PHP, or some similar metric?

  • http://spotdex.com David

    “but then you miss out on the educational opportunities of understanding the low-level”

    That is also one of the reasons I don’t like using ruby gems when I work with rails.

  • http://www.caseyprovost.com casey provost

    I believe a vital point was missed here.

    There are a slew of articles, tutorials, references out there for Php and Ruby, however the quality of both differ greatly the majority of the time. I have learned both Ruby and Php while doing it, writing code and then going back and writing more. When I started learning Ruby I was ashamed at the quality of my php code. It was messy, poorly documented, un-tested, and frankly inefficient. As soon as I started learning Ruby I started writing tests because so many in the community demonstrated the importance of doing just that. I also noticed that my methods were much shorter and much easier to read.

    The point that I believe needs addressing is that if you are self-taught, or spend any time learning on your own most resources for PHP teach how to code pretty poorly. Maybe this has changed in the last year, I wouldn’t know since I have almost entirely abandoned php for what I believe is a much more enjoyable language to develop with.

    I would also mention that Ruby is more friendly in general, especially while learning. More than once I have been writing a script and guessed the method call I would need along with the arguments required. In PHP I could almost never do that. The order of arguments for similar functions such as string manipulation were flip flopped, function names were long or just gibberish, and I wasted much time at php.org.

    Also Php has produced many developers that are satisfied by “just making things work”, Ruby has produced hundreds of developers who have a passion for doing things “the right way.”

    Just my 2 cents.

  • Kristian

    I’m certainly on the Ruby / Python side of the fence. Personally, I dabble in Python. If I were to consider another language, I’d choose Ruby over PHP without any hesitation. The only thing PHP has going for it, is that the vast ammount of jobs require PHP. Although over the next 5 / 10 years I see that slipping and Ruby / Python quickly grabbing the loss of market share.

    • DED

      I hope you’re right about this. I learned Python and Ruby before PHP ( backwards I guess) and still prefer them to PHP. Admittedly, the more I learn about PHP 5.3, the more I like it. But, I would love to see other languages like Python and Ruby become as common on the web. That would probably take care of a lot of the current deployment issues.

      • http://envato.com Ryan Allen

        Job opportunities in technology depends a lot on where abouts you live. In Melbourne, Australia for example there are more job openings for Rails developers than there are Rails developers available.

        So I think, the thing to do is to check what companies are asking for. Certainly people are asking for Ruby and Rails in Melbourne because it’s perceived to attract excited and talented developers (most of the jobs are for working on brand new projects, as far as I can tell).

        But of course you can make an amazing product in anything, if you don’t have a good frontend developer it doesn’t matter what backend technology you use!

  • xristian matos

    I have 3 years with php and i love it but there is an important thing you need to know, i am not against Ruby but you wont be hired in my country (dominican republic) programing with Ruby. PHP programmers are most wanted in the employment pages here.

    But i wanna say that i would like learn something about it.

  • Joshua M

    For me… work dictates it.

    I can’t justify the time to spend learning ruby as a web dev language. At the fortune 500 level, getting access to a LAMP stack server is far from guaranteed – quite often its windows boxes and asp.net.

    Expecting to ever be able to use ruby for most of our projects would be dumb… so I just don’t spend too much time with it.

    I did play with it… and as always, learned a few tricks that apply back to php… so it wasn’t all bad (I actually quite like ruby as a language)

    • http://envato.com Ryan Allen

      I agree, as Xristian mentioned above, it comes down to what people are hiring for locally and whether you want to learn for fun or you want to learn to get a job (or get better at your job).

      Where I live, the choice between ASP.net/Java versus Ruby depends on what kind of company you want to work at. Do you want to work at a Fortune 500 style company with all that goes with it? Or do you want to work for some crazy start up working on the alleged ‘next big thing’?

      The culture of the technologies are so different, but learning other (very different) technologies can (hopefully) only make you a better developer by showing you different ways to think about problems.

      An amazing book recently release called 7 Langauges in 7 Weeks (http://www.pragprog.com/titles/btlang/seven-languages-in-seven-weeks) is kind of designed to fast track you through a number of contrasting languages. I dare say that if you read the book and worked with it you’d come out the other end with some significantly different perspectives!

  • http://www.emailbeauty.co.uk/ Ash

    There is no denying it, RoR rocks. I think without that framework the Ruby language would still be kicking its feet along the ground. I have always been a PHP coder but since the ‘hype’ about Ruby and RoR I gave it a go and kind of hooked! I create more applications in Ruby compared to PHP – but that’s maybe because they supported Ruby better? I also think PHP is easier for newbies to ‘bodge’ in terms of you could cut corners to get the job done (using bad programming practises) unlike RoR were correct practises play a real part of the development for example correctly following the DRY principle.

    • http://envato.com Ryan Allen

      You’re probably right, Ruby would still be kicking along in relative obscurity if it wasn’t for one loud, intelligent and often contentious Danish programmer.

      • John

        I think most web development would still be kicking its feet along the ground. I remember what was available to us before Rails was released.

      • John V

        $moreaccurate = str_replace (“contentious”, “pretentious”, $abovecomment);

        DHH.

  • http://techinto.com rahul gupta

    Its shame to see nobody talked about Zend Framework which is far better then ruby on cart . I know java,c,c++,javascript,php,action script and hence can say ruby syntax are ugly and weired compared to them !!

    • http://www.michaelwales.com/ Michael Wales

      I’ve dabbled with ZF, to be honest – way to verbose for my tastes. My approach to this discussion was to view PHP as a language/framework in one (because it is) and assume any mention of Ruby actually meant Rails (since it’s the predominant framework for Ruby and you simply can’t remove the framework from PHP).

      • http://www.bitcetera.com/en/techblog Svoop

        I prefer innovation through competition (aka: gems) to the one framework has it all monolith (aka: ZF). And besides ZF, libraries for PHP are scattered on many webpages and a somewhat stalled PEAR whereas the Ruby community adopted Git and Github which now acts as a tremendous incubator for innovation.

  • http://www.jamienay.com Jamie

    Pretty useless – comparing apples to cars. The Ruby guy keeps on using Rails as a reference point to compare it against plain old PHP. Rails is NOT a language, it’s a framework. If you’re going to use Rails in the argument, then don’t compare it to PHP, compare it to a framework like CakePHP, Zend, CodeIgniter, etc.

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      That’s why we were comparing Ruby to PHP — not Rails.

    • http://www.michaelwales.com/ Michael Wales

      I agree to an extent – it’s impossible to remove the framework from PHP. This really should have been a PHP vs Rails discussion (which is what it amounted to), it’s impossible to compare PHP to Ruby (PHP is really nothing more than a web framework, disguised as a language; Ruby is a true language).

      With that said, I’d be happy to argue on Python’s behalf vs. Ruby. :)

      • http://tshawkins.blogspot.com Tim Hawkins

        ehhhh, “Its impossible to remove the framework from php”, there is no framework in PHP, if you are talking about the sapi interfaces, then they are just a language feature. But to argue that PHP has a “framework” embedded is ridiculous.

        PHP+Zend, PHP+CI , PHP+Cake, thats what you want to be comparing to Ruby+Rails, but PHP has no inherent “framework”

  • DED

    One of the issues that I thought would have come up, but didn’t is the problem ROR has with updating so frequently and breaking earlier versions. DJango has a similar issue, and I believe both even let you create virtual environments to help solve it. But when people try to learn rails from say a book that uses a previous version, they often show up on the forums confused about why the code won’t work as the book claimed. I think this makes learning anything more difficult. Where as Ruby updates less frequently than the ROR framework and is less likely to break earlier code. It’s not deal breaker issue, but it is one I’ve noticed causing frustration with learners , even experienced programmers learning the framework have this problem to some extent.

    • http://www.michaelwales.com/ Michael Wales

      Pretty sure I brought this up word-for-word…

  • http://www.binghamuni.edu.ng Mfawa Alfred Onen

    I was expecting some real “Blood shed” on this so called war but none the less, I enjoyed it since I got more insight on both RoR and PHP. I personally use PHP but RoR is another upcoming rival and may overthrow the raining days of PHP in the not so distant feature. Also good comments everyone, keep it going…

    • http://envato.com Ryan Allen

      If it would make you happy I could go punch some ducks! :)

  • http://www.cyberstream.us Eli Mitchell

    There was a good point made at the beginning:

    these debates are meant to outline why you might, in certain situations, choose one over the other.

    PHP and RoR are different tools. I would definitely recommend PHP as a first language to any interested person. It gives you a good understanding of how the Internet works. With PHP, you can start building and deploying simple applications with minimal knowledge. Rails, OTOH, can be confusing to a novice (it was to me, at first). Since it does so much of the dirty work for you, that can prevent understanding of the things that are actually going on behind the scenes.

    I think every developer should learn both. PHP functions lack the consistency in syntax that Ruby has, but it has functions for almost anything you want to do. PHP has unparalleled documentation, making referencing and learning even faster. If I was building a simple website with some DB interaction, it wouldn’t make sense to get out RoR. However, maintaining and expanding large websites (e.g. e-commerce) is easier with Rails.

  • http://www.shiftedwork.de/blog Daniel S

    The foreach comparsion from the ruby guy is poor – he compared a for-$i with the ruby foreach.

    Additionally, i think PHP is very powerful with MVC and CRUD Support. The biggest problem of php is that there are many people who just want to make the things work. I love OOP PHP and i will never change using it. I think there are many ruby coders who think they’re cool because they are using a “new” language.

  • http://newarts.at Drazen Mokic

    Enjoyed this, would be nice as a Podcast though.

  • bob

    having a cry because your language sucks?

    • http://envato.com Ryan Allen

      Haha, bob you’re the best guy ever!!!

  • Ashen

    “PHP is an amalgamation of language and web framework in one package, whereas Ruby is a programming language with numerous frameworks available.”

    That made no sense at all.

    There are numerous frameworks in play for PHP: Codeigniter, CakePHP, Zend. PHP syntax on its own is hardly a web framework, it simply has asptects of the syntax that are more intune with website constructs.

    • http://www.michaelwales.com/ Michael Wales

      How does it not make sense? PHP is a web framework, disguised as a language. Sure, there are other frameworks built on top of PHP; but that doesn’t change the fact that it was designed, from the ground up, to be a language for the web – it was never meant to perform lower-level system functions, to power 3D engines, to perform intense calculations powering satellites and rockets through space.

      It started as nothing more than a simpler interface to dabble with CGI and eventually received its own preoprocessor – it’s far from being a language, in the truest sense of the word.

    • http://envato.com Ryan Allen

      A number of years ago I read on Slashdot, something along the lines of “Well, PHP is actually itself a templating language, you can’t make any code execute without wrapping it in <?php tags!", and I was like, woah.

      The debate was for or against the use of engines like Smarty (I am against them – I want all access to language features inside a template). If you compare the way PHP works to the Ruby library ERB (in which you pass in a string, anything wrapped in tags are executed as Ruby), you’ll see the distinction.

    • Ashen

      The use of the term “framework” I feel is erroneous. By your logic we should be using terms like “Javascript Framework” and “Python Framework”.

      “but that doesn’t change the fact that it was designed, from the ground up, to be a language for the web”

      Now you refer to it as a language. Which is it, a framework or a language, or both?

      I know I am being picky about the usage of one word here but I just can’t see how you can attribute the word “framework” to a syntax like PHP, this is a Language War after all, not a Framework War.

      Do a Google search for “PHP Framework”, I am not coming up with any hits that describe the base PHP syntax as a framework, all references go up a level to products like Codeigniter, Zend, CakePHP, etc.

      • http://www.michaelwales.com/ Michael Wales

        When I use the term “framework” I am really meaning a web framework. PHP doesn’t do anything except generate web pages, at least nothing else very well.

        Now, look at languages like PHP, Ruby, even JavaScript – they do so much more! 3D engines, parsing large amounts of data, huge calculations down to hundreds of decimal places. No one in their right mind would attempt these tasks with PHP.

        In this article, Ryan and I had to attempt to come to some common ground in terms of what we were discussing because comparing PHP to Ruby just isn’t possible. It’s like comparing a Ferrari to Transformer – sure, the Ferrari is cool and all but all it can do is drive; a Transformer can drive, fly, swim, do whatever it wants.

        Regardless, we’re focusing on the word “framework” to much, let’s from here on call it Shiner Bock (because that’s the best beer ever). So, PHP is a language and a Shiner Bock in one – all it does very well is the web; whereas, Ruby is a language that Shiner Bocks can be hooked on to – without those Shiner Bocks it’s not very useful to most web developers.

      • http://tshawkins.blogspot.com Tim Hawkins

        I think Michael is mistaking php the language for mod_php the SAPI, the so called “web framework” he is alluding to is just the way php is bound to the container it is operating in, php also has a CLI sapi that makes it into a general purpose language. We use it to write all of our system scripts instead of bash, it easily has the same capabilities, and can support libraries easily too. You can write System_Daemons, complete with forking etc (which you cant easily do in bash), php has several extensions to support its role as a systems language, such as php_posix, php_pcntl, php_sysv* etc that make it not just a web language.

  • kankuro

    There’s one thing I would like say based on the debates above… everything in this world has an advantage and disadvantage…. and there’s no perfect language but a stable one..

    for a coders like me… choose the programming language that makes you happy or i would say a language that’s best for you, a language that you like… there’s no since of making an apps of system if you don’t like that language… :D

  • http://adbhuth.in aditya menon

    i’m now tempted to learn ruby because of Ryan’s comment : “The user group is great!!!”

    besides, even the great Phil Sturgeon has declared that he’s learning ruby right now. him being my idol, i’ll do whatever he does xD

    • anonymous coward

      My experience with the Ruby community is that they are a bunch of opinionated pricks. This was the reason I left Ruby and Rails a long time ago, and wont consider using them at all. I am not the only one, some big names in the Rails community ( http://techcrunch.com/2008/01/01/zed-shaw-puts-the-smack-down-on-the-rails-community/ ) left because of the community, and Rails in general.

      Go into their forums and ask a question, most of the answers are “RTFM”, or “If you don’t know, you shouldn’t be a developer.”

      At least with Django they are like here read this, this and this, and then this.

      I also don’t like that Rails hides a lot of their security issues.

  • http://www.circuitbomb.com Dustin

    PHP is not limited to the web. I agree that it is more tuned for web development, but it doesn’t mean that you can’t build stand alone PHP applications on the Desktop.

    • http://envato.com Ryan Allen

      What APIs do you use to make PHP applications on the desktop?

      • http://www.circuitbomb.com Dustin

        PHP is a web scripting language, it isn’t intended to be a programming language like your high level(C, ++, Python, even Ruby) or even some RAD platforms like Visual Basic, as far as I know building desktop apps in the sense that we know them is beyond the scope of the PHP project, but open source has its benefits. I don’t personally use any of these tools because I’ve not had a desire or need to use them.

        You could use WinBinder to interface directly into the Windows API, though I’m not quite sure how up to date it is. PHP does have Windows only extensions (aside from win32api, which is now a PECL module and no longer bundled with PHP) which let you do a myriad of things like even setup and run scripts as services.

        Theres PHP-GTK

        phc and roadsend are PHP compilers to build standalone binaries etc…

        As far as developing PHP with Adobe AIR / FLEX I’ve only read a small bit about it, and will admit I’ve never really even dove into those Adobe technologies.

      • http://www.michaelwales.com/ Michael Wales

        Uhh… Dustin, PHP, Python and Ruby are all scripting languages. Just because you *can* build desktop applications with PHP (and I’ve done so, with PHP-GTK – the first version of the WoWCensus uploader was PHP-GTK) doesn’t mean you should or that it was the intent of the language.

        Without a doubt, it’s not up for debate – PHP was designed for web application programming only.

  • Brett

    I have never used ruby nor php so am a complete beginner. This was a great read though and has really helped me in deciding what to learn first, php.

  • Doug

    I have to say my favorite thing about ruby is the community. When Ryan said he was with his people I thought I couldn’t agree more.

  • http://www.visual-blade.com Daquan Wright

    I’m majoring in Computer Science working with Calculus and Physics. =P I’m sure that critical thinking will come into play.

    As a stack of technology, I love apache/mysql/php combination for the back-end. Powerful, yet simple. As long as I focus on best practices, I’ll write good code in every language.

    If I needed to use a stronger system for back-end development, I’m sure what what I’d pick between Java/JSP or ASP.NET. Very interesting article, great talk guys!

    I love PHP as a language because of the flexibility it offers me. Just be disciplined…PHP can work for you or against you, depending on how you use it.

  • http://mimrankhan.com M.Imran Khan

    I think Ryan’s correct , but in some point like deployement of ruby have some downfalls when compared to PHP , nevertheless both have pros and cons.

  • http://www.wanged.com Charles

    I started off as a php developer, but eventually moved on to Ruby on Rails. The rails framework makes building web applications a breeze. You can pump out a ton of content within a short period of time and spend more time thinking of good solutions rather then spending time with the code. I still like PHP as a programming language since it was very easy to learn coming from a C++ background. I don’t think I’ve used one or the other long enough to assess a fair judgement, but Github + Rubygems definitely pushes me towards RoR.

  • http://pavelpichardo.com Pavel Pichardo

    mmmm… this got me thinking, I’m a seasoned php developer and I’m about to start a new personal project, maybe I should try ruby on this one and get my own conclusions. :)

    Very nice interview btw.

  • arkel

    Ruby or PHP no difference it’s developer who made a difference by spirit, philosophy and affinity with the language.

  • http://www.putneymartialarts.co.uk Dan

    No one has mentioned the PHP manual ( php.net ). I went from HTML, CSS & JS and thought I need to learn to make a proper functional website. PHP with its massive online community made it easy to get to grips with. My friend a Ruby Developer who hosts some of my other sites using Ruby on Rails and Mephisto hassles me to learn Ruby all the time. He says “languages are like restaurants, PHP is fast food and is fine, but if you’re taking a girl on a date you want something nicer like Ruby”. Anyway I disagree with him but I gave learning Ruby a quick go. I will keep at it but the available free knowledge on the internet is much less so its harder to pick up for me.

  • Saulo Matias

    I enjoy discussions like this! Gives a good overview for beginners and mature opinions of who knows more about PHP or Ruby.

  • http://konradstrozik.com Konrad

    There will be more Ruby/PHP ‘wars’ because their popularity falls a lot
    http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

    If it comes about performance python is much faster than both ruby or php.
    Python frameworks are also much faster than RoR or php frameworks, there is a lot of tests on net,
    and another important thing Google using Python in GAE, because it is fast (performance), fast and easy to write etc. etc:)

  • http://www.up2speedmedia.com Adwin

    I’ve not had experience with RoR yet, but I agree that PHP is a good language to learn if you are just getting into web development. However it’s main weakness is that the syntax is too loose and it allows novice developers to get away with writing sloppy, insecure code. This has given PHP its bad reputation. I also believe a lot of online PHP tutorials do just focus on getting things done, rather than best coding practices.

  • kisin

    django rules!

  • http://www.rebatesense.com RebateSense

    Even though I love Ruby on Rails (naturally!) the deployment overhead and too much magic behind the scenes were the main killers for me not getting my hands dirty with RoR. There is no way it can beat the convenience of copy/paste CodeIgniter convenience. And, oh btw, with CI it is a breeze to carry your web app in a thumb drive and get productive on any machine that has PHP. I’m finding that as a real convenience.

  • Mike Rosas

    interesting, this is the first time I read about RoR in an interesting way, you see, I come from an older generation of programers, when we used languajes like Basic, Pascal and DBase, it was refreshing when concepts like modular programing and OOP came along with C/C++ and Java, and even more defying when the programing started to get a little more complicated with languajes like C#, Delphi and Visual Basic, When I had to put a side software development and started working on web development it was kind of hard, it was almost imposible to empty a cup that has already been filled, and to be honest I started with perl but it wasnt until I used PHP that I felt in a comfort zone again, RoR looks more apealing but at my age and after my history of programing languajes ill go with something more conservative.

    I define PHP as a little more “traditional languaje” and RoR as the “new hip” how ever both does deliver at the end, its not about wich one is better or faster to code with, its not about wich concepts are easier to learn or how far can I expand my code, its all about the programer.

    if its a good programer then it doesnt matter the languaje, he will make a great job, if its a bad programer then it doesnt matter the languaje either, he will make a bad job, if its a new programer it doesnt matter the languaje, any languaje will be equally hard to learn but if its an experienced programer then he will defenetly find PHP easier to learn.

    Regards.
    P.S. Excuse my broken english.

  • http://davegardner.me.uk/ Dave

    “There are plenty of ways to write clean MVC-based PHP.”

    Very strange assertion. There are plenty of ways to write clean PHP! MVC does
    not necessarily equal clean PHP, as I’m sure many people have experienced themselves.

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      Well certainly that’s true.

  • Calvin

    Ruby beats PHP if we’re just talking about the language. It has a nice syntax and offers some fancy meta programming features. It shares some features with javascript which I consider as a bonus point. PHP is ugly (I never liked the $ before a variable name) and is bloated with functions (actually this is a good and a bad thing… it is good that there’re so many functions but… the lack of OO is bad/evil) with inconsistent arguments and/or naming conventions.

    I feel that the discussion is more about the frameworks that the languages on their own. RoR is awesome but Zend is also great. Do you love ActiveRecord? Then you’ll like Propel too. Is Zend too bloated then you can take either CodeIgniter or CakePHP (or even WordPress or Drupal if you’re building a CMS).

    RoR is about conventions and consistency. It’s about design and good architecture just like the language it is written in. PHP and the frameworks haven’t archived that level yet (PHP never will because of it backwards compability) but as frameworks mature I believe that the differences are getting smaller and smaller.

    PHP offers more options in hosting and frameworks which is probably its most important ‘asset’ because the day that every host offers Ruby hosting for the same price and that more frameworks are build with Ruby is the day that Ruby will rise.

    Money still rules the world! The *AMP stack is so standard that it is cheap to build/maintain… *AMR is not that common and that scare newcomers away.

    note: I still develop in PHP (Drupal and a bit of Zend). Used RoR a long time ago for one project.

  • A_Minko

    Ryan, why you use count() function inside a for loop? it is generally a bad practice in php..

  • http://bhu1st.blogspot.com bhupal

    @Jeff i just love reading your articles and tutorials. thanks for this share. The title says Language War: PHP vs. Ruby but the stuff going on is Language (PHP) vs. Framework (Rails) war. i will be waiting to read a rather more specific kind of post like, PHP Frameworks vs. Ruby Frameworks that will make a lot sense.

    On thing,
    Ruby has hype, vibrancy, and sex appeal.
    did it mean
    Ruby On Rails has hype, vibrancy, and sex appeal. IMHO, but not Ruby as a language. i never heard Ruby before i heard Rails.

    for most of people who are from background of C/C++ and derivative languages, PHP is the similar in syntax and easier language to start with to learn web stuffs.

    Web is diverse choice of technology, and you never know when you need to use which tool. What i would say is – don’t depend on PHP alone or Rails alone – there are more hot stuffs emerging (Node.js).

    • noname

      Right, i’ve been learning C++ for a year in university, so when i found myself as web developer, I actually didn’t have to learn anything when coding PHP. Plus, C++ background brings a vast amount of low-level knowledge, as well as OOP, which ables to write a high quality code on PHP.

  • Mr Z

    PHP and Ruby both have a place in the web programming ecosystem. Just like different hammers have a place in the builder’s toolbox. Some folk have a favorite hammer, some don’t. Personally, as I have to learn many types, I’d rather just choose the tool that does this particular job better or faster.

    Seriously, this type of argument is only valid when the ONLY thing you are doing is web development. Asking if it is a good first language is silly. The appropriate question is whether one or the other is the best first language for a web developer. Neither will help you develop code for embedded systems in any particular fashion.

    I’m still looking for a fact based comparison table between languages. Yes, it would have many rows, but it would be nice to see the facts of what each does, and a peer rated scale of how good each feature/function is. And finally, a comparison between languages for developing the same code functions. In this case, a web site with a set list of features. It might be said as build a website with one and port it to the other language – now what problems did you have? How many lines of code did each take? How well does each perform in real life? What is the cost of ownership for each.

    You know, real apples to apples comparisons.