News for hackers. Stuff that matters.
Re:What's Coming in Python 3.8 by elcritch on Thursday July 18, 2019 @12:54AM (#20466822)
I disagree this python version is as readable and here’s why. It’s about as many characters but more complex. The Kotlin version performs several distinct actions, each being clear to its purpose. These actions have the same syntax (eg requires less parsing effort). The Python version mixes at least 4 different language syntax/features, being list comprehension, if special form in the list comprehension, keywords, and lambda functions.

On top of the lessened readability, the Kotlin version makes it very easy to add, subtract, or comment out lines/actions which really helps when debugging. The Kotlin version is almost identical in structure to how you’d do it in Rust, Elixir, etc.

Re:What's Coming in Python 3.8 by brodsky on Thursday July 18, 2019 @01:46AM (#20467075)
I agree. I don't know Kotlin and am reasonably well versed in Python, yet I immediately grasp the Kotlin example as more readable, while having to squint at the Python one for a few seconds. (this is anecdotal of course, and does not account for the example possibly being contrived)
Re:What's Coming in Python 3.8 by HelloNurse on Thursday July 18, 2019 @03:28AM (#20467582)
One thing that I like more in the Python version is that it contains less names: .asSequence and .take are replaced by operators of much greater generality, while the ugly implicitly declared identifier it is replaced by explicitly deciding that sequence elements are u.

It should also be noted that Python would allow a more functional style, possibly leaving out the list comprehension.

Re:What's Coming in Python 3.8 by kragen on Thursday July 18, 2019 @08:31AM (#20469056)
It's surprising to me that there are people who disagree with my opinion about this, but it suggests that my familiarity with Python has damaged my perspective. You're clearly much less familiar with Python (this code doesn't contain any list comprehensions, for example), so I think your opinion about readability is probably a lot more objective than mine.
Re:What's Coming in Python 3.8 by DangitBobby on Thursday July 18, 2019 @12:31PM (#20471468)
FWIW most of the programming I've ever done has been in Python, and while I have no trouble understanding either snippet, I think that the Kotlin snippet is much clearer in intent and structure.
Re:What's Coming in Python 3.8 by kragen on Thursday July 18, 2019 @01:02PM (#20471779)
I certainly didn't mean to imply that only someone unfamiliar with Python could prefer the Kotlin version! Perhaps you thought I meant that, but I didn't.
Re:What's Coming in Python 3.8 by Izkata on Thursday July 18, 2019 @11:21AM (#20470734)
> this code doesn't contain any list comprehensions, for example

It does contain a generator expression though, which is the same as a list comprehension in general structure, but slightly more confusing because it doesn't have the relationship to lists that square brackets in a list comprehension would have given it.

Re:What's Coming in Python 3.8 by kragen on Thursday July 18, 2019 @11:26AM (#20470811)
Yes, it shares the structure of a list comprehension, but has different semantics. In this case a listcomp would have worked just as well.

My point, though, was that not being able to tell the difference was a key "tell" that the comment author was not very familiar with Python — in some contexts, that would tend to undermine credibility in their comment (and then it would be rude to point it out), but in this context, it probably makes their opinion more objective.

Re:What's Coming in Python 3.8 by elcritch on Thursday July 18, 2019 @12:56PM (#20471711)
Good point, though it's less my familiarity with Python and more that I tend to simplify and call generator expressions as list comprehensions unless the laziness is important to call out (meta laziness there? ;) ). Mainly since L.C.'s were first and describing the differences is tedious.
Re:What's Coming in Python 3.8 by agumonkey on Thursday July 18, 2019 @04:35AM (#20467915)
I think you're all fighting for nothing here.

The map filter chaining is obviously simpler, but python code is not that difficult and it's a no brainer task anyway.

Re:What's Coming in Python 3.8 by elcritch on Thursday July 18, 2019 @04:56AM (#20468011)
It's true the Python is still relatively easy. It may only take, say, 1.3 sec vs 1.1 to parse, but it adds up.