Teaching Perl to Undergraduates
onionstand.blogspot.com
onionstand.blogspot.com
Have I missed something? I'd kinda like this to be true, Perl is still my go-to language when I need to hack something together - not because I think it's necessarily "the best" language to do most jobs, but because I know it's "the best" language for _me_...
Has everybody _else_ figured that out too? ;-)
Just because this guy says it is so, doesn't make it is so. Tell me 1 metric that tells me definitively Perl is coming back. If this guy told me Perl is never going away, I'd believe him, but when he told me Perl is coming back, with no data to back it up but his ass, and use that as an excuse to brain-wrap the next generation of programmers to think in an alien language that looks like comic characters cursing with $_@qw()<>$@{}*&lc()~>>>$.$/$<$:, I'd brand it as a trash.
http://www.tiobe.com/index.php/content/paperinfo/tpci/index....
This is one of the factors why we have replaced Perl in our curriculum with Python. The other being that Python is far more fit for education.
Jokes aside, I think the sentiment has some strong truth - if for no other reason that there are some very heavy assumptions in the standard documentation that the user is well versed in Unix, shell and C libraries. "perldoc -f printf" and "perldoc -f sprintf" are _not_ what I'd expect first-programming-language learners to have to work with.
Unfortunately, the usual refrains of "patches welcome" are unlikely to solve this problem, because as a 2nd or 3rd (or 17th) language, it's precisely the documentation I want.
The TIOBE reference was to show that there are nearly always metrics that show your point.
But I guess it is easy to stomp on people based on presumption. Let's just stick to arguments, rather than poisoning the well.
Personally, I find Perl's $header2 = "Dear $title $name,";
to be more readable than Python's header2 = "Dear %(title)s %(name)s," % vars()
Another benefit to using sigils is that it's immediately clear when reading code what type of data is being referred to, while in other languages you often have to read back through the code.
On the other hand, Python has done a great job in positioning itself as the new BASIC (in a good way), and so of course Python gets much more exposure in the educational setting and thus has greater mind-share amongst younger coders.
Python is simpler and easier to learn well than Perl, but nevertheless Perl is a very powerful and useful language that takes a lot of undeserved criticism (e.g. see the comment of wyuenho in this thread).
Incidentally, I found the Google Trends link hilarious, as all the news snippets on the right of the page refer to people called Ruby and actual Python snakes (hey, maybe people are searching for things other than programming languages..)!
All I'm saying is, Perl requires too much more mental power to process than Python because of it's large vocabulary and inconsistent grammar rules. It is really a natural language, but a natural language is not needed for programming.
32.times{|i|i.upto(31){|k|putc~k&i>0?32:35};puts}
Oh, wait. That's Ruby. I meant to say:
<?for($n=33;$k=--$n;print~\xf5)for(;$k;)echo-$n&--$k?~\xdf:~\xdc;
Oh, sorry! That's PHP. My bad... here we go:
print map($%&$_?$":'#',0..~($%=$_)),$/for-32..1
There we go... You're right, Perl is so much worse!
The point is, of course, you can write ugly code in any language, or you can write beautiful code in any language. Python actually is fairly legible nearly all the time...
n=32
while n:print''.join('# '[-n&k>0]for k in range(n));n-=1
but that comes at the cost of added verbosity and reduced flexibility . Whether that's better is a matter of taste, not of fact.
I also disagree with the claim that a large vocabulary in Perl is a notable issue. The size of the Perl grammar and language is sufficiently smaller, in my experience, than the size of all of the library APIs that I have to deal with when writing Perl programs.
I agree on Python. I disagree for Ruby. It is a tossup. In most cases they are equivalent, Perl has autovivification, it is easier to interpolate functions into strings in Ruby. All in all it doesn't matter.
http://www.google.com/trends?q=perl,+python,+ruby&ctab=0...
I wouldn't have guessed they'd each surpassed Perl around 2007.
Edit: Also, despite a steady decline, watch Java dwarf them all:
Metrics? How about job trends?
http://www.indeed.com/jobtrends?q=perl&l=
Facts? How about blekko.com and duckduckgo.com, two search engines written in Perl?
Don't get me wrong I don't dismiss the continuing importance of Perl, that's why I was very careful in my wording (minus a spelling mistake). I don't think there's even 1 metric we can agree on when measuring language popularity (Python is ranked 4th on TIOBE and 6th on StackOverflow and there's exactly 0 job posting for it in Hong Kong), so never-mind 1 that tells me definitively that Perl is coming back. After all, for it to come back, it must have gone away before. Ever thought of why? Even if it is coming back, what's the significance? We've had other viable choices for a very long time now. Python, PHP are all doing a very good job that Perl was traditionally good at. Hell, I'd even throw in Ruby as another viable choice too.
Arguing success stories is kind of pointless too, theoretically I can write anything in any Turing-Complete language, so for all I care I could have written Blekko and DuckDuckGo in assembly.
There are meta-modules which allow you to pull in all the goodies with a single line of code, e.g. "use Modern::Perl;" or "use Task::Kensho;"
At that point, you are effectively coding in a "modern" dialect of Perl and it's a definite break from the past.
If you are not already interested in Perl, it's arguably not enough to persuade you, but I find it really exciting.
There was a time when there was nothing but Perl could solve effectively. That was in the 90s. We've had Moderm Perl dialects for a very long time now, they are called PHP, Ruby, and arguably, Python.
Incidentally, like an old girlfriend, the language kept going even after you broke up with her :)
With all due respect, none of PHP, Ruby, or Python come close to Modern Perl in quality or reliability.
http://www.alexa.com/siteinfo/cpan.org+rubygems.org+python-e...
CPAN's popularity vs other language module distribution systems could probably explain why perl is a lot less searched for: most of the typical programming problems have already been solved, tested and smoked in perl. Writing perl these days boils down to integrating things from CPAN, and you don't need the funky characters to do that.
$_@qw()<>$@{}*&lc()~>>>$.$/$<$:
Which happens to appear to not be valid Perl code. $ perl -e '$_@qw()<>$@{}*&lc()~>>>$.$/$<$:'
Array found where operator expected at -e line 1, at end of line
(Missing operator before ?)
Scalar found where operator expected at -e line 1, near "$.$/"
(Missing operator before $/?)
Scalar found where operator expected at -e line 1, near "$/$<"
(Missing operator before $<?)
Scalar found where operator expected at -e line 1, near "$<$:"
(Missing operator before $:?)
syntax error at -e line 1, near "$_@qw"
Execution of -e aborted due to compilation errors.Thinking back to my undergraduate mindset, I am sure I wouldn't care about what is being said at lecture unless it was practically applicable to something I was currently working on. Just my two-bits.