17 ms·
I’ve said it many times: a pure C++20 standard library imagined from first principles with total disregard for legacy code would do amazing things for the reput
by jandrewrogers 1y ago
I’ve said it many times: a pure C++20 standard library imagined from first principles with total disregard for legacy code would do amazing things for the reputation and value of C++ as a language. It could be so much better than it is.
Yes, I understand, compatibility. At some point, clean new code bases should not be burdened with that albatross.
- thenewwazoo 1y agoIsn't that just abseil? https://abseil.io https://abseil.io
- jandrewrogers 1y agoNot even close, and I am a fan of abseil. The design of abseil has legacy constraints that don’t need to apply to a C++20 clean room implementation. I have better re-implementations of abseil components in my own “standard” library simply because I didn’t have those constraints. There are many good libraries out there, or fragments of libraries, but I’ve never found one that really scratches this itch.
- hoten 1y agoCould you give a couple examples?
- krapht 1y agoOf libraries that are better than the STL? Or data structures that the STL is missing? Without getting into the weeds of esoteric data structures and algorithms I think there's a few holes that aren't addressed: https://github.com/martinus/unordered_dense https://github.com/martinus/unordered_dense provides better replacements for unordered_map/set. The STL is missing B-trees and B-heaps, as well as d-heaps. STL is also missing a radix sort, which is even more sorely missed now that we have std::executor::par_unseq to play with.
- maattdd 1y agoExamples of better design than abseil in a pure C++20 implementation
- jll29 1y agoCompatibility is not a reason for not attempting to realize your proposal. (One just needs a difference namespace from "std" e.g. "lib".)
- monkeyelite 1y agoThe problem with C++ is not a bad standard library. It’s probably one of the best algorithms and containers libraries in any language.
- 112233 1y agoWhat are you comparing it to? Because wow.
- monkeyelite 1y agoSame question for you.
- 112233 1y agoEvery time I have to work with text in C++ using stl feels like pulling teeth. It has gotten better over years, but even php gives one stdlib envy. The idea to base everything on iterators instead of ranges, blowing up the code (and amount of errors) — it would have made sense for pure algorithms, but stl insists on having ownership of object placed in the containers. No sane way to work with binary data. Inconsistent allocation and exception ideology through the years. Mysteriously missing functionality. What little ruby, python, php I have written — nothing has felt as clunky as STL. E.g. vector has no "sort" member function. What great benefit not adding it for convenience has brought?
- platinumrad 1y ago<algorithm> is a very good header, but most of the containers are substandard at best. `std::unordered_map` is required to be node-based, `std::map` can't be a B-tree, MSVC's implementation of `std::deque` is infamously a glorified `std::list`, and so on. Pretty much everything else (e.g. iostreams) is horrible.
- TuxSH 1y agoDon't forget <tuple> not mandated to be trivial when it can be (and in fact never being trivial with GCC's stdlib), std::print performance issues (see P3107R5, P3235R3), etc. Heck, even std::atomic was designed with only x64 in mind (it clearly shows), and is unusable outside it. One is incentivized to write their own "atomic" class until P3330R0 is approved for RMW-centric platforms ISAs like Aarch32 and Aarch64. And of course, Rust already has "fetch_update"...
- prydt 1y agoHave you seen libkj [1]? I've used it and really enjoy working with it. It has a rust-like owned pointer and the whole library uses these smart pointers. It has proper container classes based on B-trees and its also got an async runtime. [1] https://github.com/capnproto/capnproto/blob/v2/kjdoc/index.md https://github.com/capnproto/capnproto/blob/v2/kjdoc/index.m...
- jeroenhd 1y agoI like SerenityOS' "standard library". It has some Rust-like features (like ErrorOr, which is a lot like Result) but also some C++ usability enhancement that make use of modern C++ features rather than trying to force a C++-shaped peg into a POSIX-shaped hole. The only exception I know of is the pledge() implementation (which uses a space separated string rather than something like an array of enum values), but having pledge() at all is a pretty major improvement. SerenityOS' original "make no use of external libraries" approach made one of the more complete re-imaginings of the C++ application landscape I've seen. It really changed my perspective on what C++ could be.
- tyrellj 1y agoI was curious, and a bit distractible this morning, so I took a look at their git repo. I did some osdev tinkering in college so I find this all interesting. AK seems to be their standard library that you were mentioning, but there's some interesting things going on in their Libraries dir too. https://github.com/SerenityOS/serenity/blob/master/AK/ https://github.com/SerenityOS/serenity/blob/master/AK/ https://github.com/SerenityOS/serenity/blob/master/AK/Result.h https://github.com/SerenityOS/serenity/blob/master/AK/Result... https://github.com/SerenityOS/serenity/tree/master/Userland/Libraries https://github.com/SerenityOS/serenity/tree/master/Userland/...
- kgeist 1y agoD already had this, 2 "standard" libraries: https://news.ycombinator.com/item?id=6066174 https://news.ycombinator.com/item?id=6066174 >The reason it caused the division at community is that the ones that you could not use both on the same project, this meant that for a while you had two "D" languages that were separate, libraries made with one did not worked with the other...
- deleted 1y ago[deleted]