3 ms·
> I wish more programming languages provided interfaces for building libraries around the std library like what Go does. It makes using libraries a lot better b
by lmm 4y ago
> I wish more programming languages provided interfaces for building libraries around the std library like what Go does. It makes using libraries a lot better because you aren't dependent on that library as long as it uses the std library interface.
> This is huge for things like database drivers which might become outdated or not support certain features. In Go switching database drivers in as simple as importing the new library. You dont have to change your code.
The effect is that every database driver becomes outdated and doesn't support certain features, instead of just a few. Python people have a saying that the standard library is where modules go to die. Java's database drivers massively lag behind (e.g. there's still no good async support for most of them), because JDBC is a lowest common denominator that every driver has to be dumbed down to, but is established enough that it sucks all the oxygen away from any efforts to write better drivers.
Far better to keep the standard library small and allow modules to update on their own terms and their own schedule. If the library you're using does what you need, you can stick with it, but a better alternative (which always means a new interface in practice - the idea that you can make substantial improvement without changing the interface is mostly a myth, because the interface is the most important part of a library) can appear and compete on its merits, and if the improvements are worth migrating to then it will win out.
- alfiedotwtf 4y agoExactly. Perl had BerkleyDB as part of Core, as well as CGI. How's that going for the Perl footprint!
- born-jre 4y agoone approcach with golang is make interface that can be leaked if you really want, you will be using standard interface 99% but if you need sth not provided by abstraction you can ask for underlying impl `db.Driver()` and cast to appropriate type.
- lenkite 4y ago> Java's database drivers massively lag behind (e.g. there's still no good async support for most of them), Very Hard Disagree. JDBC is pretty amazing actually. Thats why you find so many Database tools and wizards written in Java as opposed to Rust. Regarding async - With Java 19 virtual threads , you have newer versions of JDBC drivers support async with none to minimal changes. Example: https://medium.com/oracledevs/introduction-to-oracle-jdbc-21c-driver-support-for-virtual-threads-189b918c56f4 https://medium.com/oracledevs/introduction-to-oracle-jdbc-21... I am very, very glad that human civilisation standardised on one system for gears instead of every manufacturer making their own special snowflake.
- lmm 4y ago> Very Hard Disagree. JDBC is pretty amazing actually. Thats why you find so many Database tools and wizards written in Java as opposed to Rust. Java is much older and bigger than Rust. I don't think its level of database tooling is noticeably better than other big languages with less of a standard database API (e.g. Python). > Regarding async - With Java 19 virtual threads , you have newer versions of JDBC drivers support async with none to minimal changes. So it's only taken what, 15 years, and even then it's only been done because they found a way to make it happen without having to actually change the API (which it remains to be seen how well that actually works in practice - I'm pretty skeptical because other platforms have tried and failed with that approach).
- dragonwriter 4y ago> I don't think its level of database tooling is noticeably better than other big languages with less of a standard database API (e.g., Python) DB-API 2.0 (PEP 249) is very much a standard database API.
- badrequest 4y agoGo doesn't provide standard library implementations of database drivers, only standard library interfaces for driver implementations to adhere to.
- lmm 4y agoI addressed this in my last paragraph.
- JodieBenitez 4y ago> Python people have a saying that the standard library is where modules go to die. That's just a quote from a 10 years old talk by Kenneth Reitz, and it's quite an overstatement.
- jiehong 4y agoJava has something called R2DBC as well, the async jdbc driver equivalent. Most major db have such a driver nowadays.
- lmm 4y agoRight, but it's very hard to overcome the inertia of an established standard. (JDBC isn't actually in the standard library IIRC but it's a JSR, so it's an "official" part of the platform and that creates a lot of pressure to follow that)
- pjmlp 4y agoAll those complains always forget that the standard library happens to be available everywhere the language has a full implementation available, while third party libraries are hit and miss. I rather have outdated code that works, than not having anything at all.
- lmm 4y ago> All those complains always forget that the standard library happens to be available everywhere the language has a full implementation available, while third party libraries are hit and miss. Only if your dependency management is bad. And if you're stuck running on e.g. an old install of the language, there's at least a chance that the third party library will support it, whereas if you want a new standard library feature you're SOL.
- pjmlp 4y agoAll dependency managements are bad when they assume UNIX only workloads with C compilers pre-installed. And on top of that download half of the Internet for doing an hello world with error handling or asynchronous code.
- JodieBenitez 4y ago> Only if your dependency management is bad. Please give an example of good dependency management in any language. It seems to be one of these subjects draining constant displeasure. I'm not advocating against third party libraries, I just think a reasonably rich standard library sets a good foundation for them.
- lmm 4y agoMaven has worked well for over a decade. I understand cargo is similar. If your dependency management is any good then there's nothing to lose and a lot to gain from splitting your libraries out and allowing them to have independent release cycles. You can always do "platform" releases that aggregate together a bunch of finer-grained libraries with versions that are known together if you have a use case for that; going the other direction is a lot harder.