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.

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

12 pointsby pankratievabout 14 years ago

3 comments

jrockwayabout 14 years ago
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 未加载
davvidabout 14 years ago
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>
tzsabout 14 years ago
I can't tell if this is meant as an April Fool's joke.