Perl tutorials suck (and cause serious damage)
blogs.perl.org
blogs.perl.org
To be perfectly honest myself, the last time I looked at Perl was about 4 years ago, and I despised the experience. I used it for about 10 months because the company I worked at had their entire infrastructure running on it, but it was the worst code I had ever seen, so I quit. If I remember correctly the code that broke the camel's back for me (pun intended) was:
$a = $src[$src];
I've forgotten my Perl syntax so the syntax may be incorrect, but essentially what happened was that the original author had defined two different variables with the name "src", one being a scalar variable and the other being an array, and apparently those have two different namespaces.
So when I looked at the perl tutorial that the author points out, it looked like regular perl to me. However, if the syntax of Perl has changed since 2007, then I'd be willing to give it a shot. Although I've recently started learning Python, and I'm enjoying it, except for the dynamic typing and the GIL... which is a rant for another time.
I remember being offered to choose any toolset I wanted for a particular project and finding out that Perl was the only scripting language that had the bindings to the C libraries I needed to use. Naturally, I decided to to do the whole project in straight C instead. :)
The funny thing is, whenever I would code in Perl for a while, I would actually grow acclimated to it. I would start to think to myself, "Hey! I'm finally getting things done. I CAN be productive in this language!" It was only after switching away to another language again that I would re-recognize just how painful Perl really is. This experience actually repeated itself multiple times for me as I moved on and off Perl projects and it helped me learn to sympathize more with others who are perfectly content to code in Perl for a living.
At one point, I had enough and began recording all the weird Perlisms that were wasting my time as I encountered them. My goal was to compile a "95 theses against Perl" document and post it on my manager's door as a joke. Fortunately, I only got into the 40s before my manager offered to let me move to another team where I never had to write a line of Perl again in that job!
It's possible to write good Perl just like it's possible to write good COBOL, and better tutorials would definitely help newcomers to the language do just that. I would rather spend my time writing good code in other languages, however.
I don't think it's the language's fault that poor code exists to teach people the way to Perl zen. It's more that scripting languages themselves lend to one-offs and poor code writing, especially in the days of early Perl, when people were giddy to get their hands on something that wasn't as ugly as "sh". We need better programmers who are not "too busy to write good code" as well as better material.
One of perl's big "natural language" claims is that things mean something different in different context. I think there are several movies based on what can happen when two people have a conversation but have a context mismatch.
If it was bad, it wouldn't have become the way to communicate with people in every culture on the planet. Don't forget "natural language" can include body language, as well as words, grammar, idioms, stresses, pause, and intonations.
> there are several movies based on what can happen when two people have a conversation but have a context mismatch
Matching context using protocols such as small talk before a main topic of conversation is also part of natural language. Many of us who work on computers don't learn these other aspects of natural language very well, and tend to project this limited command of natural language onto computer languages.
We have nothing better, but it is not the only way we communicate. Mathmatics made a whole other language to communicate with because spoken language wasn't effective enough.
Further, natural language is useful among people because we can work out meanings, fill in implicit statements closely enough, have experience on what certain phrases mean and so on. Even with every tool we have, we often still get it wrong. So if it takes so much intelligence to be able to communicate with written language, why would anyone imagine it a good idea to expect computers to be able to do this too? A computer must explicitly be told what to do in every situation. Typically when we need to go into that level of detail with people we don't use natural language either. We generally demonstrate what must be done (e.g. youtube tutorials which often don't even have sound, etc.).
>Many of us who work on computers don't learn these other aspects of natural language very well, and tend to project this limited command of natural language onto computer languages.
Is that a rock thrown at me? I don't think I have a problem here. I'm just realistic about what language is good at. Natural language's value is that it can be very concise when everyone has the same context as you. With a computer this is never the case.
That's because the vast majority of social situations are very tolerant of misunderstandings and have lots of redundancy/repetition to ensure that communication occurs successfully.
In cases where misunderstandings can be significant, we turn to more formal modes of communication. Scientific literature, technical manuals, and legal documents are all more stilted than regular prose for the simple reason that they need to clearly and unambiguously communicate their contents. Reader enjoyment is a secondary consideration.
Programming languages need to be even clearer than legal or technical documents, because they're being read by a machine rather than another person. As such, I see ambiguity in programming languages as even more of a sin than ambiguity in contracts and scientific papers.
Here's a great example of C++ meaning different things in different contexts. How about this:
int *& p;
*&p;With things like this I would like to advocate that Perl be treated as politics: something that's just not appropriate for HN. The thing is, when ever perl comes up some of us point out why we don't use it anymore but perl fans get seriously emotional about perl and start downvoting things they disagree with (much more so than ordinarily happens). I really suspect that if it weren't for the downvote limit some perl fan would have gone through and downvoted all my posts by now.
The problem is not whether Perl or C++ is bad. All languages have their own use cases. When their use cases go away, nobody feels the need to use the language. That's the golden rule for any language/tool that exists out there.
Perl, C++ and even lisp even over a half a century are still alive out there because there are use cases that those languages serve very well. And a majority of the people feel compelled to use them. The reason why people troll is they feel they can convince others not to use the language they hate.
C++ has a lot of problems, but compared to the other languages advantages it offers are many and it doesn't quite really have good competitors in those areas. We can go and talk about various other languages that you can compare with C++. But language itself is nothing. The surrounding ecosystem, libraries, books, help, availability of programmers, the total weight of the community with their combined wisdom over the years. In all those parameters, syntactical problems of a language count for very little things in the real world. There are more than sufficient real world scenarios out there where C++ has done the job exceedingly well.
I have myself maintained large C++ applications. And have faced many problem like what others have mentioned before. But given our efficiency requirements, Java wouldn't last for an hour in our production environments. And given all the conditions I mentioned, there isn't really a clear alternative apart from C++. And I'm sure vast majority of the C++ project have the same reasons to use C++.
Perl has its own niche. I don't really have time to write 100 line of Java/Python code with piles of exceptions of handling code just to read a file. I don't have time or the patience to deal with alien integration of Regular expression that Python offers. Python has other problems, It never evolved as a rapid scripting language, I still can't consider using python as a prototyping language. It has a little posh gloss to it. Python has nothing even remotely closer to CPAN. Compared to Perl, Python is no where in syntactical flexibility. Perl's documentation is just awesome, support for newbies is too good. And they seem to fixing all the problems in the new language Perl 6. I use scripting for rapid tasks which need urgent attentions. Some of that gets converted to production work. If that rapid aspect is missing I don't really consider that language a scripting language. And serious scripting language will have to provide means of easily modifying data of all kinds text especially. And also provide seamless integration with the Operating system.
Python never provided me all this. Its never could become my primary scripting language.
But I appreciate Python's other use cases. It has some awesome frameworks. And it has a very easy verbose syntax. And I'm sure it has plenty of use cases for people around.
Now just because you like Python, don't go on endlessly trolling Perl. This has a been going for a decade now and is getting a little boring. Both language have their use cases and are likely to be there for a real long time. Whether you like it or not.
As Bjarne Stroustrup mentions in his "The C++ programming lanaguage" - You must learn C++ not for a new syntax to do old things, but to build better systems.
I commented on a bad troll that wrote 10++% of all comments and made sweeping personal attacks.
I assume you wanted to comment on the same comment as me? :-)
Yes, I think by mistake I hit the wrong reply button.
Perl Medic (Peter J. Scott) - http://amzn.com/0201795264 Effective Perl Programming (Joseph N. Hall, Joshua A. McAdams, brian d foy) - http://amzn.com/0321496949
Besides those, having a good reference to the language is also essential. For example, I keep Perl In a Nutshell close by, even though I almost always just search http://perldoc.perl.org/ when I need that info.
In the company I worked for that used Perl extensively, there were coding standards. In fact, you don't even need that, you just need to remind everyone that cleverness is not a goal in writing maintainable software, even if cleverness is what Perl's best at.
The reason that an array subscript is "$foo[0]" is because the $ sigil means "HEY COMPILER, the expression here is going to evaluate to some scalar".
@foo is the entire list and the compiler treats it as a list type; $foo[0] is an element of the list and needs storage/behavior of a scalar. Same thing for hashes: %bar is the whole hash; $bar{quux} is an element and must be treated by the compiler as a scalar.
The programmer must remember that square braces mean array subscript and curly braces mean hash lookup.
So basically, this is a compiler optimization implemented by having the programmer provide hints to the compiler. It's overhead that probably isn't needed in the modern age, but we're effectively stuck with it. It wouldn't be so bad if they hadn't made the second (and IMO worse) decision:
You can reuse symbols across contexts. The way this works is that the compiler maintains a symbol table where each symbol has a slot available for each of the types (scalar $, array @, hash %, subroutine &). This was originally the way to emulate pass-by-reference: you'd write a subroutine that assigned its arguments into typeglobs (* foo — think of it as a wildcard for all things named foo that behaves as a magic scalar with the contents of foo's symbol table entry) and then pulled them back out as the types it wanted:
local(*foo) = @_;
foreach $bar (@foo) {
do_something($bar);
}
This amounts to telling the compiler "I want to alias the name foo in all contexts to my argument, and then go look at what's stored in the array at that name" and is a poor man's pass-by-reference.Perl 5 has a real reference system that completely obviates the need for this, except for the case of monkey-patching a subroutine, where you still say:
local *Package::quux = sub { ... }"
What's left is an unfortunate case where things like the GP mentioned ($bar = $foo[$foo]) are possible, and people who think they're being clever will do these things. Like the parent said, this is not a good thing to do.I'm not entirely sure that's correct. I think Larry Wall (being a linguist originally) designed it that way because he thought that using context-sensitive sigils was more like regular speech where leading words indicate the number, i.e. 'a cup' vs. 'some cups'...
Having taken a class on linguistics, I have to say basing a computer language on it is a horrible idea.
Human languages are far more complex and verbose than is required for talking to computers. Consider that it takes years to master a spoken language. A computer language should be much easier to pick up once you already know how to use an existing language. Computer languages should attempt to reduce complexity and verbosity where possible.
Example: I picked up lua in a week. (javascript and ruby experience helped a lot) I'm not an expert by any means but I'm capable of writing usable applications. I doubt a person could pick up a new human language in a week.
This is mostly a quibble, but human languages are not more verbose than computer languages, generally. I can generally rely on you to allocate all the variables and present the result in a context-aware way when I ask you, "What is 3 + 5?" I'd generally have to allocate variables and tell the computer where to put the result if I were to ask it the same question.
What was, and still is, sort of magical about Perl is the degree to which it is aware of context and can use it to sort out meaning. If anything, the chief complaints against Perl, which stems from its similarity to natural languages (!), is its terseness and expressive power, these complaints being that it's indistinguishable from line noise and is a write-only language.
https://github.com/schwern/AAAAAAA/blob/aaaaaa/aaa/AAAAAAAAA...
It should be unparsable, but most people who have some Perl knowledge find they can actually read and understand this.
It's quite difficult to get people to use your new version when you actively tell them that it's probably not a good idea right now.
use v5.10;
use strict;
use warnings;
my $ref = ['one', 2, 3];
say $ref;
foreach (@{$ref}) {
say;
}
# These are the same. The first form is much cleaner.
# It also makes more sense semanticaly
say @{$ref}->[0];
say @{$ref}[0];
say $ref->[0]; say @{$ref}->[0];
This raises a deprecation warning for me. say @{$ref}[0];
This is technically correct, as the leading sigil "@" indicates you are returning an array, but since you're only returning one element in that array, this should probably be "${$ref}[0]" which returns a scalar only. say $ref->[0];
This the only form which I would consider correct or "clean".This example proves nothing about Perl's power, though. The fact that difficult and fiddly reference handling shenanigans are necessary to handle something as trivial as nested arrays and hashes shows quite the opposite.
It's perfectly fine to use the array sigil, in which case it's a one-element list instead of a scalar. That's useful sometimes.
Compared to what? C? In what way is it more powerful than Ruby, Python, Ocaml, Haskell, etc.?
There are things perl has over e.g. python (lambdas) but there are at least as many things those languages have over perl (e.g. python generators built in) and all of those languages are easier to use. Look at the code you wrote there! I assume "use v5.10" is actually a forward compatibility declaration instead of a backward one, right? Really embarrassing if so.
The most feature-complete implementation - Rakudo on Parrot - is not production-ready, though, and currently somewhat stalled due to low bus factor: The object-system refactor (which made things like natively-typed attributes possible) introduced a lot of regressions, and the regex engine in particular is not yet fixed as the lead-developer was hit by real-life issues.
That's a little disingenuous. I'm a Perl fan and I'd like to use Perl 6 practically, but the fact that someone wrote a Tetris clone in one of multiple incomplete implementations of Perl 6 doesn't mean that Perl 6 is actually useful for much.
Not really. It just shows that feature-completeness may be a good metric when comparing implementations of the same language, but not so much when comparing them to implementations of a different language.
the fact that someone wrote a Tetris clone in one of multiple incomplete implementations of Perl 6 doesn't mean that Perl 6 is actually useful for much
The fact that there's a Tetris-clone in Perl6 indeed doesn't mean much. However, the fact that it uses GTK is an example of CLR interop, which opens up a whole new level of practical applicability.
Newer languages have warts, too, you just don't know what they are, yet.
The real problem is that "relevance" for technical resources has a very different meaning from "relevance" on the Internet at large, because the content pages and incoming links, by themselves, don't contain all the necessary information to judge whether a page is still relevant. As a result, Google is in some ways less and less useful as a programmer's tool - not because Google is getting worse, but because there are more and more layers of obsolete information out there.
This is bloody brilliant.
But news worthy events are only one form of white out, historical weight is another (as the perl example shows).
Disclaimer I work at blekko.com (a search engine) which allows you to specify things like /date=2005 in the search providing semantic intent. Searching through white-out situations is one of the uses of the slashtag system.
Finding information on Steve Jobs from 2000 - 2005 is actually pretty easy on Google. Search "steve jobs", then on the left-hand bar, click "custom range," and input 2000 to 2005. Done.
I invite readers to actually try the blekko example to see how incapable it is. Searching with /date=2005 : (a) sorts the results by date, such that you the first few pages are full of irrelevant pages from Dec 31, 2005. And, (b) only returns results from 2005 (it's not clear how to search over a time range).
I suspect Google uses more or less the same algorithm for general content and for tech documentation. The difference is, general content - news, discussions, fiction, etc. - rarely loses relevancy, it can only be supplanted by newer, more relevant content over time.
This happens for documentation, but it takes time - and at any given time you end up with a hodgepodge of content for various versions.
There's also no foolproof way to search for content for a specific version - this would go a long way towards fixing the problem. The closest solution is restricting the search results by date, I often have to do that.
http://www.onyxneon.com/books/modern_perl/
Unfortunately you can't create your own set of tutorials from it, and it doesn't rank highly in Google.
http://www.modernperlbooks.com/mt/2011/09/how-to-learn-perl....
One of the problems is Google won't let you filter for tutorials from last, say 2 years. There's lots of solid tutorials for 5.10 and up
The problem is that people looking for a basic Perl tutorial may not know about all the filtering options.
What people should search for is immaterial. For us in the perl community, only what people do search for counts.
Not only should advocating link rot as the preferred solution alarm any web user, but there are people out there who specifically need to learn Perl 4 to maintain or port crappy old systems (they might even outnumber people selecting Perl 6 or 5 for new projects), and we shouldn't throw their tutorials down the memory hole to make the language look more sane. Stick with a notice that better dialects are available, please.
On the larger subject, I agree, old documentation shouldn't be discarded, but should be clearly marked as referring to an older version. Of course, the horrible outdated examples the original article mentions have such disclaimers, but people still see their code as representative Perl code.
Most criticisms I read focus on how dealing with legacy Perl is typically bad because it was written poorly. The thing is, I've read legacy PHP, legacy Python, and other "legacy" code that was just as terrible.
The new Perl code I work with, though, written by my colleagues, is every bit as elegant and readable as code in any other language - provided thoughtful people are writing it.
Perl has a bad rep but I have yet to see a single legitimate argument thrown at it which doesn't boil down to "I read some bad legacy code." I've been in the same boat, and believe me, I sympathize :)
Lots of 15-year-old code is out there on the internet for folks to sneer at.
So as weird as it sounds, Google shares the blame for the poor perl code being written.
If you are really worried about this, write a blog post (or several) that show people how to properly code Perl.
Try searching for information about an obscure problem with (say) Linux. The pages found often relate to earlier versions of the OS and even in some cases 2.4.xx kernels. You have to know a bit to be able to filter the search for newer releases.
Also, more importantly, this task is so huge that a single person trying to solve it on their own is doomed. It needs to be a community thing.
It will take time, but the community will start to change, and thus actually change what users are searching for.
Think of HTML/CSS. One gets a more relevant set of results by searching HTML5, because there was a great deal of effort put into explaining how the language had changed. When looking for bleeding-edge features, a search for CSS3 is more helpful than a search on CSS (which like the perl situation, sometimes returns legacy garbage). The same applies when trying to troubleshoot a problem on OS X: adding 'lion' to the query often improves relevance of results.
I short, make a conscious effort to create a new label and inject it into the public consciousness.
My point was that OP complains they can't change what users are searching for. I assert they can, but they have to change the way they market and talk about their language. They need to present it as markedly different and give users a way to differentiate it in search from previous versions.
(Aside: I don't use Perl. I don't want to use Perl. The things I need to get done I can accomplish in other languages, and that are clear when I look at the code six months later.)
You can resist it, as has happened in various communities (i.e. python) but to actually compete with perl 6 and try and make the two different languages is down-right cult behavior. Perl isn't a person, it doesn't have feelings. If you tell it "screw you perl 5, perl 6 is better" it's not going to cry or leave angry messages on your phone. It's just a tool.
And well, with the pace Perl 6 is moving on it'll be another decade for it to become production-usable. There may be only 5% of the feature-set missing (maybe more, maybe less, i don't keep track), but those 5% are the hardest part, and then comes the task of making all that run fast and to bundle it up, etc. etc. I wouldn't hold my breath. Also see chromatic's writings on that matter:
http://www.modernperlbooks.com/cgi-bin/mt/mt-search.cgi?blog...
http://www.modernperlbooks.com/mt/2011/08/why-my-side-projec...
And if it's truly a different language then you should change the name. Racket did it. And then you would have room to eventually have a version 6 of perl (what you call perl5 now).
And well, it is usable as in, you can write software with it. It's just not commercially usable or complete.
The other side is hacked together scripts. Which have their place, but are often a mess.
There is the CPAN, which is obviously what it is;
And there is the DarkPAN, a term describing all the internal projects in companies, or small tools hacked together by people who don't know or care about the CPAN.
In some parts, the latter is referred to as BedPAN.
====>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.
From 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/
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).
This is a deliberate feature of Perl, whose motto is "There's More Than One Way To Do It".
Not to defend the practice, since the fact that there are 10 ways to do something means that (1) there's a 90% chance that when you look at somebody else's code you can't understand it, unless you learned all 10 ways and (2) at least 50% of those ways are objectively worse than the alternatives, but people will still use them because Perl programmers are encouraged to solve problems in whatever way they can.
Contrast with Python, where "There should be one - and preferably only one - obvious way to do it".
Contrast with Python, where "There should be
one - and preferably only one - obvious way to
do it".
As a Python developer myself, I call that bullshit ... how about 2 urllibs in the standard library, both broken and a dozen or so XML parsers and I still have to install PyQuery to remain sane.Also, its one obvious way to do it also breaks down in the language itself, like there's still a difference between old-style and new-style classes. And because the language does not have anonymous code-blocks (something which Perl has), the language designers added a bunch of features to take care of certain use-cases, features which are not orthogonal, like lambda expressions, foreach blocks, with blocks, iterators AND decorators, all of which could have been avoided by adding just a simple feature.
If you ever try building a simple DSL, something that modifies a class at runtime, you'll have about a dozen or so techniques to use, but none of them as beautiful as ActiveRecord ... which relies on the fact that a class block in ruby is just syntactic sugar for opening a class context with define_class and passing it a code block.
That's what we have use English for.
I'm not quibbling with the rest of your response; just wanted to shout-out Travis since I learned of it myself recently.
Isn't RMagick "like" PIL?
RMagick is a leaky, slow and unmaintained piece of software. It is also used only for small retouching on images, the primary use-case being to make thumbnails. PIL on the other hand is more reliable and can do things that RMagick does not, like actual drawings or to put it another way, whatever you can do with GDK, you can do with PIL, all in one nice package.
PIL is not perfect either, but there's nothing like it for Ruby.
and can do things that RMagick does not, like actual drawings
RMagick has a SVG-related drawing system called RVG:
http://studio.imagemagick.org/RMagick/doc/rvgtut.html
As well as a smorgasbord of drawing primitives:
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.
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==>8Imagine 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.
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
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.
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.
Well, it depends on what you mean by "truly terrible samples". If you mean "things the thread-OP couldn't understand" then I would be surprised if your statement is correct. Was the example he provided from CPAN?
>I said language, not virtual machine.
People are doing "crazy" things in every language. Including porting them to the JVM so they can use the whole body of Java libraries (which is more than what's on CPAN btw).
>When does Ruby plan to have Roles?
I'm not a ruby guy but ruby has mixins which fill the same niche (even if they probably behave a little differently to accomplish it).
>Trouble setting up perl, good one, pal.
It depends. If I'm on a modern Linux, sure, if it's not already there I can apt-get it. That's not always the case though.
>That was written as a joke
I'm pretty sure the one I saw from Chromatic. It had various Moose stuff in it as well. Surely you don't have to pull in the whole OO framework to get unicode to work?
>Right now, yes. Which is why i wrote the blog post mentioned above. How kind of you to notice.
So finally you accept a criticism. But only the one you made yourself already. And they say Rails is a ghetto...
Man, please, you could at least read the whole thing. I provided the sample, randomly pulled from CPAN and that dude harped on one small extract.
> mixins
Hm, gonna have to admit i have no clue about those. Will read up at some point.
> It depends. If I'm on a modern Linux, sure, if it's not already there I can apt-get it. That's not always the case though.
Perl is on every linux, no exception. It may not be the newest one, but even then you can use perlbrew to install whatever version you want for your own user account. But seriously, perl is on every linux.
And even on windows it's as stupidly simple as downloading an installer and clicking 5 times.
> moose ... boilerplate
You wouldn't include Moose in a boilerplate thing.
> criticism
I work daily with Perl, i've considered MANY criticisms, i have a whole book of criticisms of my own. The problem you're running into is that i've already spent a hell of a lot more time thinking about those criticisms than you have.
I missed that part. But I find it highly amusing that you randomly pulled a sample file from CPAN an already failed your own test.
>Hm, gonna have to admit i have no clue about those. Will read up at some point.
Fair enough, but I feel compelled to point out that you've been harping on me all over this thread for not reading things yet you declare perl's OO (bolted on via a library, no less) superior to ruby's without even knowing how ruby's works.
>Perl is on every linux
Linux yes. Not every Unix, not every Windows.
>You wouldn't include Moose in a boilerplate thing.
It was. It was a boilerplate list of things one should use to make perl a modern language. I think they wanted to make one module that did all these uses for you so you could just use that, but the point remains. It takes a lot of modification to stock perl to bring it up to the level of the competition.
>The problem you're running into is that i've already spent a hell of a lot more time thinking about those criticisms than you have.
I worked daily with perl for half a decade. I can believe that you have spent more time thinking about the criticism because you apparently like perl. I had no emotional attachment to it so when I saw languages that didn't have those problems I left it and never looked back.
>Linux yes. Not every Unix, not every Windows.
Wait, you'll only consider languages that come pre-installed on all Unices and Windows? That's a pretty short list!
Or are you complaining that Perl isn't available for some Unices or some versions of Windows? I'm curious to know what version of Unix or Windows has Python and/or Ruby interpreters available, but doesn't have Perl.
And on that note i'll concede defeat to your lack of reading comprehension.
Mixins don't even compare to roles; mixins in Ruby (at least Ruby 1.8 this was true) manipulate inheritance, and so they suffer from ordering problems. The compiler can't warn you about collisions and conflicts.
Roles solve that problem.
Of course they do. They may not be as good as perl's Roles but you can't say "Ruby doesn't even have a way to do this" as the GP did (paraphrased). They do, perhaps it's not as nice but it's there.
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.
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?
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)
You're saying "CPAN authors don't write crappy code". Fair point, but CPAN authors aren't looking for tutorials, nor are they writing tutorials (otherwise, they'd be tutorial authors, not CPAN authors).
The original point was that googling for tutorials brings up old crappy code. What modern perl experts write has no bearing on this issue.
What's needed is an concerted effort to have those talented CPAN authors focus their efforts on writing modern tutorials, publicizing them, getting linked, and also contacting owners of older tutorials and asking them to link to the modern stuff.
It won't happen overnight, but there's a cyclical downward spiral with perl that needs to be stopped. People looking at old/bad perl tutorials may never get to the point where they even learn about or use CPAN in the first place, and won't get exposed to better techniques. Many tutorials in other languages are bad, of course, but compare a bad PHP tutorial to a bad perl one, and the PHP will still be easier for newbs to grok.
I agree with everything you said and would like to make it more succinctly: We need to figure out a way to make what CPAN authors write relevant for newbies.
Unfortunately, I'm not sure if this is going to help all that much at this point. I think the main group of people that use the current, rather poor tutorials are newbie(or even experienced) developers that have inherited Perl code that uses the language in a way that they have never encountered before. Those devs need a good way to find all the insane single character typing optimizations built into the language.
If you have a script that consists of one 1500 character line with approximately 10 alphanumeric characters total, well written Perl examples aren't going to help you figure it out that much.
Sure, it will help if you're a complete newbie to Perl, and learning it from scratch. For those people, drilling good coding standards into them from day 1 is a GREAT thing, if for no other reason than to avoid the spaghetti that plagues a lot of Perl.
(Just kidding, I'm sure you have generous helpings of both :)