TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Perl Myths Talk 2009

43 点作者 bigmac超过 15 年前

4 条评论

Goladus超过 15 年前
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 未加载
skolor超过 15 年前
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 未加载
bkovitz超过 15 年前
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 未加载
jlc超过 15 年前
Interesting. I know python and ruby. Now I'm wondering if it's worth my time to learn perl.
评论 #844082 未加载
评论 #844080 未加载
评论 #844025 未加载