Live data from Hacker News

Python is not a great programming language

gist.github.com

91–100 of 156 posts

Re: Python is not a great programming language

#91
post #88
post #85

Earlier quoted context omitted.

Each to their own, but both the snippets you posted crossed my threshold for headache inducing parentheses tracking

Similarly, my parsing of special-case syntax in the Python.

What special-case syntax? The only brazenly pythonic thing in there was the (iterative) tuple unpacking, as in

(for) k, v in dic.items()

which is just

k, v = (, ) for every key value pair in the dictionary

Re: Python is not a great programming language

#92
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 think he means you don't get a list/tuple back after applying enumerate and map. That's actually lazy evaluation and it's a plus. If you just want to iterate over the values, why create a list that you are going to throw away? Twice the effort for nothing.

I agree with you that this reads as someone expecting JS behavior in Python.

Re: Python is not a great programming language

#93
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…

> "Different syntaxes for lists and tuples." -- Again, what? They're different types! Lists and tuples have different syntax in a weird and surprising way. List syntax is straightforward, just square brackets and commas. Tuple syntax pretends to be list syntax with parentheses but it's actually only about commas except when it isn't. Typically you write `(a, b)`, but the parentheses are only for precedence, and can b…

Ah, yeah I see; there's an ambiguity in parsing expressions and tuples which could lead to subtle typing bugs. There's another ambiguity that (a for a in b) is not a tuple, but a generator, while [a for a in b] is a list.

Re: Python is not a great programming language

#94
post #91
post #88

Earlier quoted context omitted.

Similarly, my parsing of special-case syntax in the Python.

What special-case syntax? The only brazenly pythonic thing in there was the (iterative) tuple unpacking, as in (for) k, v in dic.items() which is just k, v = ( , ) for every key value pair in the dictionary

There are a number of precedence rules you need to keep track of to parse the list comprehension. There are two different syntaxes that do the same thing. Arguably you need to do the same if you don't already know how the threading macro in the my second example works.

I posted due to your claim regarding all other languages necessitating increased verbosity. I should have left it lie, as I didn't intend to promote a language war, just to post a counter example. My apologies.

Re: Python is not a great programming language

#95
post #72
post #15

Earlier quoted context omitted.

The inclusion of that made me question the entire thing. It's just so...wrong. Does the author not realize that you can use (almost) anything as a dict key? a = 123 b = 'foo' d = {a:456, b:123, 2.3:'2.3'} print(d) >>> {123: 456, 'foo': 123, 2.3: '2.3'}

> Does the author not realize that you can use (almost) anything as a dict key? You can do that in JS too, it's just coerced to string, so you can do e.g. {foo: "bar"} where foo is not a variable, but assumed to be the string foo. In Python you can't, because you couldn't tell if it's foo the string, or a reference to an existing (or non-existing) foo variable. That said, in JS, not only you're limited to using (real…

That's different though. In python there is no coercion going on with the keys.

Re: Python is not a great programming language

#96
post #31

It doesn't matter about its quirks. The most important thing nowadays is that it's reached critical mass. We'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's here forever, IMO.

I remember our salesmen back in 90's cobbling together some Visual Basic or whatever it was called. So where it is now?

Did Microsoft not kill VB in the 2000s? I could be wrong.

Re: Python is not a great programming language

#97
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…

> I guess I just didn't realize how bad a programmer knowing (only/mainly) JavaScript causes you to be. Hey now - not all of us ECMA devs are total crap, but, I guess I know a fair bit of other languages. This guy is just totally ... I have words for it but I'd rather not get the mods on me. I struggled with an appropriate way to say this but I think he's super pretentious and just sounds frustrated with learning a n…

I struggle with learning new languages from time to time and there's always been a learning curve from starting out to being proficient.

But while Python itself I think provides an awesome developer experience, django seems less than awesome, and it's taken a while for me to feel proficient in Django.

Re: Python is not a great programming language

#99
post #60

Earlier quoted context omitted.

I personally find list comprehensions in python pretty horrible. They seem to exist only to do lots of stuff in one single line of code. You end up with totally impenetrable unreadable perl-esq garbage write-once-read-never code that is too clever for its own good. And people say python is easy to learn and good for beginners...! A better approach would be something like Java Streams/.net Lync/RxX pattern IMO. Explic…

dic = {k: v for k, v in dic.items() if k in other_dic and v == "bar"} How could that be improved? That's 3-4 LOC minimum in any other language My main grip is python's ternary operators, since the True value is evaluated before the condition, if you are doing ternaries on things that might throw exceptions the False value has to come first value = 0 if key not in dic else dic[key] * 5 rather than (throws indexerror i…

It appears textually first but the evaluation order is the same as the classic ?: ternary. ```[][0] if False else 'foo'``` will not raise an IndexError.

Re: Python is not a great programming language

#100
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…

> "Different syntaxes for lists and tuples." -- Again, what? They're different types! Lists and tuples have different syntax in a weird and surprising way. List syntax is straightforward, just square brackets and commas. Tuple syntax pretends to be list syntax with parentheses but it's actually only about commas except when it isn't. Typically you write `(a, b)`, but the parentheses are only for precedence, and can b…

It’s the one of those common situations where there’s no perfect solution, so one from a number of suboptimal ones needs to be chosen. This rubs random folks in random ways, and is endemic to language design. Just try to design one without no such compromise.

In this case the problem stems from the overloading of parentheses. There aren’t any more paired delimiters in ascii available unfortunately. Perhaps t[] could have been chosen, but as you see it isn’t exactly elegant either.

Post reply on HN