TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Perl Myths Talk 2009

43 pointsby bigmacover 15 years ago

4 comments

Goladusover 15 years ago
So perl is not hard to read because there's a book about best practices, and optional libraries that enforce coding styles?<p>I respectfully disagree. Reading perl requires understanding a significant amount of perl-specific trivia for any given block of code, that's why it is hard to read.<p><a href="http://shootout.alioth.debian.org/" rel="nofollow">http://shootout.alioth.debian.org/</a> Binary trees problem.<p>Perl:<p><pre><code> sub item_check { my ($tree) = @_; return $tree-&#62;[2] unless (defined $tree-&#62;[0]); return $tree-&#62;[2] + item_check($tree-&#62;[0]) - item_check($tree-&#62;[1]); } </code></pre> Lua:<p><pre><code> local function ItemCheck(tree) if tree == 3 then return tree[1] + ItemCheck(tree[2]) - ItemCheck(tree[3]) else return tree[1] end end </code></pre> These demonstrate the REALITY of what it's like reading perl code vs. other languages. Count the number of different symbols you must know in order to understand the perl code, versus the number of symbols you must know to understand the lua code. Anyone familiar with functions, variables, and standard control flow will be able to read the lua with no problem. If you look at other code snippets, like Javascript and C#, you'd amend the comment to say that anyone familiar with methods and object-oriented programming will be able to read the code with no problem.<p>With perl, you have to know perl. You have to know perl's control flow ("unless"), you have to know perl references(-&#62;), you have to know perl's parameter passing semantics and the meaning of @_, and you have to know perl's variable prefixes.<p>That's why perl is hard to read. That's why people who use perl all the time don't understand why it drives everyone else crazy. They have all that crap in their heads already. You never smell your own bad breath. Style guides don't fix this problem.
评论 #844450 未加载
评论 #844293 未加载
评论 #844800 未加载
评论 #844635 未加载
skolorover 15 years ago
As someone recently getting into using Perl, the Guidelines and Tools Slide (#36) was amazingly useful. Its got a whole list of things I've wanted, but didn't think to go out and look for yet. (Primarily tools/books on writing good perl or testing it).
评论 #843753 未加载
bkovitzover 15 years ago
The debunking of the myth of unreadability omitted something of concern to me: How much Perl code "in the wild" uses those best practices?<p>I have no doubt that Perl can be written in a disciplined and reasonable manner, readable to people familiar with its idioms, and not especially bug-prone. I cringe every time I come across Perl code because I've never actually come across any real Perl that's written that way. Or maybe I have, but I've always gotten discouraged with the language before mastering enough of the syntax to master the idioms, so I can't really tell.<p>This is not a problem with Python. It's easy to learn to read Python, and I have yet to come across really <i>bad</i> Python in practice. Good coding seems to flow easily from the way the language is made.
评论 #846118 未加载
jlcover 15 years ago
Interesting. I know python and ruby. Now I'm wondering if it's worth my time to learn perl.
评论 #844082 未加载
评论 #844080 未加载
评论 #844025 未加载