ALFA Exporters generate code that works alongside an ALFA runtime library that will support encoding to and decoding from JSON. This will satisfy majority of object serialisation requirements for users.
The generated code for Java (and similar pattern for CSharp) use highly efficient lambda expressions to encode and decode hierarchical data. In testing, ALFA Java JSON based round-trips were observed to 20-30% faster than Protocol Buffers JSON for round-trip conversions.
The lambda based encode decode of data is generic, there in addition to JSON, other streaming serialisation formats can easily be added, e.g BSON, Avro, Amazon ION.
Serialisation to binary is under consideration. There are several factors, as a single binary serialsation implementation will not satisfy everyone. Users have different reasons for binary serialisation;
- Smaller serialised payload, compared to JSON.
- Faster to encode and decode.
- Less GC by reducing intermediate objects, or eliminate altogether.
- ALFA ‘builder’ classes should create the final payload byte, in effect there is no serialsation step required.
- Extract an ALFA Trait definition, thereby exclude reading entire payload.
- Lazy reading of a serialised payload.
- Use back-references to reduce payload size.
- Existing investment and knowledge in a binary serialisation technology.
Some of these requirements conflict with each other. For the time being binary support for ALFA runtime will be remain to be discussed in detail with users.