Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is encouraging binary encoding/decoding a good idea? #4

Open
domenic opened this issue Jul 1, 2021 · 1 comment
Open

Is encouraging binary encoding/decoding a good idea? #4

domenic opened this issue Jul 1, 2021 · 1 comment
Labels
blocker Something isn't working

Comments

@domenic
Copy link

domenic commented Jul 1, 2021

I found the arguments at whatwg/html#6811 (comment) by @Kaiido somewhat persuasive. Basically, if you're encoding your bytes to and from a string, you're probably doing something wrong, and you should instead modify your APIs or endpoints to accept bytes anyway.

There are definitely cases where it's useful, mostly around parsing and serializing older file formats. But I'm not sure they need to be promoted to the web platform (or language).

@lucacasonato
Copy link
Owner

Hex encoding of digests is a frequent use for binary encodings. Hex encoded SHA-256 digests are very common for integrity checking.

Basically, if you're encoding your bytes to and from a string, you're probably doing something wrong, and you should instead modify your APIs or endpoints to accept bytes anyway.

Many public APIs that I don't personally have the ability to change (including ones from Google and GitHub) require the usage of base64 encoded data in payloads. I disagree that users are thus doing something wrong when using these APIs. Sometimes they are the only choice you have.

There are definitely cases where it's useful, mostly around parsing and serializing older file formats. But I'm not sure they need to be promoted to the web platform (or language).

Essentially every other language and ecosystem has builtin binary encoding. This shows there is a genuine need, and I don't think the web platform is doing anyone a favour by requiring that people include subpar external packages for this usecase. https://www.npmjs.com/package/js-base64 has 5.8 million weekly downloads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants