Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

As you might have noticed from the title, this is not a "PHP or Ruby", or a "PHP vs. Ruby" question. This is a question on how to leverage PHP + Ruby in the same business.

I myself am a PHP developer, I love the language because of its convenience and I specially love the ecosystem of resources that surround it: Joomla, Drupal, Wordpress, Symfony2, Doctrine2, etc. However, the language itself can be a little disappointing sometimes.

OTOH, Ruby looks like a very beautiful language and —from studying it superficially in several aspects— I could say it is leaner than Python as a language per se. However, from what I've seen there is pretty much only RoR making noise, and I don't like RoR so much (mainly because its model layer).

As Co-CEO and CTO at my company I'm trying to think outside of the box since I want to start to focus on the human side of technology and see if its sane to use both PHP and Ruby. Here are some random thoughts:

  • Ruby folk seem to be generally better suited programmers than PHP folk (in terms of averages), I know the previous statement is somewhat baloney because very good and well architected PHP can be written, but I'd say the Ruby programmer culture is better than PHP's.
  • The thing about Ruby is that it seems better suited for rapid development, I don't really know if this is only the case for RoR, but I do know that there are certain practices (perhaps not so good) like monkey patching that let business needs be satified quicker.
  • From a marketing point of view (yep, sometimes you need to leverage the marketing BS for the sake of your company) Ruby seems better while PHP carries some stigmas.
  • PHP 5.4 is bringing traits, and that is better/cleaner than mixins. That could really make PHP as lean as Ruby —or more— for certain stuff.

Now, concretely, my questions:

  • Would a PHP programmer want to learn Ruby?, I know I do, but conversely, would a Ruby programmer want to learn PHP?.
  • What kinds of projects or situations would be better suited for Ruby that are not suited for PHP?.
  • What is the actual ecosystem of Ruby?, aside from RoR, I have not seen other hyped technologies/frameworks (I've seen RSpec, but I confess being a total noob on what BDD really consists of and its implications).
  • Supposing there are a certain type of projects ideal for Ruby, would there be a moment that its better to move it to PHP?. I know PHP can handle lots of stuff, but I've read that Ruby has its limitations when scaling (or is that RoR?, or is that baloney for both?).
  • Finally and most importantly, would it be sane to maintain projects in two languages?, or is that just stupid. As I said, it looks like Ruby is leaner on the short term and that can make a project happen and succeed, but I'm not so sure about that on the long run.

I'm looking for insights mainly from people that know well the strengths and weaknesses of the languages —preferably both of them— and Ruby's ecosystem in real practice, meaning: frameworks and applications like the ones I quoted from PHP's ecosystem.

share|improve this question
add comment

3 Answers

up vote 6 down vote accepted

Keep in mind, while reading my answers, that my PHP experience (> 10 years) is much higher than my Ruby experience (a few weeks of playing with it; no live project yet).

Would a PHP programmer want to learn Ruby?

Personally, I came to Ruby while looking for a cleaner language for web development (especially when it comes to multibyte string awareness) and server-side scripting (my OSX bash scripts always seem to have a niggle or two when they're run on my FreeBSD server).

Before trying it, I had been toying with Lisp, Perl, Python and Node.js. I eventually abandoned Lisp because of the lack of a proper editor (it's emacs or nothing, and I hate emacs with a vengeance), the weirdness in building a web app (there are tools, but they don't feel natural to use) and the occasional quirkiness (I'm watching you, car, cdr and cons). I quickly dismissed Perl as just as stinky as PHP when it comes to multibyte string awareness. I didn't like Python much (it's just a taste thing; I've absolutely no valid reasons). And while promising, I stroke Node.js as too young and overhyped. (I considered Erlang, too, but never went beyond a tutorial.)

Conversely, would a Ruby programmer want to learn PHP?.

(...) Finally and most importantly, would it be sane to maintain projects in two languages?

I can only speak for myself here, but the more I play with Ruby, the more I feel like puking whenever I read or write PHP code.

What kinds of projects or situations would be better suited for Ruby that are not suited for PHP?.

Anything that involves UTF-8 string handling, for one -- which arguably includes everything web-related. It's like, yes, in PHP there are the mb_* functions; and the Intl classes; and the /u modifier for the preg_* functions; and... As a PostgreSQL junky, I've come to take UTF-8 handling as a given. It's the kind of thing I don't want to be worrying about, especially when it comes to libraries, beyond locale-specific issues such as case and collation.

(Ruby is not absolutely perfect in this respect, by the way. Python is a bit better. But I'd rather have mixins. In 15 years of coding, I've seldom needed to sort non-ascii strings outside of a database, or case-handle beyond transliterating bits and pieces that make it into a URI.)

Shell scripting is another. PHP can be used for this kind of stuff too, but the language's inconsistencies and messiness makes it a lot less pleasant.

What is the actual ecosystem of Ruby?, aside from RoR, I have not seen other hyped technologies/frameworks (I've seen RSpec, but I confess being a total noob on what BDD really consists of and its implications).

There actually are several other frameworks than Rails: Merb, Camping, Ramaze, Sinatra, etc. It's just that RoR got a lot of hype early on.

I've read that Ruby has its limitations when scaling (or is that RoR?, or is that baloney for both?).

So has PHP. :-)

Personally, I think it's baloney for Ruby. When scaling, in any language, you look at the bottlenecks and work on them one by one. From there, you scale vertically and horizontally.

You replace your pet language when appropriate (I would not run a chat server or some high performance financial service in PHP or Ruby, for instance). But overall in my experience, the language is not the core of the problem when scaling, no matter how slow it is -- the architecture is. (If the language was at the core of the problem, sites would be mostly written in C, C++, C#, Java, Lisp, Erlang, etc. Each of the latter outperform PHP and Ruby by one or two orders of magnitude.)

For RoR, I can't say. I only looked into it superficially. I fully understand why or how RoR would satisfy a graphic designer or a CS student, though. It insulted everything I've come to take for granted as a database developer.

I later bumped into a long rant by Zed Shaw (a guy who wrote a Ruby web server), though. Among other things, he mocked the Rails creator for not being able to keep his own production servers running for more than 4 minutes on average. (This has improved since.)

share|improve this answer
add comment

If you want to do some desktop application development and want to use the same programming language, then Ruby (particularly the JRuby) will be more suited than PHP. http://stackoverflow.com/questions/1129383/non-trivial-desktop-apps-that-use-ruby

share|improve this answer
add comment

Frankly your question(s) seem unclear to me, but I'll try to answer them nonetheless.

Would a PHP programmer want to learn Ruby?, I know I do, but conversely, would a Ruby programmer want to learn PHP?.

No offense, but this question is unanswerable. It really depends on too many factors, many of which are tied to the personality of the programmer. Easy answer: Of course, why not? It's one more tool to build websites.

What kinds of projects or situations would be better suited for Ruby that are not suited for PHP?.

As for projects, both are just as suitable (if I remember well, ruby runs slower, although this is to take with a pinch of salt since AFAIK, stackchange is built with RoR [I never read actual benchmarks]). A situation that would fit one more than the other is if you intend to use a particular framework, or if your team consists of people that have more experience in one of the two languages. I really don't think there is any determined type of project that's "ideal" for any specific language. It really boils down to the specifics of each project (and even then, the differences would be subtle).

What is the actual ecosystem of Ruby?, aside from RoR, I have not seen other hyped technologies/frameworks.

Ruby on Rails is an enormous part of the success of Ruby. Ruby stayed a language unknown until RoR rolled out. There are lots of interesting projects built on Ruby, but nothing comes close in terms of success & acceptance by the community. There are CMSs built on top of RoR that are quite known. Lovd by Less for example.

Supposing there are a certain type of projects ideal for Ruby, would there be a moment that its better to move it to PHP?.

The only case I can imagine is right after prototyping with Ruby, if you feel PHP would yield to faster development. But once a project is started, how do you intend to "move it to PHP"? Port all the code that has been written?

Finally and most importantly, would it be sane to maintain projects in two languages?

If you don't have a bazooka pointed to your head, absolutely not.
If you mean maintain two completely different projects in two different languages, then absolutely. I don't think you will ever go for a long period of time with the same language. For example, I am constantly hopping from language to language. I master only a few, but I know enough of the others to get myself out of any situation (until now). I am freelancer so people working in companies might have a different experience. But my point is, maintaining different projects in different languages is easy (enough) and fun.

share|improve this answer
2  
I just recently read that stackxchange is built on ASP.NET MVC. Not that it's germaine to your post, but thought I'd mention it. –  kinakuta Jun 18 '11 at 6:05
    
you are right, I'll edit my post to correct that. –  Xananax Jun 19 '11 at 16:23
    
+ 1 for the "If you don't have a bazooka pointed to your head, absolutely not." Mixing languages in the same project is problematic because every maintainer of the project have to know them both, and it's hard to find a developer who is good enough in both languages. Of course, if there is a clear separation between every part (like say back-end and front-end) it may have an excuse. But it's like calling problems. –  Carlos Campderrós Jun 20 '11 at 9:08
    
I didn't mean a single project in both languages, but having some projects in PHP and some in Ruby. –  dukeofgaming Jun 21 '11 at 12:18
    
My bad then. I don't know if your question is unclear or if I was under the influence of what I was working on (markup engine in php with preview in js - exactly like stackxchange-, so two parsers in two languages that must output the exact same result). If you mean having different projects in different languages, then of course, absolutely. I always needs a few days to pick up a language you haven't used in a while, but it comes back very fast. –  Xananax Jun 22 '11 at 4:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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