-2

I've been a front-end developer for about two years now, and I'm attempting to break into the server side of things. Ideally I'd like to work for a startup social network on the back-end side so I want to try and be as marketable as possible.

In my quest to learn a new scripting language I've dug myself into the PHP vs Ruby hole. What are the main advantages and disadvantages of the two? I would really appreciate words from experience with the two, but will settle for any experience.

Cheers.

closed as off-topic by gnat, GrandmasterB, Bart van Ingen Schenau, thorsten müller, user16764 Mar 2 '14 at 16:11

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about what language, technology, or project one should take up next are off topic on Programmers, as they can only attract subjective opinions for answers. There are too many individual factors behind the question to create answers that will have lasting value. You may be able to get help in The Whiteboard, our chat room." – gnat, GrandmasterB, thorsten müller, user16764
If this question can be reworded to fit the rules in the help center, please edit the question.

  • I think it comes down to expressiveness vs deployment. – elclanrs Mar 2 '14 at 8:39
0

I've been a PHP developer for about five years, and in the last year I started looking into the Ruby (on Rails) world. I'm never going to go back. Here's why.

Inconsistency

I was displeased with PHP mostly because of its inconsistency: PHP was originally intended as a tool for amateurs, and it couldn't cope with the exponential growth it has seen over the years. In PHP you have random function names, random parameter order, random return values, random error handling and lots of other randomness.

Object-orientation

I was looking for a language that was truly object-oriented (i.e. a language where everything's an object) and that had a beautiful syntax. Ruby seemed to be the most appropriate option. Sure, it has its problems like every other technology (I don't really like this monkey-patching stuff, and Rails in particular seems to be quite slow compared to other frameworks).

Syntax

This is a subjective matter, but I'll put it anyway. I wanted my code to be expressive, concise, and beautiful. To me, PHP code has always been an ugly mess.

Here's an example: suppose that you have an array of objects and that you want to call a method on those objects and sum the returned values. Here's the PHP code for it:

array_sum(array_map(function($object) {
    $object->foo();
}, $objects));

Not so bad, is it? Here's the same with Ruby:

objects.collect(&:foo).sum

Now, this might seem a small improvement, but when you're writing lots of code I can assure you that it does make a difference.

Community

With the birth of modern web frameworks like Symfony (God bless the authors!) and Laravel this situation has slightly improved, but this point is still partially true.

The PHP community is terrible: most of them have no interest in improving the tools they're working with, and just care about getting stuff done as quickly as possible with as little effort as possible. The amount of wrong/outdated information about PHP out there is impressive.

That's why I've decided to maintain the Italian translation of PHP: The Right Way, even though I don't use PHP anymore. I know that PHP isn't going anywhere, at least for the next decade, and I'd like to improve all the terrible spaghetti code that I've read over the years.

What is PHP good for?

As I've said, PHP is a language designed for amateurs. All web hostings out there support it, and you can just upload your script through an FTP client and let it run. This works well for small applications that don't require a lot of design or maintenance.

All the other technologies, on the other hand, require a bit of setup and tweaking to work well, but it pays off in the long run.

Further reading

There are many rants out there about PHP. The best are:

  • 3
    "PHP is a language designed for amateurs... This works well for small applications". So you consider Facebook, Wikipedia, Flickr, Digg and Yahoo to be small applications written by amateurs? – tcrosley Mar 2 '14 at 15:44
  • I have written it's designed for amateurs, not used by amateurs - there's a difference. That big companies use PHP means nothing: good engineers can make the best out of a bad tool, and no reason could justify migrating an application the size of Facebook to another language, as one of Facebook's engineers has already stated. – alessandro1997 Mar 2 '14 at 16:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.