3 ms·
Lack of serialization/marshalling support at the language level is a big issue. Serialization eats up a lot of CPU time in any message passing system, it's slow
by Animats 11y ago
Lack of serialization/marshalling support at the language level is a big issue. Serialization eats up a lot of CPU time in any message passing system, it's slow when done with run-time introspection, and it's something that can be done fast by code compiled for a specific structure. Attempts to speed up serialization usually involve preprocessors; there are preprocessor code generators for Google protocol buffers and OpenRPC marshalling.
It's probably possible to do serialization code generation at compile time in Rust.
- stevedonovan 11y agoOr any language where you can write code that generates code at compile time, like Nim. Unfortunately, any answer for C++ is unlikely to be so elegant, so preprocessing feels like a lesser evil.
- Animats 11y agoIf you had some way to apply templates to each element of a structure in sequence, you could use template metaprogramming to do marshalling. Suppose you could write struct pnt { float x; float y; bool valid; }; pnt p; and then have auto s = serialize(p); expand into auto s = serialize_field("x", p.x, serialize_field("y", p.y, serialize_field("valid", p.valid))) then serialization could be implemented by defining serialize_field for each type.
- kibwen 11y ago> It's probably possible to do serialization code > generation at compile time in Rust. This is precisely how it's generally done. See https://crates.io/crates/serde https://crates.io/crates/serde for an example.
- atilaneves 11y agoOr any other language with compile-time reflection, such as D. Here's my serialization library in it: https://github.com/atilaneves/cerealed https://github.com/atilaneves/cerealed
- seivan 11y agoI am using https://google.github.io/flatbuffers/ https://google.github.io/flatbuffers/ right now, it's going slowly but I'm still learning c++