Live data from Hacker News

Reasons Python Sucks

hackerfactor.com

401–410 of 554 posts

Re: Reasons Python Sucks

#401
post #264

Earlier quoted context omitted.

> Java primitives (short, float, double, etc...) are copied to the calling function, but arrays and objects are passed by reference. Not really. "Pass by reference" is a specific term for a much different technique which is very rarely encountered these days. It means that if you pass a variable "foo" to a function, that function can assign "foo" to some other value and the value of "foo" will also be changed outside…

> "Pass by reference" is a specific term for a much different technique which is very rarely encountered these days. C++ isn't all that rare. I suspect we'll have to agree to disagree whether your definition of pass by reference is universal. Given your definition, can you name any language with calling semantics which are not pass-by-value? I mean, you're always passing the value of something (be it the actual value…

I don’t know any C++, so forgive me. I can’t name any language that doesn’t use pass by value. Okay, I’ve heard that FORTRAN does, but I’m not sure. But that’s the point. The distinction was made when both techniques were popular, since it was obviously an important distinction to understand.

Re: Reasons Python Sucks

#402

People hate on spacing, but people rarely talk about the benefits that specific spacing has. Yeah, sure, you can complain about how strict it might be, and complain about how it can cause bugs when something is mis-indented. But it's not like brace-languages are perfect either. How about people who mix tabs & spaces within a single line because of lack of discipline or maybe a mistake from refactoring code? Imagine t…

The more serious issue with significant white space is that it makes writing code formatting tools like Prettier impossible. That’s too much to give up to avoid having to write an extra brace or two IMO.

Re: Reasons Python Sucks

#403
post #158

Earlier quoted context omitted.

Well, it sounds like this author's employer required their devs to use multiple minor versions at once: > I was advised by one teammate that I needed to configure my environment so that everything uses the Python 3.5 base. This worked great until I started on a second project that needed Python 3.6. Might be an issue specific to that company of course.

I think that whole paragraph he mixed up python 2 and 3. >However, Python installs in separate installations. My code for Python 3.5 won't work with the Python 3.7 installation unless I intentionally port it to 3.7. Enough Linux developers have decided that porting isn't worth the effort, so Ubuntu installs with both Python2 and Python3 -- because they are needed by different core functions. The way he just segways f…

> All code from 3.5 should work 3.7, unless they were using some undefined behavior of some sorts.

Interesting; that certainly wasn't always the policy (e.g. I remember 2.4 -> 2.5 being a major, breaking upgrade) and maybe his employer never got the memo. If it's now the case that you can do fearless upgrades between minor versions then maybe that just needs to be better advertised.

Re: Reasons Python Sucks

#404

Earlier quoted context omitted.

> And I pity anyone who miscounts spaces and accidentally puts in three spaces instead of four somewhere -- this can take hours to debug and track down. this is so hilariously wrong that it is clear that the author has never actually tried any of the things he complains about. Python 3.7.1 (default, Oct 22 2018, 10:41:28) [GCC 8.2.1 20180831] on linux Type "help", "copyright", "credits" or "license" for more informat…

I think the problem he is describing--somewhat poorly--is when the "third space" just happens to match some other scope above, and therefore is syntactically valid, but not nested the way one initially thought. Those kinds of problems can be hard to track down.

Exactly this. I've spent many hours on multiple hard-to-replicate bugs that turned out to be from a couple of lines at the end of a loop body that were indented to the wrong level after a refactor.

Re: Reasons Python Sucks

#405

Earlier quoted context omitted.

> I've always thought there's a much simpler language struggling to get out of Python I agree, although I suspect we have different ideas as to which parts of Python would be included in that simpler language. For example, I quite like the consistency of "everything-is-an-object". FWIW some of the Python core developers have started to express a similar sentiment. Especially in the last few versions, where Python has…

Sure: >>> [[x*y for y in xrange(1,5)] for x in xrange(1,5)] [[1, 2, 3, 4], [2, 4, 6, 8], [3, 6, 9, 12], [4, 8, 12, 16]] >>> list([x*y for y in xrange(1,5)] for x in xrange(1,5)) [[1, 2, 3, 4], [2, 4, 6, 8], [3, 6, 9, 12], [4, 8, 12, 16]] >>> [list(l) for l in ((x*y for y in xrange(1,5)) for x in xrange(1,5))] [[1, 2, 3, 4], [2, 4, 6, 8], [3, 6, 9, 12], [4, 8, 12, 16]] >>> [list(l) for l in [(x*y for y in xrange(1,5))…

You're right, this is the same problem that Python has with closures, for example:

    >>> l = []
    >>> for i in range(10):
    ...     l.append(lambda: i)
    ... 
    >>> for j in range(10):
    ...     print(l[j](), end=' ')
    ... 
    9 9 9 9 9 9 9 9 9 9
The issue isn't really closing over the variable instead of the value, but the fact that Python re-uses the same variable for each iteration of the loop. C# used to behave the same way, but its designers considered this bad enough that they made a breaking change to the language to fix it [1].

Unfortunately, C#'s solution (creating a new variable for each execution of the loop body) isn't really an option for Python. It would conflict with the rest of the language, which only uses variables scoped to whole functions.

Note that Go makes the same mistake as in earlier versions of C# [2].

[1] https://ericlippert.com/2009/11/12/closing-over-the-loop-var...

[2] https://play.golang.org/p/Pt6BN2Mj-WL

Re: Reasons Python Sucks

#406
post #14

A number of these points seem like reasonable opinions to have. But two which had me questioning the breadth of the author's experience were "Most programming languages pass function parameters by value." and "In every other language, arrays are called 'arrays'. In Python, they are called 'lists'." To the author: 1. Java, JavaScript and C# all have types which are passed by reference. (They also have types which are…

Python lists are not arrays In addition python also does have arrays if you want/need them: https://docs.python.org/3.7/library/array.html

[deleted]

Re: Reasons Python Sucks

#407

Earlier quoted context omitted.

I think the problem he is describing--somewhat poorly--is when the "third space" just happens to match some other scope above, and therefore is syntactically valid, but not nested the way one initially thought. Those kinds of problems can be hard to track down.

A third space can never align with another line since it will be an odd number of characters while indents are always even (or vice versa). If you are two chars off, well at some point you need to be responsible for your broken blocks. I agree with the other person that says this doesn't really happen in the real world with a baseline developer and editor.

We now have three real-world counter examples just in this thread. And the hacker news crowd is relatively sophisticated technically--even for programmers in general.

"It isn't a problem for me, therefore it isn't a problem for anyone." just isn't a good way to reason about problems like this.

Re: Reasons Python Sucks

#408

My top 3 criticisms as an intermediate (~5 months of study) python programmer: 1. Importing behavior is ridiculous: https://chrisyeh96.github.io/2017/08/08/definitive-guide-pyt... 2. Python libraries' documentation leave a lot to be desired (compared to good javadocs). Just because your language is dynamically typed doesn't mean you don't need to describe what the expected shape of a parameter should be. 3. Static me…

> 2. Python libraries' documentation leave a lot to be desired (compared to good javadocs). Just because your language is dynamically typed doesn't mean you don't need to describe what the expected shape of a parameter should be.

Could you give examples?

Re: Reasons Python Sucks

#409

Earlier quoted context omitted.

> The article read more like a rant of "I PERSONALLY HATE THIS" Given the entire premise of the post is that he's written a list of things he hates about Python as an answer to his friend's question as to why he hates Python, I'm not sure why you think there's some ambiguity here.

I think the issue is that the article is called "Reasons Python Sucks" rather than "Things I Hate About Python". It comes off as the author saying that these things are objectively bad about python even though many of them are clearly subjective.

clearly subjective

Are they objectively subjective?

Re: Reasons Python Sucks

#410

Earlier quoted context omitted.

I don't think the term has much value. Maybe Scratch.

"Language for people who are not programmers but who need to instruct computers to do things" is the definition I work with. Scratch, BASIC, etc., aren't really suited to that role. No-one who's just trying to munge some files wants to be told "OK first learn this language that isn't useful for you, and then you can learn a language that is". Hence why practically, Python tends to fill the "beginner" role, which is u…

Python is for people who are programmers, so it doesn't fall under your rule.

Also that rule is tautological.

Post reply on HN