3 ms·
An expansive Standard Library has a cost, which will be paid by your users (programmers, maybe their end users) in several ways. I see a Package Repository as a
by tialaramex 3y ago
An expansive Standard Library has a cost, which will be paid by your users (programmers, maybe their end users) in several ways. I see a Package Repository as almost always strictly better than such a Standard Library.
1. Unlike a Package Repository, there is only one Standard Library. Got a Goose in your stdlib? That's the Goose. Even when this Goose is completely wrong for the application, you will need to work very hard to get people to use their GoodGoose instead because Goose came with the standard library. It's not stupid, it's advanced. See C++ std::unordered_map and std::list which are - respectively - the unordered map or list you probably should not be using, but hey, they're in the standard library.
2. Unlike a Package Repository the Standard Library must chase HEAD. New shiny feature in your language is awesome for almost everybody but it makes the Goose tricky so that's going to take a bunch of work? Sorry you must fix the Goose before you can ship the shiny feature, because it's in the Standard Library. This is maybe OK if many people need a Goose, you had to fix it anyway, but in our expansive library maybe most people only need Bird, or at most Duck, and use of Goose is actually uncommon. Too bad, Goose blocks the whole feature.
3. Compatibility. Of course the other option is to remove Goose from your standard library. Merely marking it "deprecated" is different. That's maybe useful for teaching but most of the considerations still apply even though you now don't recommend using it - but in Python and I believe even in Java, gradually, they remove things from the standard library (Python calls these "Dead batteries" in reference to the "Batteries included" policy). Code which worked five, ten, fifteen years ago won't work with the latest stdlib. If you decide to pay this price it's paid by your whole language. If some third party package didn't support the new language version, it's on the community to decide whether to write a compatibility package or if that's too hard/ not worth it. But for the stdlib you own the problem.
- pclmulqdq 3y agoPackage managers have their own versions of these problems, and I would suggest that there is a balance here, but it weighs more in favor of standard libraries than you think. Here are the package manager problems: 1. Discoverability. Need an unordered map? We've got 20 of them, all made for slightly different use cases. No, their APIs are not cross-compatible. Also, only one of them has documentation and it's only in English/Chinese. 2. Lagging HEAD. Want to develop with the most recent version of the language? Too bad, package Foo was written for Python 2 and is now broken. The maintainer of foo may get around to updating it if you pay him. 3. Compatibility. The standard library runs everywhere. Package Foo only runs on M1 Macs, and has subtle bugs on x86 machines. 4. Supply chain hell. Chances are one of your packages or one of their packages is maintained by one guy. If a core function like left_pad is slow, you're shipping inefficient code. If one of those packages decides that you need to evangelize about how Putin is bad, guess what's showing up in your logs? If one of them gets compromised, you're on the hook for the damage. This practically means a lot of audits or a lot of sleepless nights.
- durumu 3y agoI think a standard library is not negative, but rather acts as a multiplier for decisions. The C++ std::unordered_map designers made a bad decision (requiring buckets to be iterable) and now, like you say, it's hard to get people to use the superior absl::flat_hash_map. But if the standard library designers make a good decision -- for instance, Python's extremely well-designed dict that is fast, insertion-ordered, and forms the basis of nearly every object -- then everyone gets to reap the benefits without the cognitive overhead of figuring out what the best hash map is.
- tialaramex 3y agoPython's current dict is reasonable by Python's standards (it's slow but not ludicrously slow, it's big but not ludicrously big and insertion ordering, though non-free, is not a great extravagance and is convenient for newbie programmers) but it wasn't so very long ago that their dict was bigger, slower and didn't preserve order. Even early Python 3's dict was like that. There's a benefit for vocabulary types, which Python's dict clearly is. I think you could make the argument for C++ std::unordered_map if it wasn't awful and I would make that argument for std::vector even though it's not the best possible design it's fine and it's vocabulary. And don't get me wrong, the opposite is a problem too. Python's dict isn't from their standard library it's a core language feature. Python doesn't formally have a freestanding mode so that doesn't make much a huge difference but e.g. the syntax for dict is not something a third party library could do. C++ here chooses to go out of its way not to put important stuff in the core language, so e.g. the built-in array type in C++ is garbage, it's the array from C. You can have a vaguely reasonable array type, std::array but it's from their stdlib and so can't change language syntax. Likewise tuples, the C++ rather unconvincing attempt at sum types (std::variant) and so on. The result is that C++ falls into the Turing Tarpit where everything is possible but nothing interesting is easy, which is maybe one harder way to play Advent of Code without needing an esolang that's designed to be awful but doesn't make a lot of sense for engineering. It's too late for WG21, but don't do this at home.
- pjmlp 3y agoThe beauty of a rich standard library is that it works everywhere there is a full implementation. I rather have a Goose than none at all, or a GoodGoose that only works when all the stars are aligned and I have made the right decision regarding what platforms to target.