3 ms·
> No needing to explain that the @ symbol is an array, except when reading from it. Then you use $. Perl is stuffed with unforced errors like this. Lack of nam
by twic 6y ago
> No needing to explain that the @ symbol is an array, except when reading from it. Then you use $.
Perl is stuffed with unforced errors like this. Lack of named parameters! Reading from filehandles by putting angle brackets around them! Filehandles being a distinct type from scalars! Hashes and arrays not being usable in the same way scalars are (can't put them inside an array or a hash, have to use a reference)! Even at the time, this stuff was distinctively bad. I wrote loads of Perl in the late '90s, and as soon as Python became viable, i leapt at it, because the language was so much simpler and more uniform.
All this is particularly wild considered in the light of the fact that awk, an explicit precursor to Perl, has a significantly simpler syntax. How did Larry Wall look at awk and think "i know, what i need to do is take out the named parameters, and add some more sigils!".
I do wonder if, it hadn't been for Perl, there might have been room for awk to grow into something more general. Probably not. But i don't see any technical reason why not.
- jandrese 6y agoI agree with you on a lot of this. Complex (nested) data structures are a real pain in the ass in Perl, especially back in the early 2000s. However, named parameters have been a thing for ages. It's extremely common to call functions using an anonymous hash like so: $sock = IO::Socket::INET->new(PeerAddr => 'www.perl.org', PeerPort => 'http(80)', Proto => 'tcp');
- twic 6y agoBy named parameters, i mean: sub double($value) { return $value * 2; } Which you can't write in Perl (or at least couldn't in 1998). You have to write this: sub double { my $value = shift(@_); return $value * 2; } "Named parameters" probably isn't the right name. This is such a basic feature of programming languages that i don't even know what it's called.
- cutler 6y ago"Unrolling @" was a common bugbear amongst Perl programmers and caused a few I know of to leave for Ruby or Python. Normal, parenthesised parameters were considered experimental until not that long ago so is it any wonder Perl failed to compete with Ruby and Python?
- jandrese 6y agoThe term you are looking for is "pass by reference". Perl does not have pass by reference, you have to use pointers if you want to do it. It will even go so far as to duplicate an entire array or hash you pass to a function, which can surprise novice Perl programmers when they build a giant data structure and start passing it around only to discover their program running slowly. Or worse, finding their changes to the structure being undone when the function exits.
- cygx 6y ago> The term you are looking for is "pass by reference". Nope, just parameter declarations. I also kind of doubt the by-value semantics will surprise anyone the way you describe: If you pass things by value without explicitly taking a reference, the structure (arrays and hashes, specifically) will be flattened into the argument list. If you're unaware of this, things will probably go wrong long before you've had time to be surprised by stuff getting copied...
- jandrese 6y agoIt can certainly catch C programmers who are used to arrays devolving to pointers in the background when passed as parameters.