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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Drawbacks of Python

97 点作者 iflywithbook超过 5 年前

18 条评论

roland35超过 5 年前
I agree with the response that there are a few &quot;gotchas&quot; with python, like with any language! I have gotten caught up with a few type problems when dealing with sending raw binary data over serial and things like that - but luckily python has great unit testing frameworks to help with this.<p>My main beef with python is that it is harder to deploy projects to other people, without them setting up a virtual environment or things like that. I know that there are some tools to help compile but they aren&#x27;t easy to use.<p>Also, it is hard to create GUI applications vs languages like C#!<p>Other than that I love using python and I think it is a great tool to use in embedded development along with c&#x2F;c++.
评论 #20954966 未加载
评论 #20951707 未加载
评论 #20951726 未加载
评论 #20957526 未加载
评论 #20951727 未加载
评论 #20955181 未加载
评论 #20954674 未加载
评论 #20959005 未加载
评论 #20951723 未加载
kyllo超过 5 年前
These are minor annoyances to me. The major annoyance I have with Python is that most Python code makes such heavy use of classes, even when it only needs lists, tuples, and dicts.<p>Why do I really need a class, when:<p>- Instance fields can be added and removed at runtime<p>- Private fields and methods are not actually private (&quot;we&#x27;re all consenting adults here&quot;)<p>- No pattern matching on types and `if isinstance(foo, Bar):` is an anti-pattern because it&#x27;s a duck-typed language<p>- Interfaces are neither available nor necessary due to late binding. Abstract Base Classes are the closest thing to an interface, but they&#x27;re also unnecessary because again, it&#x27;s duck-typed.<p>- Inheritance is widely considered to be a mistake (&quot;Prefer composition over inheritance&quot; etc)<p>- Classes tend to complicate testing<p>I can use classes to write custom data structures, I guess, but in a language as high-level as Python, I can just model trees and graphs with dicts. If I need a more performant data structure, I&#x27;m not writing it in Python in the first place.<p>I&#x27;ve seen some very experienced Pythonistas recommend using namedtuple instead of classes for most use cases, and I tend to agree with them. That gets you immutability as well as dot notation for accessing fields.<p>Clojure programmers seem perfectly happy with just lists and maps, and after experiencing that, classes feel like a bolted-on misfeature in Python.
评论 #20952859 未加载
评论 #20954908 未加载
评论 #20954316 未加载
评论 #20954005 未加载
评论 #20956596 未加载
dragonsh超过 5 年前
I like Python because of zen of python [1]. This fits my brain and had been very helpful. Indeed in 2004 I chose Django instead of Ruby On Rails just because explicit is better than implicit. Overall Python is productive and good. Yes it has some warts and corner case, but than its evident. Among programming language python has a humble community and very approachable. Also most programmer in Python will not hesitate to use low level language and interface with Python when necessary. It&#x27;s not considered bad.<p><pre><code> &gt;&gt;&gt;import this </code></pre> &quot;<i>Beautiful is better than ugly.<p>Explicit is better than implicit.<p>Simple is better than complex.<p>Complex is better than complicated.<p>Flat is better than nested.<p>Sparse is better than dense.<p>Readability counts.<p>Special cases aren&#x27;t special enough to break the rules.<p>Although practicality beats purity.<p>Errors should never pass silently.<p>Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess.<p>There should be one-- and preferably only one --obvious way to do it.<p>Although that way may not be obvious at first unless you&#x27;re Dutch.<p>Now is better than never.<p>Although never is often better than right now.<p>If the implementation is hard to explain, it&#x27;s a bad idea.<p>If the implementation is easy to explain, it may be a good idea.<p>Namespaces are one honking great idea -- let&#x27;s do more of those!</i>&quot;<p>[1] <a href="https:&#x2F;&#x2F;www.python.org&#x2F;dev&#x2F;peps&#x2F;pep-0020&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.python.org&#x2F;dev&#x2F;peps&#x2F;pep-0020&#x2F;</a>
评论 #20951967 未加载
评论 #20953130 未加载
psv1超过 5 年前
So this just links to someone&#x27;s opinion on Python 2 vs 3 instead of an actual discussion on the drawbacks of Python, right?
评论 #20952186 未加载
brbrodude超过 5 年前
Dunno if Ruby locked my mind into a certain mode, but I&#x27;ve never felt good doing anything with python :( 2 different projects I tried participating with a lot of years in between, still felt the same. Granted, I can&#x27;t say I&#x27;ve really studied it properly.
canada_dry超过 5 年前
Quora click bait. A dull and benighted article that adds nothing to the discussion.
mikece超过 5 年前
&quot;No language is perfect&quot; is the perfect reply to asking about the drawbacks. The ability to get things done in a language is what allows someone to deliver VALUE to a client (or for their own projects). A workable solution now trumps a perfect solution that will take too long to implement.
评论 #20951833 未加载
PythonicAlpha超过 5 年前
I actually expected some elaborate work about the imperfection of Python.<p>What I got was a list that started with at least three points that are already obsolete, because only valid for Python 2, which is already declared obsolete.<p>Every language with some history has its humble start and is evolving. To carry the errors of the past is just not fair. You could of course drag along the first Java version and conclude that Java is bad -- but you would really invalidate your own opinion.
rjmunro超过 5 年前
The main drawback of python for me, compared to NodeJS is the whole sharing projects onto different machines with virtualenv or whatever. package.json and node_modules just works by default in so much cleaner a way. You can use npm or yarn or just a zip of the node_modules to share the environment with a colleague or to deploy.
评论 #20955480 未加载
评论 #20951685 未加载
评论 #20953023 未加载
skrause超过 5 年前
I have to deploy web applications written in Python on Windows... no uWSGI, no Gunicorn and no easy multiprocessing because no fork(). It&#x27;s painful quite often and it makes me loathe the GIL, but I still enjoy writing Python code.
评论 #20952818 未加载
anm89超过 5 年前
Maybe I&#x27;m naive, but in my mind besides their ecosystems and superficial syntax differences there isn&#x27;t that much functionally different between Python and Ruby, with the major to exception of blocks in Ruby.<p>In which case the decision between the two seems to be between a thing and a slightly better version of itself. I totally respect that many people see this differently and probably exactly opposite but to me it always feels really hard to justify using python for this reason.<p>Just for fairness sake I&#x27;m not trying to trash python. I think it&#x27;s a great language.
zeveb超过 5 年前
Back when I wrote a lot of Python, something I disliked was how one could easily reload a module, but existing instances of classes wouldn&#x27;t get updated. You could implement the machinery to do so for your own stuff, but of course that could be arbitrarily flaky.<p>Performance was definitely <i>an</i> issue, but for the sort of programming we were doing it normally wasn&#x27;t a <i>big</i> issue.<p>Duck typing could definitely be an issue — one had little confidence that code would run as desired.<p>Overall, I really liked Python, but these days I&#x27;d sooner use Go or Lisp.
kerkeslager超过 5 年前
Almost every discussion of programming languages falls into bike-shedding[1] and this is no exception. The <i>only</i> thing he mentions worth talking about is the GIL. Syntax and small API gotchas can be learned by a beginner programmer in a matter of days of using the language, and are fairly irrelevant to your overall experience. If whitespace and using the division operator are big problems for you, significant software development probably isn&#x27;t within your abilities.<p>In addition to the GIL, other problems I&#x27;d point out with Python:<p>1. At one point, Python was &quot;batteries included&quot;. This is largely no longer the case any more--most projects are largely dependent on PyPI, and there&#x27;s been a growing sentiment in the last few years that &quot;the standard library is where modules go to die&quot;. PyPI libraries are of inconsistent quality and have a high turnover rate; the &quot;standard&quot; for what to use changes fairly rapidly. And if you manage to make good choices of mature libraries and not have to change them every year or so, you still have to manage dependencies, which complicates deployments.<p>2. Fracturing community: there are now a bunch of different non-standard ways to install Python and Python dependencies, which conflict with each other, and none of which fit all use cases, so you have to use all of them and deal with conflicts. This exacerbates issues with 1.<p>3. Increasing dependency on non-pure-Python dependencies which don&#x27;t build trivially. There are reasons for this: Python often isn&#x27;t performant enough for certain tasks, and other languages have some very good tools. However, this means you can&#x27;t just `pip install` a library and expect it to work--even very common libraries like Pillow don&#x27;t without fiddling. Again, this exacerbates problems with 1.<p>4. Lack of a good desktop UI framework. It&#x27;s apparent that not as many people are using Python for native UIs any more. tk is cludgy and doesn&#x27;t result in pretty UIs, and despite being part of the standard library, it doesn&#x27;t work out of the box on MacOS. wxWidgets doesn&#x27;t build on MacOS without significant work, and documentation is for the C++ version of the library. This is sort of the intersection of 1, 2, and 3, but in desktop UIs they combine to form a perfect storm. If you&#x27;re developing a desktop UI, there are better languages, but I&#x27;m not going to post them here because I&#x27;d rather keep this as a constructive criticism of Python than a language competition.<p>5. Introspection being used to change language syntax without solving the problems the language syntax solves. I&#x27;m really looking at Django here, but they&#x27;re not the only guilty ones. When you call a function, i.e. route_on_http_method(GET=get_handler, POST=post_handler), functions can fairly easily check arguments and throw an exception from a logical spot--i.e. route_on_http_method(GIT=get_handler) throws an exception immediately. But when you have `class MyView(GenericView): def git(self, request): ...` you get no exception until you try to call the view, in which case you get a wonderful cornucopia of meaningless line numbers in a useless stack trace. Sure, Django code looks nicer and more organized, but as I said, syntax isn&#x27;t that important. Debugging IS important. Using the bikeshedding example, this is breaking the nuclear power plant to fix a problem with the bike shed. And this is a generous example: it&#x27;s fairly simple and Django is one of the libraries that does a <i>better</i> job of this. If you really want configuration-oriented programming, you&#x27;d be better off parsing in JSON files and doing explicit error checking when you parse them in, rather than introspecting out a syntax that&#x27;s not really code and not really configuration. Introspection hasn&#x27;t played out well as a Python feature.<p>You&#x27;ll note that all these problems are CULTURAL problems, rather than problems with the language itself. And that&#x27;s my point, because those are the problems you can&#x27;t easily work around, and it&#x27;s the problems you can&#x27;t easily work around that make or break the language.<p>I say all this because I love Python. I&#x27;ve worked in Python for the last 6ish years, and don&#x27;t see that changing any time soon.<p>[1] <a href="https:&#x2F;&#x2F;en.wiktionary.org&#x2F;wiki&#x2F;bikeshedding" rel="nofollow">https:&#x2F;&#x2F;en.wiktionary.org&#x2F;wiki&#x2F;bikeshedding</a>
评论 #20953238 未加载
partizanos超过 5 年前
Sorry but it just seemed odd I didn&#x27;t see a mention for GIL (global interpreter lock).<p>Because of this mechanism that ensures concurrency safety Python does not support parallel execution of threads. I am wondering if the rest of the HN community finds it as a major disadvantage.
makz超过 5 年前
I love python and it is my main language for almost everything.<p>However, yesterday I was playing with python’s async&#x2F;await and I came to the conclusion that it is a bit... useless.<p>Not a big deal, because i can use other stuff to accomplish the same I was trying to do.<p>Or maybe I was doing it wrong.
m4r35n357超过 5 年前
Python is the simplest language I know of that does operator oveloading. If I had to write my pet maths project in c++ I would not even have got started. Sometimes abstract &quot;drawbacks&quot; are irrelevant!
abakus超过 5 年前
<i>Simple is better than complex.</i><p><i>There should be one-- and preferably only one --obvious way to do it.</i><p><a href="https:&#x2F;&#x2F;xkcd.com&#x2F;1987&#x2F;" rel="nofollow">https:&#x2F;&#x2F;xkcd.com&#x2F;1987&#x2F;</a>
评论 #20958549 未加载
metalliqaz超过 5 年前
From the article:<p>&gt; Strings were just a sequence of bytes in Python 2, but now are Unicode by default. Much better.<p>whelp, not trusting this guy&#x27;s judgement anymore
评论 #20951491 未加载
评论 #20951448 未加载