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 is not a great programming language

74 pointsby robertakarobinover 5 years ago

40 comments

tompover 5 years ago
&gt; a big part of my frustration comes from having a JavaScript background<p>Yeah, I thought so when I was reading the list of &quot;problems&quot;. In fact, many of those are <i>features</i> (e.g. lists &amp; tuples being different, list comprehensions, lazy evaluation, distinction between maps&#x2F;dicts and objects, ...) but the author doesn&#x27;t actually understand them. I hate to sound so negative, I guess I just didn&#x27;t realize how bad a programmer knowing (only&#x2F;mainly) JavaScript causes you to be.
评论 #21236280 未加载
评论 #21236270 未加载
评论 #21236648 未加载
评论 #21236191 未加载
akuberaover 5 years ago
Part of the problem here is clearly this person is mapping JavaScript idioms to python; in particular &quot;Needing to put dict property names `{&#x27;in&#x27;: &#x27;quotes&#x27;}&quot;: these aren&#x27;t object <i>properties</i>, these are keys in a map, and they can be and often are variables themselves, (also, can be any hashable type, not just strings) and I don&#x27;t see how that can detract from the &#x27;greatness&#x27; of python.<p>Also &quot;foo[&#x27;bar&#x27;] returns a KeyError&quot;, then saying sometimes this is resolved by &quot;getattr(foo, &#x27;bar&#x27;, None)&quot; -- the split between attributes and items are one of the best things about python.<p>I don&#x27;t know why list comprehensions are &quot;magic syntax&quot;, and you can&#x27;t complain about having to type list(map(...)) and then complain that you don&#x27;t like list comprehensions!<p>&quot;You have to cast your data back to a list&#x2F;tuple after using enumerate() and map().&quot; -- I don&#x27;t know what that means<p>&quot;Different syntaxes for lists and tuples.&quot; -- Again, what? They&#x27;re different types!<p>How is r&#x27;a\nd&#x27; less &quot;goofy&quot; than String.raw`a\nd` in JS or any other language with prefixed strings?<p>Python is clearly not for everyone nor for every problem, but in my opinion it is a great programming language.
评论 #21236432 未加载
评论 #21236465 未加载
评论 #21238485 未加载
评论 #21239755 未加载
stevebmarkover 5 years ago
These all just seem related to syntax, not actual program structure or capabilities. The only program structure thing I see is list comprehensions, which is one of Python&#x27;s great strengths. Ironically they say Ruby is more pleasant to write, when Ruby has the deepest structural flaws of any dynamic programming language.
评论 #21236591 未加载
评论 #21236622 未加载
评论 #21236182 未加载
kendallparkover 5 years ago
Something not mentioned in list that I had never considered until a conversation last year: meaningful whitespace is biased towards sighted programmers. According to a blind acquaintance, it is much easier to keep track of opening and closing parentheses and braces. Meaningful whitespace forces blind programmers to always check the number of tabs at the beginning of each line to make sure scope hasn&#x27;t changed.
评论 #21236350 未加载
评论 #21236257 未加载
评论 #21236238 未加载
meow_mixover 5 years ago
This is so surface level it&#x27;s not even worth addressing
aeyesover 5 years ago
&gt; The syntax for classical inheritance. Half of each Django app is super().__init__(<i>args, </i>*kwargs)<p>Care to show proof? I don&#x27;t see this a lot.<p>The code of the official Django site for example has 8 occurences: <a href="https:&#x2F;&#x2F;github.com&#x2F;django&#x2F;djangoproject.com&#x2F;search?q=super+__init__&amp;unscoped_q=super+__init__" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;django&#x2F;djangoproject.com&#x2F;search?q=super+_...</a>
jchwover 5 years ago
&gt; you have to do foo.get(&#x27;bar&#x27;)... or in some cases getattr(foo, &#x27;bar&#x27;, None)<p>This is a mistake based on thinking in Javascript: in JS the index operator is effectively the same as the dot operator, for example foo[“bar”] == foo.bar. In Python those are different. [] corresponds to get in dicts, and . corresponds to getattr in objects.<p>My personal biggest gripe with Python is that there isn’t a better story for typing as I’m spoiled by TypeScript and static languages that have a better development experience and prevent certain classes of mistakes.
评论 #21236582 未加载
JNRoweover 5 years ago
I &#x2F;feel&#x2F; like this gist is largely on the money, and also uninteresting at the same time. All languages suck, and often suck in different ways for different users. We just have to pick the one that is working best at the time, and that we&#x27;re best at working with.<p>I will say that I do like the act of writing a pro and con list for a language or tool though(which is why I read the linked doc), and I often push co-workers to do so when they&#x27;re suggesting things. Sometimes it shakes a bad choice out just with the simple act of jotting down a 5-point list.<p>Unless, of course, there actually is an ideal language out there. In which case I retract my point ;)
评论 #21236358 未加载
sidllsover 5 years ago
There are plenty of things about Python that are not good, and only two are touched on in this list (the cumbersome double-underscore syntax and &quot;magic methods&quot; in general, although the author clearly has experienced python mainly through Django, which has other problems). The rest read like someone who doesn&#x27;t really know the language that well and hasn&#x27;t a lot of experience in general.
santiagobasultoover 5 years ago
TLDR: if you’re a new programmer, don’t take this seriously.<p>This person clearly doesn’t understand programming languages so well. Sorry to make this response an “ad hominem” one, I should revoke the claims. But it’s impossible if they don’t understand basic concepts of programming languages.<p>For example, complaining that a dictionary key must be place in quotes. It’s not that “the key needs quotes”, but that you’re using “a string” as a key. In fact in Python, you can use any immutable object as a key (tuples, for example). They clearly come from Javascript, Python works differently (and arguably better), and they’re complaining that it doesn’t work the way they’d like it to work.<p>Then complaining about list comprehensions as a “weirdo” thing. Clearly not understanding the functional paradigm and the beauty of expressions (see Smalltalk for the ultimate example of beauty and expressiveness).
评论 #21236571 未加载
评论 #21236592 未加载
评论 #21236656 未加载
评论 #21236541 未加载
skinkestekover 5 years ago
I think I agree.<p>Here are a couple of more, from someone who has worked for years in a number of languages:<p>- few limitations means you can easily make a serious mess, which means you are more dependent on good programmers to avoid the mess.<p>- lack of typing information isn&#x27;t &quot;free solo&quot; hard but it certainly makes life a lot less pleasant.
评论 #21235810 未加载
sys_64738over 5 years ago
It doesn&#x27;t matter about its quirks. The most important thing nowadays is that it&#x27;s reached critical mass. We&#x27;re at the point where even non-developers can now cobble together a bit of python code to do simple things to make their jobs easier. This means it&#x27;s here forever, IMO.
评论 #21236192 未加载
verdvermover 5 years ago
I love Rob Pikes idea that is dumb to have scope determined by invisible characters
评论 #21236085 未加载
评论 #21236043 未加载
评论 #21236330 未加载
评论 #21236038 未加载
评论 #21236181 未加载
ACow_Adonisover 5 years ago
It&#x27;s certainly not a perfect language (no multi-line lambdas, double underscore keywords everywhere, converting generators, significant white space means problems working in other environments, typing, isn&#x27;t called lisp), but you know what...<p>I&#x27;ve been pleasantly surprised how shallow the &quot;general python rabbit-hole&quot; is.<p>If i can express this in words, one of the ways I like to judge a language when I program: i think of something a computer could theoretically do, then I look for ways to express it in that language. How many independent jumps I have to take down the conceptual rabbit-hole before I get to the solution is a nice little arbitrary metric.<p>Does python do everything the way I&#x27;d do it? No. You get over yourself and just accept that&#x27;s the way it is in this language.<p>Once I&#x27;ve done that, so far most problems in python have been pretty shallow: do this arbitrary thing and then this arbitrary thing and you&#x27;re done.<p>Compared to some of my past languages where you have to go 4 or 5 levels deep with N compulsory but conceptually irrelevant steps, it&#x27;s pretty damn good. Makes for a reasonable quick pathway to actually getting anything done...<p>Purely my subjective opinion.
RootKitBeerCatover 5 years ago
I think the adage goes “Python is the best at being the second best at... almost everything”
评论 #21236513 未加载
beagerover 5 years ago
There’s plenty to criticize Python about relating to performance and developer operations (pypi, virtualenvs, cumbersome version juggling), but most of these language features mentioned have a valid need to exist, or are purely stylistic, and therefore not admissible to the “not a great programming language” debate imo.
jupedover 5 years ago
I wish more languages did something like the D feature where method syntax and function syntax are really just syntax - i.e., str.len() is equivalent to len(str), and you use the syntax that best improves readability at your call site.
评论 #21236295 未加载
评论 #21236629 未加载
评论 #21236368 未加载
rdiddlyover 5 years ago
As usual, the worst things about a thing are also the best things about it, and the best things about it are the worst things about it.
imtringuedover 5 years ago
I personally hate virtualenv. I just install pip dependencies in a vendor directory and point PYTHONPATH to it.
encodererover 5 years ago
That&#x27;s just like, your opinion, man
nhumrichover 5 years ago
There are two kinds of languages. Those that people complain about, and those that nobody uses.
bjoliover 5 years ago
I hate python, but it is still invaluable to me for its ability to let me get shit done. Getting meaningful data from a 100mb CSV? No problems. Everything I need can be found in the STDlib.<p>From my main perspective (scheme programmer): I am constantly amazed by the bad code python programmers write in scheme. Take a nice recursive function, sprinkle it with set! (which leads to boxing and general slowness in many implementations) and if that wasn&#x27;t slow enough for you, wrap it in a call&#x2F;cc to be able to return from arbitrary places in the function. As a bonus, forget to discard the captured continuation to make your program use insane amounts of memory.<p>Then proceed to complain on Reddit.
poloticsover 5 years ago
This list is so deliciously sophomoric. The best one is, and I quote: &quot;&quot;&quot;To many other weirdo bits of magic syntax, like [list comprehensions]&quot;&quot;&quot; Obviously without actually proposing how comprehensions could be made better one has to hope the author would say he likes the equivalent Haskell better, but there is a strong doubt that is not the case.
评论 #21236081 未加载
评论 #21236173 未加载
评论 #21236313 未加载
LaGrangeover 5 years ago
I actually dislike Python, but this list ain&#x27;t it.
hootbootscootover 5 years ago
One realizes the true cost of Pythons forced indentation when using MicroPython over a serial connection, for example It&#x27;s a big PITAS, tbh. I see Python as a Vala-like glue language for C (as in Cython or FFI) but this singular weakness makes you pay attention to it in a context in which it&#x27; s truly beyond ridiculous. One may as well lisp for such use-cases...
nojvekover 5 years ago
I love python. I just really wish there was a typed equivalent of python like Typescript. The python3 types are very weak compared to TS.
viraptorover 5 years ago
If you complain in the same post: about top level functions like list and map, and about list comprehension, you&#x27;ve lost me. To have lazy and eager types and list processing, you either have to have functions or syntax for both. If you complain about existence of both, you either need to propose a new paradigm, or you&#x27;re just grumpy about everything.
danbrooksover 5 years ago
This reads like a list of complaints about Django. There&#x27;s much, much more to python than Django!
j88439h84over 5 years ago
Sure Python has many problems, but these aren&#x27;t a great selection.<p>&gt; The syntax for classical inheritance. Half of each Django app is super().__init__(<i>args, </i>*kwargs). At least you don&#x27;t have to pass arguments to super anymore.<p>Yes, inheritance is hard to do well, but that&#x27;s generally true. Much better to prefer composition (<a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Composition_over_inheritance" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Composition_over_inheritance</a>)<p>&gt; Too many magic __double-underscore__ methods and properties that you have to just memorize.<p>Better to just start using <a href="http:&#x2F;&#x2F;attrs.org" rel="nofollow">http:&#x2F;&#x2F;attrs.org</a> or dataclasses so you don&#x27;t have to do all the manual work. Classes without boilerplate.<p>&gt; Too many top-level built-in functions that (a) you have to just memorize, and (b) get really ugly. You end up with stuff like list(map(...)). I haven&#x27;t used so many nested parentheses since my early days in PHP. Guido&#x27;s explanation makes sense in theory, but is really annoying in practice.<p>I agree, there should be a pipeline operator |&gt; like F# has. A similar proposal has been made for JS. <a href="https:&#x2F;&#x2F;github.com&#x2F;tc39&#x2F;proposal-pipeline-operator" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tc39&#x2F;proposal-pipeline-operator</a><p>&gt; Too many other weirdo bits of magic syntax, like [list comprehensions].<p>List comprehensions are good, they just take 5 minutes of getting used to.<p>&gt; Django specifically is so full of magic words, and its documentation is so convoluted, that I&#x27;ve basically given up on documentation altogether and just look at the Django source code now.<p>Pyramid has a much more principled design IMHO. <a href="https:&#x2F;&#x2F;trypyramid.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;trypyramid.com&#x2F;</a><p>&gt; Needing to put dict property names `{&#x27;in&#x27;: &#x27;quotes&#x27;}.<p>Or use `dict(foo=5)`. Python mappings can contain non-string keys, so `{5: 1.2, 6: 3.4}` maps ints to floats.<p>&gt; You have to cast your data back to a list&#x2F;tuple after using enumerate() and map().<p>Don&#x27;t use map, use comprehensions.<p>&gt; Different syntaxes for lists and tuples.<p>They are different objects, why would they have the same syntax?<p>&gt; foo[&#x27;bar&#x27;] returns a KeyError, so you have to do foo.get(&#x27;bar&#x27;)... or in some cases getattr(foo, &#x27;bar&#x27;, None), but not in others because getattr and .get are different things.<p>Python is a different language from Javascript.<p>&gt; You can&#x27;t just tack on flags to &#x2F;regular_expressions&#x2F;ig.<p>Yeah that&#x27;s annoying.<p>&gt; All the goofy string literals: f&#x27; &#x27;, u&#x27; &#x27;, r&#x27; &#x27;, etc.<p>That&#x27;s a good thing, not a bad thing.<p>&gt; Pipfile does not work that well.<p>Poetry works better. <a href="https:&#x2F;&#x2F;poetry.eustace.io" rel="nofollow">https:&#x2F;&#x2F;poetry.eustace.io</a>
评论 #21236394 未加载
tgvover 5 years ago
Django is ok if you have a web site with content and forms that map nicely onto SQL tables. Any 1998 website, basically, with not too much of a load. Any other setup, and it gets messy.<p>&gt; Needing to put dict property names `{&#x27;in&#x27;: &#x27;quotes&#x27;}.<p>Now that&#x27;s a part I like.
评论 #21236094 未加载
评论 #21236095 未加载
HorkHunterover 5 years ago
I mean, one could complaint about many things in Django, but the documentation....??? Really?
hannibalhornover 5 years ago
Jack of all trades, master of none.<p>The article has a silly premise - I don&#x27;t know anybody who would claim it&#x27;s a great programming language. For the moment, it&#x27;s just the most practical in certain areas (notably data science and machine learning.)
评论 #21236266 未加载
评论 #21236310 未加载
joluxover 5 years ago
The biggest beefs I have with Python are inconsistent syntax and dynamic typing. But I&#x27;ve basically decided that dynamic types are a waste of time for me personally, so I&#x27;m not really the target audience anyways.
评论 #21236361 未加载
phtrivierover 5 years ago
Yes. Because python is a programming language.
djohnstonover 5 years ago
He has insulted list comprehensions and therefore my honor!
FpUserover 5 years ago
I would agree about &quot;magic&quot; parts.
tanilamaover 5 years ago
So be it. It is useful nevertheless.
ben509over 5 years ago
Most of these are pretty dumb, but there are some inadvertently good points.[5]<p>&gt; The philosophy of &quot;one correct way to do things.&quot;<p>I miss those days. T_T<p>&gt; A huge ecosystem of good third-party libraries.<p>Python also has a huge ecosystem of huge ecosystem managers, which is less than ideal.<p>&gt; Half of each Django app is super().__init__( * args, * * kwargs)<p>Haven&#x27;t used Django, but if I were providing a suite of classes people were extending, I&#x27;d provide lifecycle hooks.<p>Using super().__init__ is not a syntax problem as much as it&#x27;s a semantics problem, because it&#x27;s so fragile.[1]<p>&gt; Too many magic __double-underscore__ methods and properties that you have to just memorize.<p>Yup, dunders are the ugly consequence of duck-typing. Maybe Python could tuck them away in some kind of traits system.<p>&gt; Too many other weirdo bits of magic syntax, like [list comprehensions].<p>But the Python syntax <i>is</i> weird:<p><pre><code> [elem for outer in iterable for inner in outer] </code></pre> Which is essentially:<p><pre><code> for outer in iterable: for inner in outer: result.append(elem) </code></pre> It&#x27;s backwards. The PEP[2] doesn&#x27;t explain why, but looking at the JS syntax[3] it does seem less worse.<p>Other weirdo syntax:<p><pre><code> while some_condition(): if check_a_thing(elem): break else: print(&quot;never broke from loop&quot;) </code></pre> The meaning sort of makes sense if you think of `while` as an extension of `if`.<p>But I would have expected this:<p><pre><code> for x in y: do_a_thing() else: handle_empty_case() </code></pre> Or, really, a more descriptive keyword.<p>&gt; You have to cast your data back to a list&#x2F;tuple after using enumerate() and map().<p>I thought it was the coolest thing when generators got full support in py3k, but it&#x27;s <i>horribly</i> broken.<p>This does not raise an exception:<p><pre><code> x = list(some_generator) y = list(some_generator) </code></pre> y will be empty, which is a completely silent failure. The same is true for iterators. And everyone&#x27;s been bit by strings being iterable[4].<p>Sometimes it&#x27;s useful to do this:<p><pre><code> i = iter(some_generator) x = next(i) for elem in i: ... </code></pre> But Python should <i>not</i>:<p>1. make iterators be iterable.<p>2. allow spent generators to be reused without exception.<p>3. make strings be iterable.<p>(All of which could be bypassed with a method call when you really want that behavior.)<p>&gt; foo[&#x27;bar&#x27;] returns a KeyError, so you have to do foo.get(&#x27;bar&#x27;)<p>LOL, only javascript devs could not have noticed the hours they&#x27;ve spent tracking down the source of some mysterious undefined. Python <i>definitely</i> got this one right.<p>[1]: <a href="https:&#x2F;&#x2F;fuhm.net&#x2F;super-harmful&#x2F;" rel="nofollow">https:&#x2F;&#x2F;fuhm.net&#x2F;super-harmful&#x2F;</a><p>[2]: <a href="https:&#x2F;&#x2F;www.python.org&#x2F;dev&#x2F;peps&#x2F;pep-0202&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.python.org&#x2F;dev&#x2F;peps&#x2F;pep-0202&#x2F;</a><p>[3]: <a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;JavaScript&#x2F;Reference&#x2F;Operators&#x2F;Array_comprehensions" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;JavaScript&#x2F;Refe...</a><p>[4]: <a href="https:&#x2F;&#x2F;mail.python.org&#x2F;pipermail&#x2F;python-3000&#x2F;2006-April&#x2F;000759.html" rel="nofollow">https:&#x2F;&#x2F;mail.python.org&#x2F;pipermail&#x2F;python-3000&#x2F;2006-April&#x2F;000...</a><p>[5]: Wait, am I talking about the OP or this comment?
评论 #21236849 未加载
elan3over 5 years ago
yeah i agree, it is so weird to see that python is the only language that haven&#x27;t implemented in its own language atleast to my knowledge
评论 #21236683 未加载
diminotenover 5 years ago
You can write your dicts as keyword args to the dict() cast if you don&#x27;t like putting your keys in quotes, but it looks like shit.<p>There are two paths to take when one encounters something new; adapt and learn, or reject and mock. This sounds like the latter.