From: Marnen Laibow-Koser Date: 2009-12-08T15:36:01+09:00 Subject: Re: Wordpress Port [Warning: no Ruby content whatsoever.] David Masover wrote: > 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. Perhaps. > >> > 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 True. I've used very little of PHP's OO. I was really an OO skeptic until about the same time I started using Rails. > > 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. > Generally so. But Perl is awful for writing Web applications. > 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. > I'm not sure I understand your point. PHP was obviously designed primarily as a procedural language, so it's sort of appropriate for there to be lots of global functions. > 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. No. There are far better DB libraries than the built-in ones. > > 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. And possible in PHP. Everything I ever did in PHP used the Pear DB or MDB2 library, both of which support prepared statements. I learned that trick back in my ColdFusion days, and wouldn't have given it up in PHP. > > So the language itself doesn't lend itself to particularly high quality > in the > first place. WTF? Just because the standard DB library has problems, you make this sweeping conclusion? Isn't that kind of like concluding that Ruby sucks because TMail and REXML are awkward? > > 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. Yeah, PHP started as a template language, and it shows. But you don't have to use it that way. It's possible -- and recommended -- to write entire PHP files without any HTML in them. It looks more or less like Perl. It's not going against the spirit of the language at all. > > 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... You could say the same about JavaScript -- people learn to write a line or two at a time, so they never really learn to use the language. Both JavaScript and PHP are pretty good languages if you allow them to be rather than considering them extensions of HTML. > > 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. That's what happened to me -- but it wasn't PHP's language features that did it. It was the fact that TDD was more feasible in Rails than in any PHP framework I could find. > > Now, this is all circumstantial evidence. It's possible there's a large, > well- > organized community of quality PHP software. There is. Maybe not enough, but there is. (MediaWiki, for example, as well as any PEAR library I've ever used...) > Maybe things have changed > since I > last used it. Maybe you never really learned what you could do with it -- as witness your ignorance of DB library options. > > 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. That must have been Drupal 6. Drupal 5 was horrible -- basically reinventing OO in a fragile procedural way. > > 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, Drupal 6 was a complete rewrite, and I believe it does use PHP OO. > 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. VB is brain-dead. PHP is not, at least if you don't try to use its OO features to any great extent. I'm sorry, but it's obvious that you don't know what you're talking about with respect to PHP. Best, --  Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org -- Posted via http://www.ruby-forum.com/.