125 points · by zdw · 2y ago · 42 comments
You only need to look at C++ papers where superhumanly smart and driven IQ 200+ people desperately try with all their will to define a language or stdlib feature/improvement that preserves ABI backward compatibility and then finally give up and throw the towel after two dozen iterations and rejections. And also suffer from severe burnout in the process.
The problem is that they're not just a library people use directly: they're a library that is often used by other libraries.
The worst possible form of dependency hell is when you want to use libraryA - which depends on requests<3.0 - and libraryB, which depends on requests>=3.0, at the same time.
At that point, you're simply stuck. You cannot use both libraryA and libraryB at the same time until they both upgrade to the same underlying requests dependency.
Python projects are affected by this because it isn't currently possible to have two versions of the same library installed at the same time, because they clash with each other in the sys.modules global namespace.
This isn't true of all modern programming languages - I've been meaning to dig around and figure out which ones are affected by this problem and which are not - I think Node.js and Rust have mechanisms for this, but I don't think Go or Java do.
Go's module system was specifically designed with this problem in mind: https://go.dev/blog/versioning-proposal
I think Java projects get around this when they have to with shading, but that's a bit clunky.
There is a global cache of downloaded packages, but it's just a pure cache and happily stores multiple different versions of the same package.
Each Dart application (or package) has its own set of selected package versions independent of any other application on the same machine.
Python (thanks to virtual environments) works fine at multiple package versions, it's only when they need to be running in the same application process at the same time that you run into problems.
go codifies foo -> foo2 as foo -> foo/v2
If there are truly better ways of doing things /that matter/ in some space, find a way to incorporate them. Easy parallels to screw driving options. I'd be surprised to not see a flat head on outlet covers in any house. I'd be surprised to see traditional drives (philips, flat, or the one that looks like philips...) on most anything made by a crew nowadays. There are objectively better drivers, but it would be obnoxious to constantly have a different driver for every item in your house.
https://pypistats.org/packages/httpx - 2 million downloads a day (requests has 15 million https://pypistats.org/packages/requests)
https://www.baldurbjarnason.com/2024/disillusioned-with-deno...
If you're looking for alternatives: https://www.python-httpx.org/
The problematic design is something I see fairly frequently from people who aren't familiar with sum types, aka modelling data that has logical ors. It's very common in the Javascript world as well, for example, and in Go it's baked in with functions returning four possible values (success and error, success and nil, nil and error, nil and nil) when only two are valid.
A better design uses a combinator libraries / builders / fluent API. These are little finite state machines and the best libraries make it so invalid transitions cannot be compiled (which requires a type system).
My preference would be to focus on excelling on the small-scale stuff and leave the complex stuff for ecosystems better aligned with that; basically let Java be Java and Python be Python.
Statically typed can incrementally end up with too many parameters too, but the static typing generally helps reduce the complexity and there is generally more incentives to start binding the parameters up into meaningful other structs. Dynamically typed languages on the other hand have the tendency to start widening what types each parameter can take which makes the problems even worse. Is "targetURL" a string, an array of strings that will automatically turn the return into an array of results, an object that implements ".toURL()", a function that will be automatically called with some magic parameters, a None which will then invoke other magic to get the URL from somewhere else, etc.?
(Don't worry, dynamic typing fans, static languages have their own characteristic failures, like the aforementioned God Object.)
Dynamically typed code bases are not doomed to end up this way. It can be avoided with discipline, which starts with the awareness that it is a problem at all. And it's a very good idea to learn to avoid them, because they're terribly difficult to tear back apart once constructed. I've worked in a code base that darned near had a "JustDoEverythingWeCanPossibleDo(...)" function, where (...) doesn't represent the true horror because there were rather a lot of global variables getting set that had huge impacts on the process as well. Trying to pull that apart to do any real work was, ah, an experience.
More recently, this is the case with typed Python. Again, the dynamic-ness of Python - which easily exceeds that of JS - was part of the original design for type annotations. Turns out it doesn't work well with things like forward references or type parameters, so ugly hacks (like stringifying type names) were introduced to deal with that. Now there's yet another revamp to fix the resulting ugliness and inconsistencies (take a look at https://peps.python.org/pep-0649/ to see what I mean).
Agreed 100%. Strongly prefer python for the simple scripting and conceptually simple mental model, and others for more complex stuff.
Also, don't use tools that were not designed for the job from the beginning and then complain that it does not fit your use case.
No, those ships are setting sail with anchors down, and complaining why they're moving so slow.
> Requests has always had modules intended for its use and only its use. At some point, we tried to document them for ourselves and that led to people using them externally and then filing bugs against them. This is a perfect example of 3 adults who did not consent explicitly to the use, but Python says that we must have because we didn't hide them well enough.
I don't understand the problem? It's bad that users reported bugs in internal modules?
as long as you don't work somewhere that has its own internal CA infrastructure
requests decides to use its own built-in CA store instead of the carefully tweaked OpenSSL default (the location of which you may not know declaratively)
meanwhile urllib works fine
(yes I read further down where this point is sort of mentioned)