Started with Perl, always loved it, never understood the hate. I feel like after Perl you can write in any language. I'll never forget writing Python the first time and searching for a Data::Dumper alternative...
Started with Perl, always loved it, never understood the hate. I feel like after Perl you can write in any language. I'll never forget writing Python the first time and searching for a Data::Dumper alternative...
For me personally, the biggest pain points that drove me to Python were:
1. Sigils, and relatedly, contexts. In my opinion, `my $length = @list;` is a horrid way to spell `length = len(list)`. It feels too much like typecasting magic.
2. Having to opt in to pass by reference caused so much pain. You're happily passing a hash around, but then you want to do something to it, so now you have to change the type signature of the function, then everything that calls it, etc. etc.
Contrast with Python, where everything is pass-by-object-reference and sigils aren't needed because contexts in the Perl sense don't exist. This worked on my first try:
I liked Perl. I wrote a lot of Perl. And yet, I still had to pull out The Book whenever I wanted to do anything more complex than passing a couple of ints or strings around. This stuff is knowable, obviously, but I just got tired of having to know it.I haven't touched Perl in about ten years but your example is kind of insane. This is the one place Python is more annoying than Perl???
That's the same as your example (minus the tuple type), but where Perl shines over Python (a lot) is you could have done the following: which would yield the json: [null,null,{"bar":[null,{"spam":"eggs"}]}]To do this in Python is truly grim:
and thats doing it the unpythonic way, if you were to do this like the typical Python dev would accept in an MR for a large corp you would have written: They would still hate you for defaultdict(datastructure) though. Because absolutely no one in Python realises its got that level of expressionism one of the few places it does.Why is there an arrow between $a and [2], but not between [2] and {“bar”}, in this?
The highest rated SO answer here explains a little, and it’s the kind of situational nitpickiness that let to me dropping Perl like a hot potato when something better matching my mental model came across my radar: https://stackoverflow.com/questions/1817394/whats-the-differ...Programming is such a strange field with so many people with different mental models. I am no fan of Perl, but I think having a function pass arguments as copies (and then also having semantics to work on the original by reference if you want to) is very handy. Passing copies reduces side effects.
There are any number of ways to skin that cat. In Rust, for example, values you pass, whether by value or by reference, are immutable by default. You have to explicitly mark them as mutable in the receiving function signature to allow mutation. I freaking love that as a default. Passing by reference is trivially easy, but you still avoid accidentally altering things that ought not be frobnicated.
In this case it might interest you to learn that in Raku (Perl 6), the values passed to a function are also by default immutable within that function.
If one wants the function to mutate them, one has to explicitly mark them as `$x is rw` in the function signature; this then requires one to always pass a mutable container for $x. (A bit more detail: https://andrewshitov.com/2019/10/15/110-is-rw-vs-is-raw-in-r... )
That's a nice improvement, to be sure!
Same here. Perhaps what I've enjoyed the most about Perl was the humanness and art of it. Cleverness and expressiveness were at the service of elegance.
Sure you can write amazingly obscure foot-guns in Perl but that's also true of any other language. But honestly I'd rather a few lines of obscure Perl code WITH a comment block explaining why, than a dozen classes with bits and pieces of business logic spread all over the place.
Perl was on my "want to learn" for 25 years. This year I finally had a project that really only could be in Perl, due to a library dependency, so I was kinda forced. It has been an fun and pleasant experience.
I've done a few small Perl script in the past month, mostly just to try out things and learn a bit more. I'm surprised how robust the code turns out, without me trying. The Perl syntax is a little all over the place at times, but it's incredibly powerful.
Overall it's probably not a language I'd use at work, unless I have to, but for hobby project I would pick Perl again. It has put some of the fun and humanity back in programming.
I think that "hate" comes from the "write once" language fact. Perl is quite cryptic to read... even if it is your own script. That's why raku appeared
Which is even harder to read