Hacker News new | ask | show | jobs
by burntsushi 18 days ago
(I am on the Rust libs-api team. I say "we" below, but I didn't do any of the amazing new range type work.)

> Why replace the already existing std::range in-place with the new version

We didn't. `std::range` is new. The existing range types have always been in `std::ops`. They have to stay there because we don't have a way of resolving paths in an edition dependent way.

See: https://rust-lang.github.io/rfcs/3550-new-range.html#new-pat...

> The other day there was some talking about Go's stdlib around here, and I truly believe they got it much better thought out.

I used Go for over a decade and loved every minute of it.

As someone with significant API design experience in both Go and Rust, Go has it way easier. I don't want to go into a big long diatribe about it, but the space in which Rust operates means that getting APIs correct in a way that lasts forever is harder. To a first approximation, this is a result of project goals (hand wavy: being able to write code while thinking about "what I want the CPU to do") and expressive power provided by the language.

Go added generics after I mostly stopped using it, but even with that, there are considerable differences in expressive power that translate directly into more complex APIs.

Plus, Rust started with Cargo. Go didn't get "proper" package management until much later. The promise (and one that it has fulfilled ten-fold) was precisely that Rust's standard library could be "small" and gaps could be filled by ecosystem crates that can use semver incompatible changes to evolve when necessary.

(My intent is for the above to be mostly descriptive. I'm not trying to cast shade on Go here. The Rust and Go projects have different goals that they optimize for. To be prescriptive: Go does an excellent job of optimizing for their goals IMO. And also, IMO, to be frank, I would consider this a feature of Go that it has over Rust. Having batteries in std is great. I'd love to have more. It's just fucking hard in the Rust world. That's not to minimize and say Go has it easy... But, well, okay. I'll stop hedging here. Lol.)

1 comments

I believe by a wide margin the most significant long term problem with rust is lack of a good and comprehensive standard library, or a FEW set of crates that provides a really good set. We are in the age of supply chain risks and I personally know many great engineers who shun languages whose community / library providers don't take this problem with utmost care. At this point in time, rust is being treated like nodejs. That is not fair to rust, but that is the reality of the current situation.

Go, on the other hand took simplicity as a major goal, and while not the most efficient or expressive language out there, that single goal is paying massive dividents.

The good news is, all this means, is that rust can / will be a lot more serious when someone, possibly a big corporation with deep pockets to maintain this until a critical mass has formed, develops and maintains a golang-style standard library. It can be like C++'s in which the initial std lib was crap compared to what it is now. But people ended up using and eventually evolving the language and the std lib together. We are missing that kind of library at the moment.

Or just make it more difficult to squat obvious namespaces, and add an identity management system (like PGP Web of Trust, but simpler) so you can limit yourself to trusted packages, e.g. packages vouched by your preferred set of root signers who publish compilations of trusted publisher keys.

Expecting a kitchen sink approach for a low-level language can't work out. In low level systems languages your algorithms and interfaces are (or should be) much more tightly bound to specific solutions. It's much easier for abstraction to become excessive and counterproductive.

> so you can limit yourself to trusted packages, e.g. packages vouched by your preferred set of root signers who publish compilations of trusted publisher keys.

This is really not good enough. The real gigantic problem with supply chain risk is not that you get tricked to use a package by bad actor, it is that if everyone using gazillion packages by known good authors, that makes all those known good authors with upload rights for their own packages into exploitable vulnerabilities for all the software that depends on their libraries. So far, this has mostly looked like someone stealing creds and sneakily uploading compromised versions, if the situation persists it will eventually get worse with organized crime attacking and using rubber hose cryptoanalysis on devs. There is too much value hanging on too wobbly a foundation here, the situation is not stable and it needs to change.

The C++ standard library is terrible because it was designed from nothing with no actual real-world testing. IMHO the best path forwards for Rust is that when crates become established and "complete" with little further development needed, they should eventually be merged into some large conglomerated library with an actual organization behind it. This doesn't necessarily need to be the standard library that ships with the language. Yes, this would end up like Python, where eventually there would be 4 http clients in there with 3 of them deprecated, but that would still be better than the present state of affairs.

The C++ std lib is no longer terrible. It is really at a usable level these days. Not fun, but totally bearable. The motivation for C++ has never been the quality of the language or the std lib anyways, so it can happily chug along in many places (including the browser I am typing this on).

I disagree about merging existing "done" libraries into a mega library. That can work to some extent, but that approach will not produce something lasting (in the sense that it will remain without the need for changes for a long time). The way to achieve a lasting mega library is by putting all the pieces you need, and constantly working to increase the consistency between them. Somewhat like turning a long winded rambling into a much denser article.

Going from a set of good and working libraries to a large CONSISTENT library would be substantially laborious. Hence the need for someone with deep pockets to take it on. (There are other ways for that to happen but those are rarer).

It worked well for C++ during its first decade, each compiler had quite nice frameworks with kitchen sink approach.

It went out of favour since the 2000's, because of the raise of ecosystems like Java and .NET, followed by everyone with exception of Microsoft, going for other systems programming languages on their desktop and mobile OS platforms.

Also the consequence that we eventually got reduced to GCC, clang, and MSVC, and only one of them cares about frameworks. The other exception being C++ Builder, but that one is largely ignored outside big corporations.

C++ (the language) and its extreme complexities (each perhaps added for a good reason at the time, and then held together with backward compatibility as glue) reduced itself to gcc and clang. Not the std lib. The std lib is, de facto, removing some of the complexity.

Recent C++, together with a couple of major libraries, and with a good style guide and a matching lint (that removes / restricts many footguns) is far better than it was, 15-20 years ago. While it is not exactly cool, it can be totally bearable.

My point is the current success can be "copied over" to rust by cloning (or otherwise obtaining) a good base std lib, and a few domain specific comprehensive libraries. That doesn't even need to affect the existing ecosystem. There can be several parallel ecosystems and each one can be relatively thriving (one doing nodejs style YOLO, one doing enterprise extreme best-practices, one doing efficient embedded or OS level work, etc.). However, apart from the nodejs style community, the rest will benefit [heavily] from a base library that is well designed and NOT subject to change. Even a travesty such as a vibe-cloned golang std lib would be an improvement over the current situation.

> Recent C++, together with a couple of major libraries, and with a good style guide and a matching lint (that removes / restricts many footguns) is far better than it was, 15-20 years ago. While it is not exactly cool, it can be totally bearable.

Which is the main reason why despite its warts, C++ is my go to systems language, when I need to do something outside Java, C#, node. It is anyway for "unsafe stuff" for the most part.

Additionally being the systems language those runtimes rely on, and for stuff like GPGPU.

Always use static analysers and hardened runtime, it isn't Rust, but still so much better than C.

> My point is the current success can be "copied over" to rust by cloning (or otherwise obtaining) a good base std lib,

That I agree as well, it cannot be that for basic stuff like general purpose error handling, or handling macros, we need to rely on third party crates. Or that for all pratical purposes, tokio is the async runtime.

Honestly, at fundamental level, it is less of that need being dependent on third parties, and more of not having at least ONE set of consistent libraries (or one big library). To me the real value add of golang's std lib is not that it is developed by the language authored (that is maybe the third or fourth key point). The first one is the existence of one set (or 1.5, heh, if you consider golang.org/x slightly different) of libraries that are polished and hammered to be consistent together (primarily by spending an enormous effort on simplicity, but also on repeated polishes prior to the first notable public release and some thenafter). This is at the core of what I think rust needs right now to break through and penetrate into real C++ and golang circles.
That's just rust culture there is no changing it at this point. How many tools are new users exposed to in the first hour of the language? 'rustup -> rustc -> cargo -> random nonstandard crates, toml, git' (and then the optional rustfmt, language server, ide, clippy)

This kind of spam trains new users from the get to stop thinking about their tools. Is it necessary? Of course not, the language itself can be written with chalk and stone. The lowest tech solution naturally leads to the most comprehensible code that solves the problem, mo' tech mo' problems. We shouldn't train beginners to work on the ISS before they know how to hold a mop.

Go has this problem too, just to a slight lesser degree. The tools existing are debatably a problem, but them being pushed on beginners is certainly one. And just maybe the point of programming isn't to contribute to billion line corporate codebases.