Skip to content

Instantly share code, notes, and snippets.

@erickt
Last active January 2, 2020 06:37
Show Gist options
  • Save erickt/d44f542a25ba6a155d17a2e0f1dd027a to your computer and use it in GitHub Desktop.
Save erickt/d44f542a25ba6a155d17a2e0f1dd027a to your computer and use it in GitHub Desktop.
serde history

Rust serialization has a long history. At first, there was just some very simple formats. In March 2011, Patrick Walton added support for serializing rust object metadata into EBML (reader and writer. Then in November 2011, Elly Jones added a json library. But their functionality was quite limited, and required manual serialization. So in Feburary 2012, Niko Matsakis created the serialization plugin (1, 2, and 3).

Over time, Erick Tryzelaar took over maintenance of serialization. He converted it over to the new trait system, added support for enums, structs, and generic maps, but eventually found that the serialization design couldn't deserialize a JSON value into a generic Value enum. The reason was that the old design had the deserializable type decide how to parse the next value. So for a struct like struct Foo { x: usize, y: usize }, it would tell the deserializer to parse a struct, then two fields. Generic enums however can represent any value, so there's no way for it to tell the deserializer how to parse a value.

So, he started iterating on new design. After many iterations, which can be read about here, he converged on the basic design for Serde. Since then there's been a large ecosystem developed around the language, and David Tolnay has stepped in to take lead maintainership of the project.

Unfortunately, during the phase right before Rust 1.0, it was non-trivial to write Serde Serialize and Deserialize traits. There was a compiler plugin that simplified creating these traits, but plugins required nightly Rust. It was decided that 1.0 should ship with the old serialization library as a stop-gap, and was renamed to rustc_serialize, but with the long term plan that Serde would eventually replace it one plugins were ready.

@CreepySkeleton
Copy link

Thank you for this history overview. It appears to be the only such overview, which is quite sad :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment