Rust is not the language for you if you don't like traits
github.com
github.com
I think a fair amount of unpleasantness in recent years has come from this disconnect: some people think that by publishing on crates.io you're making some promises (that they might not assume simply for, say, having a repository on github).
To me, using an extremely generic name like 'base64' does suggest that you're in the second camp, and so that you might expect to have a conversation that feels more like "we're equals building this project together" than "I'm the maintainer and my judgement is all that matters".
I feel like most of these issues stem from the very young age of Rust (2015 -> v1.0). Give it a few years and these problems will stabilize as the long term crates will survive and the short term will grow stale.
I see the arguments against organization/namespacing in Rust (ala Maven or NPM) and I kinda shake my head. The reality is, crates.io is a crazy bazaar, people end up taking crate names and then abandoning their projects, leaving that name forever unusable.
e.g. at work we have an internal crate named "event" (on our internal repository) that conflicts with an abandoned public crate of the same name that hasn't had commits in 8 years. This leads to confusion if you get your cargo config wrong. But it's also kinda frustrating that this very generic name is ... lost to time now.
https://internals.rust-lang.org/t/blog-post-no-namespaces-in...
Create an alternative crate if you care enough, or pick a different crate to use. You can even literally pin to a previous version of this crate.
I have zero sympathy for folk coming along to a closed issue, which has been clearly closed and explained and trying to tell the maintainer they know better.
There's no point going to the issues tracker to tell him/her that though: just move on and pick a nicer library/maintainer.
People forget that base64 has variant _all the time_, that leads to bugs.
So deprecating `decode` made sense.
But then what do you do instead?
a `decode_**` for each standard variant ... not really nice design
a `decode2(data, standard)` better but if you anyway need to import the standard and one additional thing, that thing could be a trait instead of a method and the `2` in the name is quite confusing
a braking change? definitely not worth it
a `prelude` module which exports the engine trait and reexports like `BASE64_STANDARD`? Well he did that.
I mean it's not terrible design.
But having to do a `use base64::prelude::{Engine, BASE64_STANDARD}` is also not terrible design.
Nor is `use base64::engine::{Engine, general_purpose::STANDARD as BASE64}`, through it's less nice.
So given that there is already and equally good design there anyway, there is no reason to add additional code, especially if that code would make it easier to make a mistake when using it.
I guess if this would be designed now from scratch it would have something like a `decode(data, standard)` function, but `decode` is already in used (even through deprecated) so we can't have that.
That's the benefit of having a more explicit API. Doing it the other way and making a generic API on top of a simplified one is harder.
I'm not a rust user; is there anything preventing someone from making a "base64-simple" crate which uses this base64 crate to make a higher-level API?
I was on the opposite side reading the github comments, notably because of my recent usage of python base64 but your (and GP) comments make a lot of sense, i wasn't using logic but habits. Thanks.
There’s a reason that words like “the” and “it” are not 60 characters long in any spoken language.
If you’re making it super verbose to do very common tasks, you’re fucking up your interface.
How Do I Make This Hard to Misuse? - https://ozlabs.org/~rusty/index.cgi/tech/2008-03-30.html
What If I Don't Actually Like My Users? - https://ozlabs.org/~rusty/index.cgi/tech/2008-04-01.html
> sweng.the-davies.net points to the site "sweng" which does not exist. Please contact the domain administrator.
There are archives, however: https://archive.ph/NZHmW
...and TIL that despite the name, this is not Rust-specific.
It forces the developer to consider which configuration they want, and in that, actually realize that there is a difference between URL-safe and the standard version.
That doesn't make it good, but understandable.
Not reading or looking into the context is also a common HN I mean how many people commenting did look up the context?
And why is a small open source crate for a minor annoying design aspect even on hacker news just because it's called base64????????
> Normally I agree with explicit being better than implicit, but I don't see the harm here. If there's no specific interoperability requirements, explicitly choosing a configuration isn't particularly important.
Pretty much the entire point of base64 is interop, so there would always be specific interop requirements.
And since a base64 library tends to be reflexive, a library's default tends to either "way too strict to consume any base64 you can find in the wild" or "so loose you can get a carrier strike group through" e.g. Ruby and Python will strip out any invalid character from the input before attempting a parse, python requires padding to be present but I'm not sure there's any way to make ruby's decode64 fail as long as you give it a string since it does not.
And if I have to interact with that, it’s an interop issue
Maybe this illustrates why it's good to have base64 in a language's stdlib. That way 90% of people can just use a couple of simple functions, while libraries like this can still exist for those who really need them.
Without weighing in on the merits of the comment, the delivery feels very Poettering-esque.
BUT the convenience methods defaulting to "standard" base64 instead of "url safe" base64 because it's one of the things where people don't think about there being more then one standard/configuration and it then loading to bugs in their code
so deprecating it makes sense, and without a braking change (which makes no sense here) you can't replace it with anything better
and because of the prelude module the import isn't that bad e.g.: `use base64::prelude::{Engine as _, BASE64_STANDARD};`
and even ignoring that most imports are auto generated, sorted and formatted by rust analyzer for most people most of the time
so it's eitherway at most a minor anoyence
so I can understand that the author is feed up with people annoying him about that again and again and again
And in fact there's others who would make a counter argument that excessive reliance on traits is a bad over-complexity-smell.
The reality is it's fairly large language community already, and lots of people have lots of different opinions.
People behaving poorly on github issues/PR discussion is so common in every language it tells much more about the internet/open source culture than it tells about Rust users (there's no such thing as a “Rust community” nowadays BTW, it's not 2016 anymore and the language user base has grown so much the user base is now as fragmented as it is for any mainstream language).
If it matters so much create one of your own. Why have a go at open source maintainers doing things on their own time?
What "explicit" means vague. Does it mean you want the code to be verbose? Noisy? Because that's silly, and Rust doesn't even have a history of doing that. We went from try! to ?, we went from impl Future to async/await. I'd rather people talk about what they really mean than just repeating that line over and over again.
edit: also it's really weird the OP seems to keep wanting to post this thread. If you don't like their library, fork your own?
But that could totally be avoided if you just export both of them instead of hard-locked the interface. People don't really want to fork the god-damn project just to change the two character you hard-coded.
Even marking them unstable and making it unsupported would be far better than locking it down completely.