Live data from Hacker News

Comparing PHP, Perl, Python and Ruby

hyperpolyglot.org

31–40 of 92 posts

Re: Comparing PHP, Perl, Python and Ruby

#31
post #17

[I wonder if this is a personal watershed for Hacker News?] These languages are essentially the same thing. I often write code in at least 3 of these languages most days, and I simply translate the minor differences between them in my head. "Hyperpolyglot" -- excess in many tongues -- I don't think so. Learn at least some static languages, assembler and some functional languages, and then post something interesting o…

I take it you spent more time writing your rant than actually navigating the site you're criticizing. Please take a look at the index.

Re: Comparing PHP, Perl, Python and Ruby

#32

Earlier quoted context omitted.

not true at all. Maybe if you're looking at old sites, but PHP5's been out for a long time now, and most of the code in circulation is made for 5.2 or higher. No serious MVC framework, for instance, will run on anything less than 5.2.

Serious MVC frameworks are not the backbone of Wordpress, phpBB or dozens of other hairy monsters that make up the majority of CPU time spent on PHP execution. I mean Wordpress flat out resisted PHP 5.0 for years. Years . Everything had to be done in PHP4.

> I mean Wordpress flat out resisted PHP 5.0 for years. Years. Everything had to be done in PHP4.

I presume that's because of the size of Wordpress' install base. The number of people who run their software on $9/month shared hosting environments is staggering. Many of those are late to upgrade PHP versions.

Wordpress gets a lot of crap for being poorly written but the truth is that it's an example of software that works really well given some really unique circumstances. If the WP devs decided that their software didn't need to support the 99% of web servers out there then it wouldn't be nearly as ubiquitous as it is today.

Re: Comparing PHP, Perl, Python and Ruby

#33

This is a wonderful recap of the different ways of expressing the same idea in different languages. It is a fine Rosetta Stone. That being said, it would also be useful to characterize features that are completely unique to a given language. For example, Python has 1) a unique and powerful version of super() for working with multiple inheritance; 2) it has generators (the yield statement) that allows state to be susp…

I'm pretty sure you can do the same generator does with iterators in PHP. Traits in PHP 5.4 probably cover most of use cases where you may want multiple inheritance. Decorators are superior in Python though, no real replacement for it in PHP.

Re: Comparing PHP, Perl, Python and Ruby

#34
post #32

Earlier quoted context omitted.

Serious MVC frameworks are not the backbone of Wordpress, phpBB or dozens of other hairy monsters that make up the majority of CPU time spent on PHP execution. I mean Wordpress flat out resisted PHP 5.0 for years. Years . Everything had to be done in PHP4.

> I mean Wordpress flat out resisted PHP 5.0 for years. Years. Everything had to be done in PHP4. I presume that's because of the size of Wordpress' install base. The number of people who run their software on $9/month shared hosting environments is staggering. Many of those are late to upgrade PHP versions. Wordpress gets a lot of crap for being poorly written but the truth is that it's an example of software that w…

Wordpress gets a lot of crap for being poorly written because it is poorly written. There's no great mystery here.

Yes, they deal with lots of different configurations. This is not unique in the history of software development. It's called "portability" and many organisations seem to be able to achieve it without compromising quality.

My searing, eye-boiling hatred for Wordpress comes from administering it for what is now nearly a decade. Every time I dive into the code I am frequently repulsed by it.

The total absence of tests is my favourite "feature". I've seen multiple bugs closed with WORKSFORME that I was directly grappling with.

Re: Comparing PHP, Perl, Python and Ruby

#35
post #19
post #6

Note that anywhere you see array() in that list for PHP 5.4 you can replace it with [ ]'s. So the example that has: $a = array(1,2,array(3,4)); becomes: $a = [1,2,[3,4]]; Also 0b101010 works in 5.4.

True, but PHP 5.4 doesn't even have a stable release yet & many people haven't even adopted 5.3.

Just an FYI, but they are at the end of their testing the RC of 5.4, so it should be declared stable in about 2-3 weeks.

Re: Comparing PHP, Perl, Python and Ruby

#38
The Perl described in this article is COMPLETE SHIT. He calls deprecated and improper libs for some functions, unnecessary libs in others, assumes improper or unoptimal syntax in other examples. The list goes on. Learn languages before releasing articles on them.

He never even uses Perl's foreach in equivalency examples!! WTF.

Re: Comparing PHP, Perl, Python and Ruby

#39
post #25

Earlier quoted context omitted.

That being said, it would also be useful to characterize features that are completely unique to a given language. Perl has all these features. 1) a unique and powerful version of super() for working with multiple inheritance Perl (with Moose) has before, after, around, override, and augment in addition to super. And, it has "Roles" so you don't have to resort to hacks like multiple inheritance to implement mixins or…

It also means you have to stumble upon Moose to start using objects in a reasonably sane way. The average new Perl programmer is not going to go looking for a library that does object-oriented behavior until it's too late. They'll probably have some crazy idea that the language should be doing OO for them. If you were to navigate a largish Perl codebase today, you'd encounter the old-school bless, Moose trickiness, a…

I agree with another comment in reply to yours that this is a tired argument.

But ignoring that; someone who is new to programming is not going to understand the value of any of these concepts anyway, so it doesn't matter that they don't discover them immediately. At about the same time people figure out how to do OO cleanly, they will start hearing about libraries too.

If you were to navigate a largish Perl codebase today, you'd encounter the old-school bless, Moose trickiness, and all kinds of variants on these themes. Extremely clever stuff that Damian Conway would give you a gold star for.

I've worked on a number of post-Moose codebases, and most people did the conversion cleanly and all at once. (I can't explain it, I'm just reporting the facts. I was surprised too.) The biggest Moose-hacking pain point I've seen was someone trying to subclass DateTime with Moose. It just doesn't work very well; DateTime is werid and Moose is weird. (Of course, the solution is delegation rather than subclassing. Even in languages with real OO, you often want a "does X interface by delegating to Y class" rather than "isa Y".)

Re: Comparing PHP, Perl, Python and Ruby

#40
post #19
post #6

Note that anywhere you see array() in that list for PHP 5.4 you can replace it with [ ]'s. So the example that has: $a = array(1,2,array(3,4)); becomes: $a = [1,2,[3,4]]; Also 0b101010 works in 5.4.

True, but PHP 5.4 doesn't even have a stable release yet & many people haven't even adopted 5.3.

5.3 Come out in 2009, I has a small list of backwards compatibility breaking changes (http://www.php.net/manual/en/migration53.incompatible.php), no reason for anyone really not to have adopted it.
Post reply on HN