Live data from Hacker News

Python is not a great programming language

gist.github.com

121–130 of 156 posts

Re: Python is not a great programming language

#121

TLDR: if you’re a new programmer, don’t take this seriously. 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. For example, complaining that a dictionary key must be place in quotes. It’s not that “the key needs quotes”, but that you’re…

To be fair it is pretty confusing how Python and JS have two features that look very similar on the surface (dictionaries and objects) but actually work very differently. As someone who uses both languages infrequently, it trips me up.

Re: Python is not a great programming language

#122
post #120
post #13

> a big part of my frustration comes from having a JavaScript background Yeah, I thought so when I was reading the list of "problems". In fact, many of those are features (e.g. lists & tuples being different, list comprehensions, lazy evaluation, distinction between maps/dicts and objects, ...) but the author doesn't actually understand them. I hate to sound so negative, I guess I just didn't realize how bad a progra…

There's some annoyances that have accumulated in python, like the inheritance patterns and too many underscored things. Decorators are kinda weird, too. I think Python is pretty awesome, but to pretend that it's super clean is a bit of a stretch. (a,) for a single-elem tuple-- avoiding colliding with (a) as a paren'd expression-- is wonky, too.

I think there exists a lot of space between being “not a great programming language” and “not being super clean” though.

Re: Python is not a great programming language

#123
post #23

yeah i agree, it is so weird to see that python is the only language that haven't implemented in its own language atleast to my knowledge

That's not what the article is about. And most interpreted languages (bash, ruby, perl, JS, ...) are not implemented in themselves, because it makes no sense (who interprets the interpreter?).

However, Pypy is a Python interpreter that is written in (a compiled subset of) Python 2.

Re: Python is not a great programming language

#124
Most of these are pretty dumb, but there are some inadvertently good points.[5]

> The philosophy of "one correct way to do things."

I miss those days. T_T

> A huge ecosystem of good third-party libraries.

Python also has a huge ecosystem of huge ecosystem managers, which is less than ideal.

> Half of each Django app is super().__init__( * args, * * kwargs)

Haven't used Django, but if I were providing a suite of classes people were extending, I'd provide lifecycle hooks.

Using super().__init__ is not a syntax problem as much as it's a semantics problem, because it's so fragile.[1]

> Too many magic __double-underscore__ methods and properties that you have to just memorize.

Yup, dunders are the ugly consequence of duck-typing. Maybe Python could tuck them away in some kind of traits system.

> Too many other weirdo bits of magic syntax, like [list comprehensions].

But the Python syntax is weird:

    [elem for outer in iterable for inner in outer]
Which is essentially:

    for outer in iterable:
        for inner in outer:
            result.append(elem)
It's backwards. The PEP[2] doesn't explain why, but looking at the JS syntax[3] it does seem less worse.

Other weirdo syntax:

    while some_condition():
        if check_a_thing(elem):
            break
    else:
        print("never broke from loop")
The meaning sort of makes sense if you think of `while` as an extension of `if`.

But I would have expected this:

    for x in y:
        do_a_thing()
    else:
        handle_empty_case()
Or, really, a more descriptive keyword.

> You have to cast your data back to a list/tuple after using enumerate() and map().

I thought it was the coolest thing when generators got full support in py3k, but it's horribly broken.

This does not raise an exception:

    x = list(some_generator)
    y = list(some_generator)
y will be empty, which is a completely silent failure. The same is true for iterators. And everyone's been bit by strings being iterable[4].

Sometimes it's useful to do this:

    i = iter(some_generator)
    x = next(i)
    for elem in i:
        ...
But Python should not:

1. make iterators be iterable.

2. allow spent generators to be reused without exception.

3. make strings be iterable.

(All of which could be bypassed with a method call when you really want that behavior.)

> foo['bar'] returns a KeyError, so you have to do foo.get('bar')

LOL, only javascript devs could not have noticed the hours they've spent tracking down the source of some mysterious undefined. Python definitely got this one right.

[1]: https://fuhm.net/super-harmful/

[2]: https://www.python.org/dev/peps/pep-0202/

[3]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

[4]: https://mail.python.org/pipermail/python-3000/2006-April/000...

[5]: Wait, am I talking about the OP or this comment?

Re: Python is not a great programming language

#125
If you complain in the same post: about top level functions like list and map, and about list comprehension, you'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're just grumpy about everything.

Re: Python is not a great programming language

#127
post #124

Most of these are pretty dumb, but there are some inadvertently good points.[5] > The philosophy of "one correct way to do things." I miss those days. T_T > A huge ecosystem of good third-party libraries. Python also has a huge ecosystem of huge ecosystem managers, which is less than ideal. > Half of each Django app is super().__init__( * args, * * kwargs) Haven't used Django, but if I were providing a suite of class…

I wrote this package to provide model lifecycle hooks (similar to Rails callbacks) because I didn't like the frequency that my codebase was overriding __init__(): https://github.com/rsinger86/django-lifecycle

Django's ecosystem (mainly DRF and django-filters) makes it very productive for me, but I find Django core to be lacking for developer ergonomics in certain areas.

Re: Python is not a great programming language

#128
post #54
post #13

> a big part of my frustration comes from having a JavaScript background Yeah, I thought so when I was reading the list of "problems". In fact, many of those are features (e.g. lists & tuples being different, list comprehensions, lazy evaluation, distinction between maps/dicts and objects, ...) but the author doesn't actually understand them. I hate to sound so negative, I guess I just didn't realize how bad a progra…

After reading what the author wrote, including gems such as > Too many other weirdo bits of magic syntax, like [list comprehensions]. I sadly have to agree with you.

[deleted]

Re: Python is not a great programming language

#129
post #124

Most of these are pretty dumb, but there are some inadvertently good points.[5] > The philosophy of "one correct way to do things." I miss those days. T_T > A huge ecosystem of good third-party libraries. Python also has a huge ecosystem of huge ecosystem managers, which is less than ideal. > Half of each Django app is super().__init__( * args, * * kwargs) Haven't used Django, but if I were providing a suite of class…

I wrote this package to provide model lifecycle hooks (similar to Rails callbacks) because I didn't like the frequency that my codebase was overriding __init__(): https://github.com/rsinger86/django-lifecycle Django's ecosystem (mainly DRF and django-filters) makes it very productive for me, but I find Django core to be lacking for developer ergonomics in certain areas.

That's exactly what I was imagining. You can tell it's a nicely designed base class because the dunders are all tucked away so the only thing left is actual logic.
Post reply on HN