Live data from Hacker News

What's Coming in Python 3.8

lwn.net

301–310 of 558 posts

Re: What's Coming in Python 3.8

#301

Earlier quoted context omitted.

It's wrong to frame this as resistance to change for no reason. See my other comment. I see some of this stuff as repeating mistakes that were made in the design of Perl. ...but there are quite few people around these days who know Perl well enough to recognize the way in which history is repeating itself, and that has at least something to do with age.

Me, I am old enough to know Perl, and I've got plenty of one-line skeletons in my own closet. And it more-or-less entered the world already vastly more TMTOWTDI-y than Python is after 3 decades. FWIW, I tend to think of comparisons to Perl as being a lot like Nazi comparisons, only for programming languages. And I do think there's some wisdom to the Godwin's Law idea that the first person to make a Nazi comparison is…

I wouldn't call it reviled. Perl makes for a poor general purpose programming language, it always did. You can write an HTTP server in Perl but you probably shouldn't. It's very good for what it was always intended for, those situations where you need to process some data, but like just once not every week for the rest of eternity.

I've never regretted a Perl program that I wrote, used and discarded. And I've never been content with a Perl program I found I was still using a week after I wrote it.

Re: What's Coming in Python 3.8

#302
post #133

Earlier quoted context omitted.

> my freshest student in front of a code and see how they deal with it. That is fine if you want to optimize language for "fresh students". That is not representative how brain process stuff after getting even some experience.

It's not about experience vs inexperience... it's about code readability and being unsurprising. m = re.match(...) if m: ... do something ... is verbose, but quite readable. Given that it's the way things have been done since forever, it's also unsurprising. if m := re.match(...): ... do something ... Without knowing what the walrus operator is, it is not entirely clear what is going on here. := is only syntactic sug…

If feel Go solves this in a much more readable way.

    if m := re.match(...); m {
        ... do something ...
    }

Still not as readable as splitting it over multiple lines but quite a lot better than Python's syntax IMO especially once you learn how the if statement works in Go.

Re: What's Coming in Python 3.8

#303

Earlier quoted context omitted.

I'm 34 and I don't like this, so it's definitely not only those above 35. Jokes aside, I would say I'm a minimalist and this is where my resistance comes from. One of the things that I dislike the most in programming is feature creep. I prefer smaller languages. I like the idea of having a more minimal feature set that doesn't change very much. In a language with less features, you might have to write slightly more c…

Furthermore, I did my grad studies in compilers. I've thought about writing an optimizing JIT for Python. I really feel like CPython is needlessly slow, and it's kind of embarassing, Many have tried and failed, Google and Dropbox to name a couple, and countless other attempts.

Yes, and part of the reason they failed is the reason I pointed to: Python is a fast moving target, with an increasing number of features.

Re: What's Coming in Python 3.8

#304
post #278

Earlier quoted context omitted.

I envisioned it like "if/else" or "for/else" or "while/else", where a "do" block must be followed by a "while" block. x = 0 do: x += 1 while: x

This completely contradicts the rest of Python grammar, and indeed many languages’ grammars. The consistent way would then be `while x < 10` but that too looks ridiculous. The issue is that you can’t have post-clause syntax in Python due to its infamous spacing-is-syntax idea.

You're right, it would be pretty weird to rely on implicitly "returning" a value from an expression like that.

But I don't think having it all on one line would be that bad.

Re: What's Coming in Python 3.8

#305

Earlier quoted context omitted.

I don't think it's just >35-year-olds who find what's going on in Python against the natural order of things?

I'm 34 and I don't like this, so it's definitely not only those above 35. Jokes aside, I would say I'm a minimalist and this is where my resistance comes from. One of the things that I dislike the most in programming is feature creep. I prefer smaller languages. I like the idea of having a more minimal feature set that doesn't change very much. In a language with less features, you might have to write slightly more c…

> In a language with less features, you might have to write slightly more code, but the code you write will be more readable to everyone else.

That's not universally true. C# has more features than Java but is generally easier to read and the intent of the code is easier to follow. The lack of features, like properties or unsigned integers, leads to Java coders creating much more convoluted solutions.

If languages with less features were universally better we would all be using C and BASIC for everything.

Re: What's Coming in Python 3.8

#306

Does it make sense to use := everywhere (can it be used everywhere?) instead of just in conditionals? Just like Pascal.

It's not valid in an assignment statement, so you can't use it everywhere.

FWIW, I agree with the sentiment; I use := for assignment in my language precisely because that's the correct symbol. But even there, my grammar accepts = as assignment as well because I type it from habit.

Re: What's Coming in Python 3.8

#307

Earlier quoted context omitted.

Furthermore, I did my grad studies in compilers. I've thought about writing an optimizing JIT for Python. I really feel like CPython is needlessly slow, and it's kind of embarassing, Many have tried and failed, Google and Dropbox to name a couple, and countless other attempts.

Yes, and part of the reason they failed is the reason I pointed to: Python is a fast moving target, with an increasing number of features.

It's not the new features of Python that make it hard to optimize; it's the fundamental dynamic nature of the language that was there from day one. Syntactic sugar doesn't have an impact one way or the other on optimizing Python.

Re: What's Coming in Python 3.8

#308
post #181

Earlier quoted context omitted.

> If `str.dedent` was a thing Have you looked at textwrap.dedent?

Yes! `textwrap.dedent` is great. On further reflection `wrap` is actually more useful for this kludge (see below). But my point is that that's a whole import for a kludge. Compare the f-string ideal (by my standards): raise ValueError("File exists, not uploading: " f"{filename} -> {bucket}, {key}") ...which is short enough that it's readable, and it's clear where exactly each variable is going. It's the single obviou…

Here's a clean way to do that:

  str_fmt = "File exists, not uploading: {filename} -> {bucket}, {key}"
  fmt_vals = dict(filename=filename, bucket=bucket, key=key)
  raise ValueError(str_fmt.dedent().format(**fmt_vals))

Re: What's Coming in Python 3.8

#309
post #184

Also type hints for dictionaries with fixed keys: https://www.python.org/dev/peps/pep-0589/ I know it's almost always better to use objects for this, but tons of code still uses dictionaries as pseudo-objects. This should make bug hunting a lot easier.

Oh, nice! I'll have to add that to json-syntax.[1]

[1]: https://pypi.org/project/json-syntax/

Re: What's Coming in Python 3.8

#310

I long for a language which has a basic featureset, and then "freezes", and no longer adds any more language features. You may continue working on the standard library, optimizing, etc. Just no new language features. In my opinion, someone should be able to learn all of a language in a few days, including every corner case and oddity, and then understand any code. If new language features get added over time, eventua…

Common Lisp seems to tick the boxes. The syntax is stable and it doesn't change. New syntax can be added through extensions (pattern matching, string interpolation, etc). The language is stable, meaning code written in pure CL still runs 20 years later. Then there are de-facto standard libraries (bordeaux-threads, lparallel,…) and other libraries. Implementations continue to be optimized (SBCL, CCL) and to develop co…

The "very compact, never changing" language will end up not quite expressive, thus prone to boilerplate; look at Go.

Lisps avoid this by building abstractions from the same material as the language itself. Basically no other language family has this property, though JavaScript and Kotlin, via different mechanisms, achieve something similar.

Post reply on HN