4 ms·
Well, that code starts out with the following procedure: ====>8====>8====>8====>8====>8====>8====>8====>8====>8====>8====>8====>8====>8====>8 BEGIN { # T
by w0utert 15y ago
Well, that code starts out with the following procedure:
====>8====>8====>8====>8====>8====>8====>8====>8====>8====>8====>8====>8====>8====>8
BEGIN {
# Turn on the debugger's symbol source tracing
$^P |= 0x10;
# Work around bug in pre-5.8.7 perl where turning on $^P
# causes caller() to be confused about eval {}'s in the stack.
# (See http://rt.perl.org/rt3/Ticket/Display.html?id=35059 for more info.)
eval 'sub DB::sub' if $] < 5.008007;
}
====>8====>8====>8====>8====>8====>8====>8====>8====>8====>8====>8====>8====>8====>8
As someone with a 2-digit number of years of experience in 4 different programming and casual experience with about 4 others, I couldn't for the life of me have figure out what that code does, if some hadn't commented it.
The rest of the code looks a bit like PHP by the way, except uglier (not trying to flame here, just my opinion).
Maybe some day someone will be able to explain why anyone in their right mind would voluntarily choose to program in Perl, if not because of prior experience with the language, or some form of religious beliefs. The 'look at the xyz CPAN modules!' argument doesn't really cut it for me.
- Mithaldu 15y agoLiterally the only hard part there are the magic variables, which one can look up easily as long as one knows that they're all listed under `perldoc perlvar`. (Though i'd like to mention that he should've used `use English;`.) Either way, my point still stands. I took an entirely random and fresh piece of code and aside from one tiny well-documented bit, all of it is easily readable and most importantly: Extremely different from the code example used in that study. The rest of your comment does not merit discussion because you've your prejudices and are content with them.
- 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.
- bad_user 15y agoBEGIN is a hook that gets executed when you first load the file, before any other code in that file. From http://perldoc.perl.org/perlvar.html http://perldoc.perl.org/perlvar.html ... $^P |= 0x10 ... debugging support, keeps info about source lines on which a subroutine is defined The third line of code is a workaround for a bug, documented in the comment above it. If you were Chinese, would you complain that English words have no meaning to you? The 'look at the xyz CPAN modules!' argument doesn't really cut it for me. The libraries available are the most important asset of a language, more important than the language itself. Example: I just chose Ruby instead of Python for a project and I just discovered that there's nothing like PIL for doing image processing in Ruby. The alternatives are so bad that I'm thinking about rewriting the whole thing in Python. As far as CPAN is concerned, it's a really big (maybe the biggest), really comprehensive, centralized repository of libraries. CPAN also has something that RubyGems / the Python Index or the Maven repositories do not ... http://cpantesters.org/ http://cpantesters.org/
- whazzmaster 15y agoRuby does indeed have continuous testing for major (and even not-so-major) gems at http://travis-ci.org/ http://travis-ci.org/. I'm not quibbling with the rest of your response; just wanted to shout-out Travis since I learned of it myself recently.
- Mithaldu 15y agocpantesters is not continuous testing, it's distributed testing across all possible combinations of hardware, os and perl versions. :)
- w0utert 15y agoI think you are missing the point here. I'm not saying Perl is hard or impossible to program, or that it is 'bad' or anything, just that Perl code very often comes out obfuscated and hard to interpret, even for someone who knows many other programming languages. Example: instead of '$^P |= 0x10', something along the lines of 'sys.debug = True' is a lot easier to read, right? Perl code is full of such examples, I could make up at least 20 examples from the module linked to before in this thread, all using alternatives resembling different other languages, and all much easier to interpret. The problem with Perl (as far as I can judge) is that it tries to cram too many different things into operators and magic variables, and that it allows too much wonky stuff that might come in handy to shave off a few characters if you are a guru, but could just as well have been left out, sacrificing compactness for readability. Another thing that Perl seems to lack is orthogonality, I always get the impression that the language allows you to solve the same problem in 10 different ways. Just to give a counter-example, take a look at Objective-C code, which is almost the antithesis of Perl. It's almost self-documenting because of the naming conventions, named parameters, the way the frameworks are designed, etc. Sure, it's about 10 times more verbose than Perl, and the core language probably has 10 times less features, but if you have a good editor and don't try to obsessively do things 'your way' instead of 'the Objective-C way', it's a joy to work with. If you spend enough time in the Perl world, of course you'll get used to the language features and syntax of the language, and forget about how long it took to get to that point. At that point it's probably a perfectly fine and powerful language that allows very fast development. > The libraries available are the most important asset of a language, more important than the language itself 100% agreed, but most other popular languages also have huge libraries (core SDK libraries or third-party). At some point you reach some kind of critical mass where you can solve 99% of the problems using native libraries, leaving only 1% that requires bindings to e.g. C/C++, shell exec, RPC, etc. Most other languages already reached that point or make it easy enough to interface with other languages that have more libraries, to the extent lack of libraries is not an issue anymore (such as Objective-C, for example).
- pronoiac 15y agoThose lines are making my phone attempt widescreen, badly. Could you edit?