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

Use serde instead of rustc-serialize ? #18

Closed
azerupi opened this issue Jul 30, 2015 · 8 comments
Closed

Use serde instead of rustc-serialize ? #18

azerupi opened this issue Jul 30, 2015 · 8 comments
Labels
M-Discussion Meta: Discussion

Comments

@azerupi
Copy link
Contributor

azerupi commented Jul 30, 2015

I have heard good things about serde. At the moment I use rustc-serialize, should I use serde instead?

What are the differences?

@azerupi azerupi added Help Wanted M-Discussion Meta: Discussion labels Jul 30, 2015
@kbknapp
Copy link
Contributor

kbknapp commented Aug 2, 2015

serde is super nice when used in the nightly branch because you can simply mark your structs as #[derive(Serialize)] or #[derive(Deserialize)] and then encode/decode them to any format supported by serde (I used JSON, but I hear YAML is being worked on too). It worked perfectly!

The downside is you're limited to the nightly branch. serde can be used on stable, but you end up implementing those traits yourself (which isn't too hard, but it is work).

Beyond that, I don't have a lot of knowledge about the differences :\

@azerupi
Copy link
Contributor Author

azerupi commented Aug 2, 2015

Ok thanks for the clarification!
I will probably wait until all the features are in stable then, and focus on the other things in the meantime.

@gambhiro
Copy link
Contributor

Just for reference, this is waiting for rust-lang/rust/issues/29597 and rust-lang/rust/issues/29644 to land in stable.

@azerupi
Copy link
Contributor Author

azerupi commented Aug 15, 2016

I think it would be OK to make the jump now. Serde is becoming the defacto serialiser / deserialiser even though some ergonomic features are only available on nightly.

I think there are 2 ways we can make it work:

Code gen is obviously more convenient but requires some extra work in the build script. Which is not a big deal.

@gambhiro
Copy link
Contributor

I followed the serde readme and made an experiment in this branch, refactoring only bookconfig.rs.

Although it works, the build time has become quite long, 1.5 mins instead of 9 secs.

With codegen:

cargo build  86.78s user 0.57s system 99% cpu 1:27.37 total

while before:

cargo build  8.93s user 0.37s system 99% cpu 9.327 total

I didn't PR because I think it's not worth the long feedback time while working. The feature tickets are apparently being worked on, I suggest waiting until they arrive in the stable release.

@azerupi
Copy link
Contributor Author

azerupi commented Aug 16, 2016

That is a reasonable choice, thanks for looking into it :)

@dtolnay
Copy link
Member

dtolnay commented Aug 28, 2016

@gambhiro that doesn't seem like a fair comparison because you are not including any of the other dependencies.

On my computer a build following cargo clean takes 68 seconds without serde_codegen and 115 seconds with serde_codegen, but subsequent builds take 9 seconds either way. When iterating you only care about the 9 second time which is the same for both.

@gambhiro
Copy link
Contributor

@dtolnay Thanks for explaining. I'm quite new to the rust build tools.

@azerupi azerupi closed this as completed in 67aee5c Nov 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-Discussion Meta: Discussion
Projects
None yet
Development

No branches or pull requests

4 participants