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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Python vs. Perl vs. C++ - Python is Better

12 点作者 pankratiev大约 14 年前

3 条评论

jrockway大约 14 年前
I have one. Let's write a REPL in Python:<p><pre><code> result = eval string print result </code></pre> Wow, so easy. Except it doesn't work when string contains "import foo". OK, that's fine, we can "exec" instead of "eval". Oh, but then we don't get the return value anymore.<p>(The Python solution to this is a flag to pass to exec to tell it to print the result to stdout. If you want to capture the object that's the result, well, too fucking bad. I did this in my Python REPL with an AST rewrite of the user's input. What the fuck!?)<p>In Perl, you can `eval $string' and the return value is the return value of the code you just ran. And any Perl works!<p>I've never written any Perl that looks like what this article uses. If I want to slurp a file, I say "my $file = read_file('path/to/file')". read_file comes from File::Slurp. If I want to do strict validation of the arguments to my function, I just use Params::Validate (or MooseX::Declare if my blood sugar is low). (Why do you care about number of arguments but not type of arguments? So you get an obscure error when you try to use "1" as a hash?) Perl has classes, Perl has exceptions. If you say it doesn't, like the author of this post, you don't know anything about Perl.<p>So my point is, it's easy for fanbois to hand-pick examples of why a language is bad, especially when they don't even know the language. It's all very simple in practice: to program well in a programming language, you have to learn the language. Try not doing that, and you will fail, even if that language is Python!
评论 #2398818 未加载
评论 #2398820 未加载
评论 #2398807 未加载
davvid大约 14 年前
The biggest problem with Python is performance. It doesn't do threads. The GIL is a real bummer.<p>Even when you use the threading module it's very common to load up the system monitor and see only 1 core out of 12 being used. :-/<p>Performance problems aside, it's a pleasant language and the stdlib is well-designed.<p>This comment from earlier this week pretty much sums it up:<p>"Why can't you make Python faster!?" Because Python does a lot of stuff without you asking.<p><a href="http://news.ycombinator.com/item?id=2393696" rel="nofollow">http://news.ycombinator.com/item?id=2393696</a>
tzs大约 14 年前
I can't tell if this is meant as an April Fool's joke.