Live data from Hacker News

Python is not a great programming language

gist.github.com

151–156 of 156 posts

Re: Python is not a great programming language

#151
post #62

The biggest beefs I have with Python are inconsistent syntax and dynamic typing. But I've basically decided that dynamic types are a waste of time for me personally, so I'm not really the target audience anyways.

The new static type analyzers like Mypy and PyType give it more of a static feel IMHO.

As I understand it those are not really complete though, are they? Do they offer algebraic data types and exhaustive pattern matching?

Re: Python is not a great programming language

#152

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's great strengths. Ironically they say Ruby is more pleasant to write, when Ruby has the deepest structural flaws of any dynamic programming language.

I’ve always been super happy using Ruby. Never had any experiences that would cause me to label it in the way that you have. However, I am interested to know what those flaws are. Could you elaborate?

Disclaimer: I do ruby for my day job, and python for fun Disclaimer 2: I don't hate ruby, despite all these criticisms. If I had to pick a worst dynamic language it would be PHP.

Things I don't like about ruby: - two string types, symbol and string, with string being the mutable by default one.

This means given a random thing back from an api, you don't know whether to do thing[:id], thing["id"], or thing.id

This has been acknowledged as a pain point by Matz, which is why in ruby 3 strings will be immutable by default.

- Simultaneously too many names for things and not enough.

Is it .length or .size or .capacity (probably not capacity)? is_a?, kind_of?, or instance_of?? Why can I do .select or .keep_if but not .filter?

- Too many function types.

Do you want a method, a block, a proc, or a lambda? There are subtle differences between each, so choose wisely. I'll note that python suffers from this too (method, function, lambda, comprehension).

- Too much emphasis on magic

Novice rubyists get frequently bitten by all the advanced (and very hard to google) ruby concepts. How do you know what arr.map(&:id) is without already knowing that it's calling symbol.to_proc? How about $1 $? $! (if you know what all these do, you're a better rubyist than I am).

Since the author of the referenced post criticizes django for being too magical, try rails. In addition to the names of files mattering a ton, there's the routes DSL, the migrations DSL (which is not well specified in the guides), and ActiveSupport, which you only realize you're using when it's gone.

- Horrible error messages

undefined method :[] for nil:NilClass (when you try to get something out of a hash and it's nil) cannot convert Symbol into Integer (this is on an array being returned where a hash is expected) Also, if you get a stack trace, it's completely inscrutable. Python's stack traces (at least ipython's) show you both the line number and the line in question (often with context).

Re: Python is not a great programming language

#154
post #73

Part of the problem here is clearly this person is mapping JavaScript idioms to python; in particular "Needing to put dict property names `{'in': 'quotes'}": these aren't object properties , 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't see how that can detract from the 'greatness' of python. Also "foo['bar'] returns a KeyEr…

> "You have to cast your data back to a list/tuple after using enumerate() and map()." -- I don't know what that means I'm assuming that the author has a problem with the fact that those two functions return a generator and not a list.

They return an iterator, not a generator.

Re: Python is not a great programming language

#155

Earlier quoted context omitted.

> "You have to cast your data back to a list/tuple after using enumerate() and map()." -- I don't know what that means I'm assuming that the author has a problem with the fact that those two functions return a generator and not a list.

They return an iterator, not a generator.

You are correct, I typed without thinking. But my point remains the same.

Re: Python is not a great programming language

#156
post #151

Earlier quoted context omitted.

The new static type analyzers like Mypy and PyType give it more of a static feel IMHO.

As I understand it those are not really complete though, are they? Do they offer algebraic data types and exhaustive pattern matching?

I'm not sure. There is Union[Foo, Bar] which matches instances of Foo or Bar [0] and there is @overload [1]. What would it need to be complete?

[0] https://docs.python.org/3/library/typing.html#typing.Union

[1] https://mypy.readthedocs.io/en/latest/more_types.html#functi...

Post reply on HN