5 ms·
Years ago I coined the phrase “Perlaphobia”, the fear that Perl will come back into my life again and again, and every time it happens I have to relearn it all
by Scubabear68 4y ago
Years ago I coined the phrase “Perlaphobia”, the fear that Perl will come back into my life again and again, and every time it happens I have to relearn it all over again almost from scratch.
Still happens about every five years, although I am reaching for Python more and more in those situations.
What always kills me is the weirdness of the basic data structures, array/stack function calls, and the truly impressively weird ways Objects are done.
- forgetfulness 4y agoI worked briefly at a shop that maintained a complex outsourced project by Yahoo (some ad bidding optimizations pipeline). As it turns out, they used Perl, one of the few sanctioned languages at Yahoo. The coding style handed over from the client forbade every other thing that Perl fans tell you that make the language warm and endearing to them; you were allowed to use about a few of the sigil variables, all the data structures were to be used in their "object reference" form, because it sidestepped the "contexts" functionality of Perl, which was to be avoided at all costs. I remember the tedium of having to maintain your own stacktrace, because all you got was a the `$@`, `$!` and `$?` variables, which contained precisely the last of various types of error encountered during execution within the process. If you encountered errors while performing error handling, the original error would be lost, so you had to keep a backup. Edit: man, the contexts, the fans sweared by them, making analogies to natural language; I'm sorry to sound elitist, but they often came across as enthusiastic amateurs rather than people with a formal background in Computer Science. They claimed that things like passing an array to a place where an integer is expected to get the length was richness, not insanity.
- xupybd 4y agoI'm also shock that in Perl you can alter your return type based on the type of variable the caller is putting your result in. https://perlmaven.com/wantarray https://perlmaven.com/wantarray That always appeared as madness to me. Why would you make things that cryptic to understand?
- jsrcout 4y agoAs a Perl developer, I never once used that feature. It does make some sense in the context of how Perl's own operators work, making them "do the right thing" for different cases. But for user code... not needed.
- HybridCurve 4y agoThis branch of comments has decent gripes. I adopted the contextual thinking fairly easily so it was not an issue for me but having worked with so many languages since perl I can see why this would be annoying to others. It's not the most unfortunate aspect though.
- xupybd 4y agoIt's not so bad when you know what is going on but when you first hit something like that it's hard to figure out what is going on. Basically violating the Principle of least astonishment https://en.wikipedia.org/wiki/Principle_of_least_astonishment https://en.wikipedia.org/wiki/Principle_of_least_astonishmen...
- DonHopkins 4y agoPerl also flagrantly violates the Principle of Least Nausea, with all its emetic Syntactic Syrup of Ipecac. https://en.wikipedia.org/wiki/Syrup_of_ipecac https://en.wikipedia.org/wiki/Syrup_of_ipecac
- HybridCurve 4y agowantarray() is a sensing operation that allows a type of transparent function overloading: Oh you wanted just a scalar? OK. Python's ordered arguments mixed with out of order labeled arguments is worse IMO: Tell me arguments in this order. Or not... I mean, you could just tell me which they are. Wait, I got two of these... F*ck this, I quit
- xupybd 4y ago
- G3rn0ti 4y ago> I remember the tedium of having to maintain your own stacktrace With Carp::confess you get the stack trace easily when throwing an exception. It's been a core module for ages. Of course, Perl lacks a flexible condition system like Common Lisp. So all you got is an exception object you can try to handle but no restart handlers you can use to go back down the stack trace. But that's a common limitation of almost all languages supporting exceptions natively.
- wink 4y agoPHP's string datatype (in the C code) had a length field in addition to the actual bytes (probably still has), so the idea is not always bad (if most of what you do is string manipulation, so len() is O(1) and not O(n)) but I get your point, that's hidden deep in the language for perf reasons, not in user code :P
- forgetfulness 4y agoNo, that's fine, this is more like the `len()` function being called implicitly if the array is being passed to where a "scalar" value is expected. Like here: sub some_function($) { my $some_var = @_; print("$some_var\n"); } my @arr = (1, 2, 4, 7); some_function(@arr); This prints the length of the array.
- katzgrau 4y agoI worked at Yahoo, and it was Perl and PHP. Sheer madness. Their were some talented folks but I'd like them more to cowboys - git'r done instead disciplined engineers. Lots of production applications that had the code quality of your typical hacky side project. I once had a debate with my manager about classes/OOP in PHP5. He didn't like it because it usually meant having separate files and includes per class, and he likes to have all code for a PHP page in a single pane in Vim. "But Kenny it's all in one file, everything I need to work on is right here!" I still laugh about that.
- latchkey 4y ago> Lots of production applications that had the code quality of your typical hacky side project. We laugh about it now, but that's why we end up with things like this: https://www.nytimes.com/2017/10/03/technology/yahoo-hack-3-billion-users.html https://www.nytimes.com/2017/10/03/technology/yahoo-hack-3-b...
- G3rn0ti 4y ago> What always kills me is the weirdness of the basic data structures, > array/stack function calls, and the truly impressively weird ways > Objects are done. Well, Perl 5 has scalars, arrays and dictionaries -- just like Python. Unlike Python, however, Perl function arguments are always implicit/variadic by default (and stored inside the implicit "@_" variable). This can be a benefit or a curse depending on the context. Furthermore, Perl 5 does support both "call by value" and "call by reference". This distinction can confuse programmers coming from more modern languages where usually everything is a scalar reference. But you have to keep in mind Perl was invented in the 80s and put great emphasis on compatibility. Changing calling conventions would have broken many modules. edit: Regarding objects: The object system is rather simple, it's just many Perl hackers invented their own object systems on top of that. Basically, a Perl class is just a module. An object is just a reference to a dictionary that got the class name attached by applying the "bless" operator: package Foo; sub new { my ($class) = @_; my $object = {}; bless $object, $class; } sub do_stuff { my ($self) = @_; # do stuff return $self; } my $obj = Foo->new(); $obj->do_stuff()->do_stuff(); That's about it! Well, you also have inheritance using "use base ..." and you can bless other fundamental types which usually is not a bright idea. Many other object oriented languages make object orientation unnecessarily much more complex (looking at you C++).
- Scubabear68 4y agoAll true. But you have to factor in all the historical baggage, things like the weirdness of Files, introduction of references,etc. It all just ends up feeling deeply weirds and unique compared to other languages. Hence the need to relearn it every time I touch it.
- thatwasunusual 3y agoOr my favorite: package Foo { use MooseX::Extended; sub do_stuff ($self) { # do stuff return $self; } } my $obj = Foo->new; $obj->do_stuff->do_stuff;