top | item 36645346

(no title)

kkirsche | 2 years ago

Seeing so many comments about how hard it is to just break compatibility and upgrade is sad. Instead of just throwing our hands up and saying it’s too hard, we could adopt the model the JavaScript ecosystem has seen more of which is codemods that upgrade the code for us.

If as a community we invest in those tools and make them easier to build, the cost of upgrading goes down and the velocity of high-impact changes can increase.

discuss

order

inglor|2 years ago

TC39 has a famous "don't break the internet" mantra. Even the leeway that Python has with deprecations/features JavaScript doesn't. It's versionless, code automatically gets updated to whatever the browser is using.

JavaScript evolves quickly but so does Python!

(Note that your approach is exactly what they said in the 2 to 3 transiton btw with a special tool that didn't work too well)

kkirsche|2 years ago

That’s not what that library was in my opinion, it was a compatibility layer not a rewriting tool which is what I referenced. Having a layer in between simply prolongs the issue and creates many types of problems based on adoption or not. On the other hand, when rewriting you can apply that either as an author or as an end user depending on the quality which meaningfully allows for different results.

mgsouth|2 years ago

codemod is a syntax conversion tool, using regexes. Thread-safety isn't even semantic--it's an emergent behavior question, the same as "does this code halt?" There is no general solution.

For example, is this code thread-safe?

    foo(int* x) {
        int z;
        for (int* y = x + 1; y != 0 && *y < *(y - 1); ++y) {
          z = *y;
        }
        return z;
    }
You can't tell from static analysis of the function. It depends upon what guarentees are imposed upon the passed-in "x" value. For example, if "foo" is only referenced as a function pointer passed to "baz" (also in the library), and "baz" creates "x" and uses it in a thread-safe manner, then there's no problem. But there's no guarenteed mechanical way to determine if "baz" is indeed doing the right thing, or what changes should be made to make it so.

closeparen|2 years ago

A fully general transformation from naive to thread-safe code seems like it would make you one of the giants of computer science alongside Knuth and Dijkstra.

local_crmdgeon|2 years ago

You don’t need that though - you can get a long way with improved tooling and devex

VWWHFSfQ|2 years ago

I'm not sure what "codemods" means. Just static analysis code changer? Python is so highly runtime dynamic I'm not sure a tool is even possible to upgrade behavior, preserving correctness and intent (bugs and all).

twosdai|2 years ago

Not the poster of the question,

But I think they're referencing the litany of transpilers and repackagers which exist for js. So you can add new features and then still have it run on really old systems like internet explorer 9 if you need to.

This has problems obviously and in my opinion for python it would be preferable.

My reasoning being that if you need your code to work on an older system being able to write and use current syntax is preferable to not, and the hard bifurcation that python did with 2 to 3 and now potentially with 3 to nogil seems to me just to break apart the ecosystem more.

BiteCode_dev|2 years ago

Python3 had 2to3 and python-future, the migration still took 15 years.