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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Python Functional Programming Antipatterns

8 点作者 niels大约 15 年前

2 条评论

yason大约 15 年前
I don't think you can call these antipatterns. It's just a classic example of writing one language in another language. Ironically though, the author happens to use a closure in the examples 3C and 3D. Har har.<p>While closures and objects have something in common (both can, for example, store state) they're of quite different mindsets. And you can't easily mix mindsets because such mindsets are the terms in which the programmer thinks in. Try writing a program both in Java-mindset and in Haskell-mindset in the same source file of Java, Haskell, or C.<p>There's code where using objects instead of closures would look abhorring and there's code where using closures would look totally out of the place. There's also a related koan that was just referred on HN a few days ago.
jpr大约 15 年前
Python seems to be the best argument against misunderstood pseudo-OO since C++ and Java.<p>"While 3A is shorter, I think it is much less clear then 3B, 3C or 3D, the class examples. I think of a closure in terms of an outer function that needs to operate on an inner function, such as in the case of a decorator. Using a closure just to delay execution of a function doesn't seem right to me, and I feel like it obscures the code. "<p>Well, this exemplifies everything that is wrong with Python and its community. I have long since decided that Python is not for intellectually honest people, and every blog post about it I stumble upon just reinforces that observation.
评论 #1257888 未加载