4 ms·
> Literally the only hard part there are the magic variables [..] Sure, I'm not even saying that stuff like this makes Perl 'hard', just obscure and in many ca
by w0utert 15y ago
> Literally the only hard part there are the magic variables [..]
Sure, I'm not even saying that stuff like this makes Perl 'hard', just obscure and in many cases obfuscated. I have no idea whether you could write non-trivial Perl code that doesn't use magic variables or weird operators, but every piece of Perl code I have ever had to read or debug/maintain has suggested it's an integral aspect of the language. Maybe I've just been unlucky so far...
The code you linked to contains lots of other weird and obscure stuff by the way, I just picked the first routine to make my point. To illustrate it in another way: I challenge anyone who doesn't know anything about Perl to explain why there is another block labelled 'BEGIN' at the end of the module, which goes like this, and what it is needed for:
==>8==>8==>8==>8==>8==>8==>8==>8==>8==>8==>8==>8==>8==>8==>8==>8
no strict 'refs';
foreach my $sym ( sort keys %{ __PACKAGE__ . '::' } ) {
next
if $sym eq
'VERSION';
my $code = __PACKAGE__->can($sym) or next;
delete ${ __PACKAGE__ . '::' }{$sym};
*$sym = sub { goto &$code };
}
==>8==>8==>8==>8==>8==>8==>8==>8==>8==>8==>8==>8==>8==>8==>8==>8
Imagine having to come up with this if you are new to Perl programming :-S
> The rest of your comment does not merit discussion because you've your prejudices and are content with them
That's funny, I hear the exact same thing every time I ask someone about what makes Perl great, and how it stands out from any other language. Somehow I never get a real answer, just accusations of being prejudiced or anti-Perl.
I'm not against any programming language (except maybe VB ;-), I'm just curious why Perl is still relevant for anything except legacy code, now that we have so many nice languages for almost every problem domain.
- Mithaldu 15y ago> I challenge anyone who doesn't know anything about Perl Now that premise in itself is silly and you know it. (I could get a code sample for any language that would be impossible to understand by someone who doesn't know anything about tha language and it wouldn't even have to be a complicated one.) > I'm just curious why Perl is still relevant for anything except legacy code Few languages are as evolvable as Perl. Nowadays Perl has a better object system than Ruby and the only hard part is getting it into the core. Also, i should probably point out that i got a tad unlucky in that the first example i grabbed was meant to do some fairly language-integral stuff, namely reloading all the libraries already loaded into memory: https://metacpan.org/module/Module::Refresh https://metacpan.org/module/Module::Refresh
- danssig 15y ago>Now that premise in itself is silly and you know it. (I could get a code sample for any language that would be impossible to understand by someone who doesn't know anything about tha language and it wouldn't even have to be a complicated one.) The difference, and reason his statement is relevant, is that perl is one of the easiest languages to find these kinds of examples for. Where there is smoke, etc. >Few languages are as evolvable as Perl. [citation needed] Are you aware of what is being done in other languages. Does perl run on the JVM yet? >Nowadays Perl has a better object system than Ruby This is a subjective statement, right? If not, I'm afraid I'm going to have to ask for citations again. >and the only hard part is getting it into the core Oh, right. So as a new programmer I'm going to have to dig around to figure out how to pull things in to make the language modern after I've already gone through the trouble of getting it setup? I saw a "modern best practices use recommendation" one time. There were like 25 or so (I'm not even joking) use statements at the top of the file. If you give me 25 lines to pull stuff in I could probably make BF usable.
- Mithaldu 15y ago> The difference, and reason his statement is relevant, is that perl is one of the easiest languages to find these kinds of examples for. Where there is smoke, etc. Entirely by virtue of there existing a bulk of legacy software. Most other dynamic languages do not even have an appreciable amount of legacy software. If i were to restrict myself to searching only the past 5 years of produced Perl code on CPAN i would be hard-pressed to find truly terrible samples. Either way you managed to entirely miss the point that for a person with no knowledge about a language (including no knowledge about sibling languages), any example of source would be nearly impossible to understand at first try. > [citation needed] Are you aware of what is being done in other languages. Does perl run on the JVM yet? I said language, not virtual machine. > I'm afraid I'm going to have to ask for citations again. When does Ruby plan to have Roles? > I've already gone through the trouble of getting it setup Hahahaha. Trouble setting up perl, good one, pal. Also, i know what sample you saw once. That was written as a joke. It is a boilerplate tchrist made to demonstrate what would be necessary to make scripts entirely and absolutely perfect with unicode. (Note: Perl's default state is still better in handling unicode than most other languages.) > So as a new programmer I'm going to have to dig around Right now, yes. Which is why i wrote the blog post mentioned above. How kind of you to notice.
- gizzlon 15y agoMost of the ugly code can be avoided nowadays.. but for special cases (as that one) and a few not-so-special cases, the code can get ugly. At least until you get used to it ;) Also, perl is very flexible which is a good thing. But for better or for worse, perl lets people do crazy things. Actually, that flexibility is one great things about perl. If you know what you are doing, you can adapt the style for the purpose. For example, hack together something fast, and if it looks like a viable solution, flesh it out into something more maintainable. This is true for other languages as well, but IMHO, even more so for perl.
- danssig 15y ago>perl is very flexible which is a good thing. So are nearly all modern languages. No advantage. >perl lets people do crazy things So do nearly all modern languages. No advantage. When ever I hear people sing the praises of perl it just always make me think most haven't really sat down and learn many other languages. It's like hearing an English speaker say something like "man, English is so great because you can... like, express yourself in it! And there are even lots of ways to express yourself in it! And you can express all kinds of stuff!". Great, so it's like all the other languages then?
- gizzlon 15y agoSo do nearly all modern languages. No advantage. Didn't you read my last sentence? When ever I hear people sing the praises of perl it just always make me think most haven't really sat down and learn many other languages. Obviously not true.. But I agree most people probably know one language better than the rest, and I also think that when people praise language X ;) (oh, and for what it's worth, I think i started with both python & ruby before perl)