Get $500+ of the best After Effects files, video templates and music for only $20!
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!

Add Comment

Discussion 182 Comments

Comment Page 2 of 2 1 2
  1. BBM pins says:

    If this is a war, its is like USA fighting Botswana (where PHP is USA)

    • H D says:

      Wow… put a little more faith in the US. I mean… Sure we are fighting multiple wars… but we could still win against Botswana.

      Maybe you just had a typeo… Blasted auto correct (or what ever you windows users call it)…

  2. Raven says:

    Certainly. Ruby has more advantage when it comes to scalability and some other stuffs (At least that’s what I know) but PHP is more faster to launch, it’s easier to learn (when you already knew frontend coding) and has a lot of documentations and examples for a web developing newbie like me.

    • Halil says:

      Iterating over a defined iterable is not the same as looping from a number to another, using arbitrary step sizes, possibly breaking/continuing according to some constraints. Both have their use and there are many examples where you can’t use generic iterators over a for/while loop (at least sanely). On the other side, if you do not want to know what’s happening under the hood, PHP has a tool for this, too: foreach (which supports much more than simple arrays, especially with many built-in/custom objects which implement Traversable interface in PHP 5+). I hope our giving-examples-in-face-of-war literacy improves sometime…

      PS: I hate hating, and try to be language-agnostic, as none of them is holy grail, they are just tools. But you should know your thing, right ;)

      • Halil says:

        Note (to moderators): I started my previous comment as a reply to Raven, but then dropped the idea and wrote a stand-alone comment. But I forgot to cancel the reply mode and enter into the new comment mode :) So my previous comment was intended to be stand-alone. If anyone is curious about the original idea, I was mentioning the time Twitter was facing serious scalability problems.

  3. Droid says:

    But the fact is, that Ruby is a beautiful, code-saving and synoptical language. And the Ruby programmers are definitely more productive.

  4. Ed Rackham says:

    Ok, I stopped reading at the part where Ryan makes a really bad attempt at putting his point across with regards to looping over arrays (and that the Ruby way is “better” than the PHP foreach loop which he admitted is “not to bad actually!”).

    Maybe the rest of the article was good – but wasting a few minutes re-reading that section, looking for his point exactly, really ground my gears. If you can’t grasp a basic for loop, that’s pretty shocking for a programmer.

    • Evan Byrne says:

      Same here. I just knew it was going to be stupid when I saw that horrible for loop example.

    • Jay says:

      That was exactly where I stopped reading as well.

    • Clay says:

      I didn’t stop (felt compelled to get over my bias and read tho whole thing) but damn sure wanted too. The thing about it too is Ryan’s whole argument about syntax seemed way off. I think PHP has its shortcomings but not declaring variables with a token or the like is immediately harder to read

      $read // php

      read //ruby

      if i show you both out of context you can clearly tell a var in PHP but you wouldn’t be able to tell me what ‘read’ meant in ruby), and same with property vs method

      $foo->bar // php
      $foo->bar() // php

      foo.bar // ruby

      is bar a property or a method, do you know anything about the data you’ll get from foo.bar?

      • DissNig says:

        I still use basic loops, sometimes you want to iterate over elements and need the index, it doesn’t look ugly or difficult to grasp, if you have a clear understanding of what you are iterating and it’s length with explicit variable names it’s a cake walk even for newbies. Not to mention you rarely need to set a step that counts more than once per iteration:

        for( $line = 0 ; $line < $fileArr.length() ; $line++ ) { … } //Win in my book.

        You should also abuse the fact that line only exists in the scope of that loop, so you should never be afraid to use a shot and sweet name for your index.

      • Srivatsa says:

        I am a newbie in the programming world but I just want to answer your question in my understanding of ruby.

        In Ruby you cannot access a property outside the class directly and the only way to do so is by its getter. If you have a method same as a getter the former overrides the latter

        So foo.bar will pass object foo ‘bar’ to respond. Its upto the object to respond with a getter or method. If nothing exists throws NoSuchMethod error

      • John says:

        @Dissnig
        or->

        foreach ($fileArray as $index => $file){
        echo “file #”.$index;
        }

    • oxygen says:

      I stopped reading at that Array iterator example too.

      He said “shopping_list.each do |shopping_item|” has less syntax in it
      and he doesn’t screw it up, as in “unacountable numbers (no pun intended)” in PHP.

    • Justin says:

      You are so right! That loop example did not make any sense. I feel that I will have to learn some Ruby when I jump back into the workforce. I am currently developing a startup mini social network niche that will be directly tied into Facebook utilizing PHP and MySQL.

  5. Aitor says:

    Trust me!

    Learn both!

  6. Alex DeLeon says:

    Since when is RegEx good for parsing in the first place? Wait I’m getting the sense that neither contributor even knew that and has no knowledge on how to write a real parser either. You admit Php’s engine is faster but that Ruby would be better at parsing when they both use RegEx. Logically is they use the same search system the one that executes faster would win. I question the skill level of both of the chatters. One said he couldn’t grasp basic for loops so he liked Ruby because it had an object that did it for him so his poor brain wouldn’t hurt. The other guy couldn’t hack it as a Php coder and couldn’t even write a simple CRUD lib. Ruby is for spoiled kids who don’t know real coding and need the language to hold their hands. I bet neither of you could code in C(since php is C for the web) and the mere thought of having to write all the functionality for a program yourself with only base functionality and data types has you crapping your pants. One guy says low-level get serious you don’t know crap about low-level and if I asked you to transform
    int age;
    age = 0;
    if (age == 0)
    {
    printf(“you are not born yet!”);
    }

    into its assembly instruction set he couldn’t. Don’t speak about low-level when you don’t know it yourself or else guys like me who do will pull your card and make you look stupid in public(try JNZ I made it simple for you). Ruby is so special because it comes with everything I need and I don’t have to worry about data types matching up or not having an object for everything. Learn a real language like C or Fortran and then talk about being a real coder kk.

  7. Greg says:

    My fist language was PHP than because I always want to learn I started to play with Ruby and RoR. After the first problems with understanding the deployment etc I was totally amazed both from ruby and RoR. I think as a language ruby is far more complex and better than PHP.
    Unfortunately at my job I need to use PHP these days so ruby and RoR is just for home playing in the momemt. When I faced with the issue I need to use PHP again at work I tried to find a RoR like framework in PHP and luckily I found the yii. With the framework I am quite happy to code in PHP because it handles very well the relations, there is a good console script solution for background processes etc. So if someone wants to learn PHP I recommend after the basics of the language to try yii.

    • Nancoder says:

      Same here! I love Yii! Is very well documented and the community is awesome.

    • drock says:

      Agreed. Was stoked when I started using Yii… a clean break to OOP PHP 5 without all of the old cruft. http://lithify.me/ looks pretty good too but I haven’t used it and its still pretty new

    • Joel says:

      I feel so old. My first language was some form of Basic back in about 1986. I don’t even remember what it was called. My first computer required a tape player (the flat kind you snapped cassette tapes into) to save any work. My second computer was a Commodore 64. Basic and Pascal in high school. We only had 3 students studying Pascal my senior year and the first semester we all spent in the library writing our code on paper since the school didn’t even have Pascal compilers purchased yet. My first “professional” language was COBOL in the Marines, followed immediately by JCL.

  8. w1sh says:

    I belong on the back of A TRUCK! Jello in my hair! All submarines…

  9. Scottzozer says:

    I enjoyed to interview. Few problems is that they both kept saying the same thing in almost every question. Each developer uses both so it wasnt really a VS. battle. When programming it comes down to two main 3 major things, in order; cost, security, and speed. Php is fast, rails is modular. I agree about one thing though, a common standard that is going come into play is HTML5 but that really just a way to get rid of flash.

  10. Rickey Otano says:

    Personally it was way biased and one sided. This was not as the title said a Php vs Ruby talk. It was a Php and Rails talk. Using the old excuse that Php used to be a web frame work was just the devs manipulating data which is no longer true to prove a now baseless point. Don’t get me wrong Ruby has its goods but it also raises coders who don’t know how to actually code and are essentially being babied. @Sitebase I can guarantee you 100% that a for loop can iterate a numeric array faster then a foreach loop can. Any real coder knows you use foreach only on associate arrays because of how they are created(If you don’t know I suggest looking up hash algorithms). To us C coders Python and Ruby coders are the butt of our jokes because you need hand holding to code a decent app. In Ruby’s defense it does cut down on coding time and is easier to learn but you miss out on the how it works notion. I’ve never met a Ruby coder who could code an algorithm in Ruby such as Boyer-Moore. I blame the microwave society for this, and soon some uber easy language will replace both languages.

  11. jd says:

    This article is not valid.

    You can’t compare a programming language with a framework.

    Now write an article about RoR vs Zend or Cake and we are talking.

  12. aditya menon says:

    in the first line, i think you meant to say “CUE”, not “queue”

  13. Mahbub says:

    I’ve been doing PHP for over 10 years and studying Ruby (not only rails but other frameworks like Merb). But recently i decided to shift my efforts on Python (using web2py framework) which seems more promising in the current trends. The development, deployment and migration is unbelievably easier in that framework.

    Anyways, the arguments against PHP can all be refuted. And i strongly feel that if PHP wasn’t there, the amount of web development till now (good or bad) would be much less than what it is now. Let alone WordPress which is written in PHP is serving millions or probably billions. It’s not common for other web programming languages. WHY ?? So people who speak against PHP and try to make themselves special for their favorite language appears funny to me.

    But I’m no Ruby or ROR hater and I think Michale was right on the point that only people with Good Understanding of Programming and OOP concepts should start Ruby otherwise the magics of Ruby won’t just be magics.

  14. Stephen says:

    My only problem with Ruby, and Python, is the indentation to show scope, nothing makes me rage more. Not to say my code isn’t indented but I think it’s a lot easier to find the curly brace, match it with it’s closing brace, and you can quickly see your different methods and functions and what’s going on inside.

    I should note that I learned to program using Java so moving into PHP was a breeze, somewhat (see: method overloading).

  15. Jonathan Sells says:

    I would really like examples or reasons why Ruby/RoR is better/ more well suited for a project than PHP.

    These debates always seem to come down to preference rather than objective examples of why a language / framework is better. If ruby is easier to code with(once you learn and install it) thats fine…but does it give me that much more tools to justify my time investment?

    I’d prefer this article of both authors were violently opposed to each other – trying to highlight the strengths and weaknesses of the languages themselves.

  16. Ardi says:

    Ruby or Php?
    bad comparison language.
    But i choose PHP

  17. Purab says:

    I also worked on Ruby and PHP. I worked on php for last 9 years and in 2006 I stated working on Ruby on Rails.
    I must say Ruby is much more powerful and extendible than PHP. Ruby is purely OOPs base. Sting to object all things are object in Ruby.

    But the only bad part about Ruby is scalability and speed. That why people choose the PHP over ruby.

  18. Odyssey says:

    Ruby hands down. Rails frame-work is THE programming code for the future.

  19. Mohamed Cherif BOUCHELAGHEM says:

    I used php for more than five years and the best framework for me is yii cauz it has modular architecture and i can build projects with high scalability which is the an issue with php i did not try ruby yet but i think is pyhton who can take place of php not ruby so if there is a war is between Ruby and Python directly cauz php now still the de facto in backend web developement but here to 5 years i think python will take this place especialy if zend and rasmus lerdrof fail in the version 6 of php beacause they already have some issue with the unicode and some new features that are already exist in Python and Ruby.

  20. newlang says:

    1.php have C/java syntax that are much more easy then visual basic/rubi/python syntax.
    2.php – have to check every method if parameter passed by value or reference.
    3. rubi/php hard to debug vs Java/#C

    conclusion:
    best to have rubi structure and methods with php syntax and variables types like in java/c int x and not $x

  21. Tim M says:

    I’ve never heard such praise for Active Record before. It might make things easy, but easy is also inefficient. It produces awful SQL inefficiencies which are hidden from the programmer, going on in the background killing your throughput. Great for small projects with low volumes of traffic maybe.

    • Greg says:

      “Don’t waste time on problems you don’t have yet”
      with active record you can quickly build up a startup and than when you will have a scalability problem you will have probably income so you will not worry to spend time on refactoring your code and find the performance bottlenecks.

  22. Ming says:

    Comparing Rails to PHP is stupid. Despite what some people say PHP on it’s own is not a framework just because it offers easy access to the environment’s input and output (do cin, cout or getnenv() make C++ a framework?).

    If you’re going to judge the two on equal footing you have to add something like Symfony or CakePHP into the mix. When that happens alot of the common complaints levelled at PHP by Rails users fade away pretty significantly, and Rail’s own downsides suddenly matter alot more in comparison.

  23. Роман says:

    Автокондиционеры-установка на отечественные автомобили, все грузовые, трактора, сельхозтехнику. Заправка, диагностика, ремонт г.Орехово-Зуево. продажа комплектов для самостоятельной установки автокондиционеров на отечественные автомобили.

  24. Sam says:

    I think the article was written so you had something to post, and there is nothing more than that to it.
    Reasoning? oh no !!!!!!

  25. Елена says:

    Служба знакомств «Elmi» – это обширная база данных по всем городам Севера Израиля, персональный подход, разнообразные методы работы. Мы предложим ту форму обслуживания, которая подойдёт именно Вам. Для нас важно, чтобы Вы чувствовали себя уверенно и комфортно. Мы вместе с Вами работаем на конечный результат.

    Мы работаем в Хайфе, Краёт, Хадере и других городах севера страны.

  26. Boabramah Ernest says:

    For me it is about being able to write good code, eg. when to use foreach and for loop. Able to know what is going on in the background. I actually do not like everything done automatically for like a window installer.

  27. Aleksey says:

    TextExpert – недорогое и быстрое размножение статей. У нас Вы можете заказать копирайт текстов любой сложности.

    Копирайт, рерайтинг, написание статей и рекламных текстов – огромный опыт, эффективные решения, помощь в оптимизации вашего проекта. Также Вы можете заказать рекламный текст или слоган.

  28. WTF says:

    Omg , what about spam filter in comments ? Comments full of spam on russian lang.

  29. JON says:

    - I am a robot, I think humans are stupid, but I only get 0 and 1 … that’s all.
    - I’m a boss, I only need results … how … not really important!
    - I am a child; New technology is part of my life … and I want the information in a transparent …
    - I am a pragmatic programmer, but the time to show me the right way … unity is strength … And in ten years PHP, Java and Ruby is an obsolete technology, displaced by a more universal, easier to use technology to the health of many programmers …
    - I am an ET, who thinks the man is very slow, with its archaic concepts of databases and programming languages so inflexible, always limits, rules always, always bugs … this is the best they can create? best together towards overcoming its limits this is the first language to be learned …

    • Joel says:

      I’d like to argue that, of the 3, history tells us that Java is by far the most likely to still be around and relevant in another 10 years. It is, after all, over 15 years old, and has been relevant for all of that time.

  30. Edgar says:

    I’ll say this I start doing web development 3 years ago and like most of us I started with php at that time I didn’t know much about web development I only new a few bits of html and css and yes I was using dreamweaver I move on to Komodo Edit this days I think is a much better editor.

    Anyways php is kind of easy when you start but it can get messy and complicated in not time mixing html and php tags all over the place.

    Rails is a bit more complex to understand because is OOP especially if you are starting but things get pretty easy after you figured out that part, I love ruby syntax is so simple and you don’t to worry too much about closing tags after every line. deployment thanks to heroku it’s a breeze.

    I wish php was as simple as ruby
    and I wish was rails as fast as php

    for now I’m sticking with rails for work and fun and decide to learn more php as side thing.

    • Joel says:

      PHP CAN be as clean in format as other languages. It just takes more thought. I agree that it is a potential issue with the language that the syntax encourages mixing markup and logic. ASP is like this as well. As is JSP. However, you don’t HAVE to do it. It just takes a little restraint and thoughtful planning and organizing. The Zend framework, for instance, can somewhat alleviate the mixing of php and html, though not entirely as the view will often have php inside it. Generally, however, this is simply echo statements which output the html using a method of the current object.

  31. Madhu says:

    I this both are great in their own universe.

    As i am web developer I prefer PHP.

  32. kovpack says:

    i’ve got acquainted with php long time ago (2006), cause i needed to make one site (dictionary). after that did not dealt with it till 2010. so, at this moment i’ve developed only a few quite complicated sites without any framework. now i started learning kohana. wanted to learn ror, but found a few probles: 1) i don’t like ruby syntax; 2) application on ror works ok on localhost, but going online is not that easy sometimes (it’s ok if you use heroku etc., but not many hosters support ror); 3) ror applications are too heavy for shared hosting and i don’t want to pay 50$ / month for vps to write a blog in ror; 4) if you decide to make quite visited site and axpect 1000 visitors a day, you need vds for that task, but if it’s not commercial site – it’s too expensive. and if you really want to learn ror – you have to know basics of server configuring etc. and that is time and money. so, for many reasons php and it’s frameworks are better that ruby and ror. but i tried to work with ror – and code is really “sexy” as ror community usually says.

  33. Joey says:

    Only dabbles around with ROR a bit, but it really seems like a framework more then it is a language so how in the heck are we comparing it to PHP which is a language?
    If you want to make a real comparison compare it to frameworks within PHP such as CodeIgniter, Cake PHP and the like.

    So just for the fact that ROR is more a framework and not a language i would much rather stay with a language that offers numerous frameworks then focus my time on a language which basically is a frame work.

  34. Bill says:

    No ofns, but even comparisons to things like “Enumerable” (albeit, cutesy and all…) I agree with a few of the previously stated entries… if one doesn’t understand the basics of programming, it’s rather barbaric to think that one language supercedes another… they’re tools.

    BTW, FWIW and FtRecord… Underscore.php is a fine example of people being able to do similar such things as Enumerable [did!], and one small screw tightening like this package, unlocks 80-90% of features like Enumerable (in one fell swoop).

    http://brianhaveri.github.com/Underscore.php/

    It’s like most languages, and such, they’re a tool for a task, and as stated with re: PHP above, Ruby has had its days and will continue to do such… and with it… an onslaught of other languages will be thought of, produced, marketed, etc… much like Ruby has taken it’s opportunity to do such.

    Again, FWIW. :)

  35. Thor says:

    I am very psyched when it comes to web development technologies such as PHP and Ruby on Rails. Sop much that I have decided to focus on these for my academic research, where community feedback is a part of my report. I hope this is OK with the owners of this forum, but I have a quick survey here to gather feedback regarding the differences between PHP and Ruby on Rails and I’d really appreciate some participation. It will only take a few minutes.

    http://kwiksurveys.com?u=phprubyonrails

  36. Jason says:

    It’s funny when people say PHP syntax is ugly and Ruby is just so amazing and beautiful/sexy, I wonder why these Ruby addict don’t say the same about C, C++, C# and other similar languages as there syntax is very similar to PHP. Python and VB have a similar syntax to Ruby but all the C based languages, just kind of funny how PHP is the only one they ever try to pick on in that sense.

    Also PHP5′s OO is not bad at all, I code with PHP and Ruby as well as C# and JS but I prefer PHP over Ruby for a lot of reasons, I won’t bash it like the Ruby devs try to do with PHP though

  37. Arty says:

    The problem with Ruby is that is enables bad programmers to do be employed, and bad programmers build bad products regardless of what language they use.

    As someone who started programming on slow processors with no memory; it was a time when if you didn’t know what you were doing, you did something else. Now every clown with a PC is a “programmer”, and the proliferation of crap is pervasive.

    There are a lot of bad (big, well-known) sites built on rails. Mainly because it allows people who don’t understand how to write efficient programs to pretend to be programmers.

  38. Lilian says:

    I hate how Web Developers are lazy and are afraid to use their brain to do something…
    “I knew relational databases rather well but was sick of writing the same SQL over and over.” – oh Web Developers and their lazy asses…
    As my programming teacher said once “If your mind is not good enough for programming but you still want to make good money, you can go into Web Developing because it’s easy to learn, doesn’t require to have a brain and gives good money”

    • Paul says:

      I think you might be confused, regardless of whatever stigma you and your programming teacher have against web developers they aren’t being lazy when they don’t want to write the same SQL over and over again, but instead are attempting to optimise their workflow. Being a more productive programmer is being a better programmer, as long as you maintain proper abstraction you should never get into the situation where it ties you down in future development.

      Obviously your programming teacher never taught you the principles of DRY.

    • Dan DiGangi says:

      If you believe that we “web developers” are lazy then you would have to be a poor programmer to think that rewriting the same SQL syntaxes repeatedly is better then creating turn key solutions that eliminate doing the same work over and over.

      -DD

  39. recon says:

    when the language and framework does everything for you then you are not programming any more just connecting scripts.. no fun.. ask many programmers today if they can write a recursive function in a non-recursive language and they would not have a clue…

Comment Page 2 of 2 1 2

Add a Comment

To add a code snippet to your comment, please wrap your code like so: <pre name="code" class="html">YOUR CODE</pre>. You can replace the class name with "js," "css," "sql," or "php." If there are any "<" or ">" within your code, please search and replace them with: &lt; and &gt; respectively.