Even though there is no native "switch" statement in Python, the same control flow structure can be done with a dict construct: http://simonwillison.net/2004/may/7/switch/
Comparing PHP, Perl, Python and Ruby
21–30 of 92 posts
Re: Comparing PHP, Perl, Python and Ruby
#22Re: Comparing PHP, Perl, Python and Ruby
#23[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…
Re: Comparing PHP, Perl, Python and Ruby
#24Re: Comparing PHP, Perl, Python and Ruby
#25This 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…
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…
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.
As usual Perl gives you everything you want, unless what you wanted was simplicity or standardization.
Re: Comparing PHP, Perl, Python and Ruby
#26x += 1
x -= 1
Re: Comparing PHP, Perl, Python and Ruby
#27Edit: Found Lua compared on the same site here: http://hyperpolyglot.org/embeddable
Re: Comparing PHP, Perl, Python and Ruby
#28awk begat perl.
perl begat python and ruby.
python will get you a job at google.
ruby will get you a job at twitter.
php will get you a job at facebook.
Re: Comparing PHP, Perl, Python and Ruby
#29Earlier quoted context omitted.
The problem with PHP is that 99.99% of the code in circulation today isn't the shinier cleaned-up versions. It's PHP4 and PHP 5.0 and it's still chock-a-block with the storied mind-bending nastiness of yore.
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.
I mean Wordpress flat out resisted PHP 5.0 for years. Years. Everything had to be done in PHP4.
Re: Comparing PHP, Perl, Python and Ruby
#30Earlier 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…
Sigh, please don't start language wars by stuff like assuming new programmers sits alone in an ivory tower and don't talk to people, read blogs or browse a new book. (Modern Perl discuss Moose before the old standard, for instance.)
Edit: I'm just not going to touch where you assume all Perl teams that write large code bases are too stupid to agree on best practices. (I'll ask this back instead: Why are there so many language wars-lovers in some open source communities...?)