eredo / dartson

Dartson is a Dart library that can be used to convert Dart objects into a JSON string.
MIT License
79 stars 29 forks source link

We need a true serializer for dart #18

Closed Emasoft closed 9 years ago

Emasoft commented 9 years ago

Following up to the discussion on the dart tracker:

https://code.google.com/p/dart/issues/detail?id=16630

We need a true serializer for dart, something that works without having to recompile at every code change and that doesn't bloat and slow down the code. So please stop using Transformers and Mirrors, and try to make a runtime version of Dartson that can be called anywhere from code, and able to serialize/deserialize any dart object on the fly.

eredo commented 9 years ago

Thanks for your feedback, but I guess the discussion should be continued within the dart tracker. A runtime based serialization without mirrors, if possible, can only be implemented within the VM (as far as I know) and for JS Code generation by transformers. This is not an official Google project so in order to request a VM based implementation please use the dart issue tracker.

Mirrors are currently required to receive informations about a dart object (same for other languages like Java, Go, ... , then mostly called reflection). To reduce the overhead in the dart2js compilation result caused by mirrors, dartson removes those references and creates a static mapping method. This is currently one possible solution to implement basic JSON serialization as easy as possible. The project is still in early stages and I'll try to improve it, however due to the limitations there is currently no other way than Mirrors and Transformers.