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

Better encoding of records #5

Open
si14 opened this issue Oct 19, 2013 · 1 comment
Open

Better encoding of records #5

si14 opened this issue Oct 19, 2013 · 1 comment

Comments

@si14
Copy link

si14 commented Oct 19, 2013

It seems reasonable to me to skip field names while encoding records if we can share record definitions between CLJ and CLJS, so (map->Person {:a 1 :b 2}) will become ["user.Person" 1 2]. This way we can save some space in the wire. If you are interested, I can try to come up with PR eventually, what do you think?

@micha
Copy link
Member

micha commented Oct 19, 2013

That sounds good to me. Totally makes sense, provided it doesn't break too many things...

  1. If there is no record definition on one side (i.e. the shared record definition assumption is false) then you'll get an exception with the current algorithm anyway, right? So your proposal won't break anything or require new restrictions on user code?
  2. Does this mean you'd need to use something other than the standard clojure data reader functions to decode records? How do you know how the fields are ordered? Maybe cljson-encode and cljson-decode multimethods instead, that you would extend on both sides (cljs and clj)? What if its only extended on one side?
  3. This won't affect performance when encoding/decoding regular persistent data structures like maps, vectors, etc., as this is the case we want to make sure is fast and correct?

Thanks for all your help!

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

No branches or pull requests

2 participants