5 ms·
but these are all superficial next to the damage done by all the absolutely atrocious Perl code out there. The writer argues that Perl's being damaged by bad c
by petercooper 18y ago
but these are all superficial next to the damage done by all the absolutely atrocious Perl code out there.
The writer argues that Perl's being damaged by bad code examples, but if that were the case, PHP would be the least popular language in the world, no?
Perl's troubles are not just because of bad code examples, because the language is poorly constructed (in terms of v5, v6 is a lot better), or because its marketing is poor/non-existent.. but because of all of these things and many other issues beside (especially the difficulty of deployment). These issues are enough to make one jump ship after years of non-resolution.
(I was a nearly full-time Perl developer from 1996-2005 - haven't touched it at all in the last few years since I jumped ship to Ruby, so it's not as if I'm hating on the language without having once loved it ;-))
- drwh0 18y agophp became popular because it is easy to install and requires almost no configuration post-install. for ISPs it was a no-brainer compared to the relatively complex mod_perl install
- mikeryan 18y agoI'm not sure this is really true, when PHP started to gain popularity most hosts had a default cgi-bin with perl ready to go. The popularity of PHP has much more to do with ease of use for users then admins.
- mikeryan 18y agoIt also doesn't help that the semantics of Perl leads to some difficult to read code even if it is well written.
- mechanical_fish 18y agoIt's not that Perl examples are unusually bad. It's that Perl's syntax is bad. Really bad. Especially for newbs. Declaring a function in PHP which accepts a scalar, an array and a hash: function foo($bar, $baz, $quux = array('quux' => "default")) { Declaring the same function in Perl: sub foo { my ($bar, @baz, %quux) = @_; Which is already terrible. Worse, despite being relatively intuitive (I've made the mistake of writing this more than once, whenever I forget too much about Perl) it's completely broken. In the words of the Camel book: If you want to pass more than one array or hash into or out of a function and have them maintain their integrity, then you're going to want to use an explicit pass-by-reference. Before you do that, you need to understand references as detailed in Chapter 4. This section may not make much sense to you otherwise. But hey, you can always look at the pictures. Here we see that Perl's syntax isn't just very ugly: It's hopelessly entangled with relatively-advanced concepts like references, and dereferencing, and pass-by-value vs pass-by-reference, and wacky only-in-Perl nonsense like "array context" vs "scalar context". Even PHP can do arguments right. Meanwhile, Perl doesn't even apologize for being a language where you have to learn about pointers before you can walk.
- thwarted 18y agoI'm not sure that example, which doesn't do what it looks like it might do, supports your argument. Because sub foo { my($bar, @baz, %quux) = @_ Is just another way to declare your types: void foo(int bar, void *baz[], hash_t quux) { ... Or in your untyped, dynamic language du jour with my bastardized Hungarian Notation: sub foo(Ibar, Abaz, Hquux) ... However, as you point out, that syntax doesn't work because non-scalars need to be passed as references. Most non-scalar types need to be passed as references in C also (I can't remember which C standard let structs be passed as value), which is perl's heritage.
- mechanical_fish 18y agoYes, if you want to write C this sort of thing is the least of your problems. Perl is certainly simpler and easier to learn than C. I'd also agree that Perl's declaration syntax is simpler than Java's, but what isn't simpler than Java's type system at this point? ;) The simple syntax works in multiple Perl alternatives: PHP and Ruby are the ones I know about. Both languages have intelligent defaults to eliminate the need, in many cases, for newbs to think hard about what they're doing. (By default, PHP passes an array of arguments, by value -- with hidden optimizations to avoid the overhead of excess copying. The PHP argument array may include entire arrays as arguments. Meanwhile, in Ruby everything is an object, so Ruby passes an array of object references.) These are the languages which constitute Perl's competition, today. (Along with Python, of course, which I am unfairly leaving out of my argument because but I don't know how Python handles arguments! But I'm sure the answer is "with reasonable intelligence".)
- nostrademons 18y ago"but what isn't simpler than Java's type system at this point?" Haskell's type system. ;-)
- deleted 18y ago[deleted]
- DavidMcLaughlin 18y ago
- timr 18y agoInteresting that you should complain about Perl, then say that you've moved to Ruby, because in my opinion, Ruby is no better constructed than Perl. The biggest crime I see attributed to Perl -- flexible syntax -- applies to Ruby in spades. (Ruby's actually much worse, since it allows you to do obtuse metaprogramming tricks that would make a good Perl coder blush. Not to mention the fact that it's a LOT slower.) I think the main difference is that Perl is old, and Ruby is new. Geeks are a cantankerous, competitive bunch, and it's harder to be the hot new guy with mad skillz if you're working in a well-established language that has a huge base of expertise and good programmers. As a result, lacking outside pressures, programmers will always migrate to the flavor of the week, so that they can stand out from their competitors.
- lacker 18y agoRuby gets the basics of object oriented programming right. You should not have different syntax for different object types. In Perl, even for things like assigning to a variable or passing an argument to a function you need to know the types. It is nearly impossible to replace a list or a hash table for another datatype later. Ruby gets the simple stuff like this right.
- timr 18y agoRuby's way of doing things is not necessarily "right". It's different. In particular, if your fundamental types are fundamentally different, there's a strong argument that they should have different interfaces. Object-oriented programming does not require that all types be polymorphic, and pretending that they are is a source of confusion.