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

Add MessagePack's encode and decode #2194

Closed
idranme opened this issue May 6, 2022 · 9 comments · Fixed by #3460
Closed

Add MessagePack's encode and decode #2194

idranme opened this issue May 6, 2022 · 9 comments · Fixed by #3460

Comments

@idranme
Copy link

idranme commented May 6, 2022

Is your feature request related to a problem? Please describe.

encode or decode MessagePack

Describe the solution you'd like

import { encode, decode } from "https://deno.land/std/encoding/magpack.ts";

const object = {
  nil: null,
  integer: 1,
  float: Math.PI,
  string: "Hello, world!",
  binary: Uint8Array.from([1, 2, 3]),
  array: [10, 20, 30],
  map: { foo: "bar" },
  timestampExt: new Date(),
};

const encoded= encode(object);
const object = decode(encoded);

Describe alternatives you've considered

@lino-levan
Copy link
Contributor

lino-levan commented Nov 5, 2022

This would be pretty huge for socketio/socket.io-deno#7. It looks like https://deno.land/x/[email protected] does exist, but having this be part of std would be really nice. Does this make sense to go in encoding?

@kt3k
Copy link
Member

kt3k commented Nov 5, 2022

It'd be also worth considering using rust implementation via wasm

@lino-levan
Copy link
Contributor

Could be a pretty huge selling point over /x/msgpackr... I don't plan on picking this up right now, but I might get back to it in a few ~weeks-months if no one else picks this up.

@idranme
Copy link
Author

idranme commented May 1, 2023

...

@lino-levan
Copy link
Contributor

@iuioiua I know recently you've been against wasm modules in std. Thoughts on this one?

@iuioiua
Copy link
Contributor

iuioiua commented May 2, 2023

I was previously against a Wasm implementation of std/encoding/varint. The number of moving parts required to operate and maintain it was disproportionally large compared to the issue it solved. It was easily solvable using only TypeScript.

On the other hand, the Wasm implementation of std/crypto makes sense as it's perhaps not easily solvable using only TypeScript and robust Rust implementations for algorithms already exist.

I'm unfamiliar with MessagePack. Either way, I'd urge any possible implementor to consider whether a Wasm implementation is worth the added complexity or can be done well enough with just TypeScript, which would be far simpler.

@lino-levan
Copy link
Contributor

On the other hand, the Wasm implementation of std/crypto makes sense as it's perhaps not easily solvable using only TypeScript and robust Rust implementations for algorithms already exist.

IMO the main advantage of std/crypto using wasm is perf, with the implementation itself being secondary. MessagePack is an interesting case because it's not immediately obvious whether performance or simplicity is more valuable. MessagePack as a format is supposed to be a "more performant + smaller JSON with more types". I think we might want a typescript implementation to start and move over to WASM if we see it as limiting.

@idranme
Copy link
Author

idranme commented Jun 21, 2023

On the other hand, the Wasm implementation of std/crypto makes sense as it's perhaps not easily solvable using only TypeScript and robust Rust implementations for algorithms already exist.

IMO the main advantage of std/crypto using wasm is perf, with the implementation itself being secondary. MessagePack is an interesting case because it's not immediately obvious whether performance or simplicity is more valuable. MessagePack as a format is supposed to be a "more performant + smaller JSON with more types". I think we might want a typescript implementation to start and move over to WASM if we see it as limiting.

👍👍

@lino-levan
Copy link
Contributor

Just finished the decode implementation and writing some tests. Will open a PR with both encode + decode later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants