zlacker

[return to "Perl's decline was cultural"]
1. mmastr+53[view] [source] 2025-12-06 18:11:10
>>todsac+(OP)
In fairness, Perl died because it was just not a good language compared to others that popped up after its peak. Sometimes people just move to the better option.
◧◩
2. athert+g4[view] [source] 2025-12-06 18:20:20
>>mmastr+53
There was so much complexity hidden behind "do what I mean". For example, scalar vs array context which was super subtle:

  my @var = @array  # copy the array
  my $var = @array  # return the count of elements in array
◧◩◪
3. js2+b5[view] [source] 2025-12-06 18:26:03
>>athert+g4
Or even worse:

  my($f) = `fortune`; # assigns first line of output to $f.
  my $f = `fortune`; # assign all output to $f.
Which allegedly got a HS kid in hot water[^1].

[^1]: "It's all about context" (2001): https://archive.ph/IB2kR (http://www.stonehenge.com/merlyn/UnixReview/col38.html)

◧◩◪◨
4. Punchy+Ne[view] [source] 2025-12-06 19:41:34
>>js2+b5
I think what's most likely to happen here is that: * a developer that knew how it worked used it in code where he *wanted* to get the first line * someone just starting up copied it over and assumed that's the way to get the content of command into a variable

It's essentially complaining about using feature wrong on purpose, because the person that made mistake never learned the language.

my($var1, $var2...) is a way to multi-assign variables from an array.

and that makes perfect sense when you look at it. Perl have no multiple returns, but if you need a function that returns 2 variables it is very easy to make it work with:

    my ($bandwidth, $latency) = speedtest($host)

Perl's feature for returning different type depending on caller is definitely a confusing part but

    my @lines = `fortune`
returning lines makes perfect sense for the use case (you call external commands to parse its output, and if you do that you generally want it in lines, because then you can just do

   foreach my $line (`fortune`) {}
and it "just works".

Now you might ask "why make such shortcuts?". Well, one of big mistakes when making Perl is that it was also aimed as replacement for sed/awk for the oneliners, so language is peppered with "clever short ways to do stuff", and it's a pleasure to use in quick ad-hoc oneliners for CLI.... but then people try to use same cleverness in the actual code and it ends up with the unreadable mess people know Perl for.

the fact you can do

    my ($first_line, $second_line, ...) = `fortune`
is just the feature being.... consistent in its use "when you give it array, it will fill it with lines from the executed command"

you gave it array, and it just did what it does with arrays.

[go to top]