From: David Masover Date: 2009-12-08T15:05:23+09:00 Subject: Re: Wordpress Port On Monday 07 December 2009 10:11:18 pm Marnen Laibow-Koser wrote: > David Masover wrote: > > In particular, there isn't any sort of PHP VM that we could meaningfully > > target. We'd be compiling Ruby to PHP, at best. > > Well, there are a couple of PHP compilers, as well as Quercus... Ah, point taken. So we could use the JVM after all. > > The "rich set of libraries" is the only benefit I can see for PHP, and > > I'm > > very skeptical -- not just of quantity, but of quality. > > Is this skepticism based on anything other than being a Smug Ruby Weenie > [TM]? No, not really... Well, ok, there are a few complaints. First of all, PHP had object-orientedness tacked on after the fact. Now, this can be done well, and it can be done poorly. In PHP's case, it was done poorly -- I'd almost rather not use them at all. By contrast, Perl implemented OO rather well, and it did so _after_ modules were implemented. Indeed, Perl libraries were already well-namespaced and easy to transform into something object-oriented -- and I found CPAN to be of consistently high quality, especially the documentation. Second, just look at the number of global functions in PHP. I'm not talking about the ones you'll write yourself, but the ones that are built into the language. Even Perl is better about this, and Javascript certainly is. And there's the inconsistency, and layers of cruft from Really Bad decisions. Stuff like mysql_escape_quotes. Or is it escape_quotes_mysql? Or maybe mysql_really_escape_quotes? I always forget, and using the wrong one will either corrupt my data or leave me open to SQL injection -- nevertheless, I must use it on every single database operation. Even Rails supports the idea of placeholder values (when you need to touch SQL at all), and this is commonplace at the database API in Perl -- the idea of prepared statements comes to mind. This is a much easier habit to maintain -- and more efficient, too. So the language itself doesn't lend itself to particularly high quality in the first place. I mean, think of the design of it, too. The syntax alone, the fact that every file is essentially already a template -- this was never intended to be a general-purpose language. It was intended to be a template language. It doesn't even make a very good template language -- Haml is better, even if you don't consider the fact that it's tied to Ruby. Add to that, one of the problems PHP shares with Ruby is its low barrier of entry, being perceived as an "easy" language -- only PHP seems to have this to a greater degree. People who learn Ruby and Rails are at least trying to learn to program. People who learn PHP usually start as designers, who learn a bit of HTML and CSS, and need a tiny bit of server-side logic in their HTML page, so they learn a bit of PHP or paste a bit of code in... For that matter, I'd guess the better developers would see that there are better languages, and would migrate away from PHP, in the long run. Now, this is all circumstantial evidence. It's possible there's a large, well- organized community of quality PHP software. Maybe things have changed since I last used it. But I've also been on two language rants in the past two days, and I should stop. > I spent about 4 happy, productive years as a PHP developer, and > enjoyed working both with the language and the many good libraries. Good for you. Hey, I've seen Drupal. I was amazed -- there are things I strongly dislike about it, but here was object-orientation, modules, mixins, all kinds of good stuff. Sure, it was completely hacked together, and not at all supported by the standard, but it was decent. This would be the main argument for creating some sort of Ruby bindings -- because then we could write Drupal plugins in Ruby. But it would end in tears. As I said, Drupal (at least, last I checked) hacks these things together. I'm fairly sure it doesn't even use PHP's own object- orientedness, as it predates that, and certainly predates its widespread adoption -- thus, while PHP and Ruby both support objects, you'd have to write Drupal-specific bindings to get any meaningful objects relating to Drupal stuff. > Of course, everything's done to higher standards in the Ruby community. > But that's because Ruby's so good, not because PHP's so bad. Ruby, and Perl, and Python, are so good? ...and Erlang, and io? In fact, the only language I can think of in this niche that I dislike more than PHP is Visual Basic.