Wednesday, December 30, 2020

Yet Another Serialization Library

Announcing YASL: Yet Another Serialization Library!

I know what you're thinking: "What?! Another serialization library!?! Why does it sound suspiciously like YAML? Isn't YAML enough?"

Good questions!

The short answer is YAML isn't available in Opal Ruby inside web browsers on the client-side, and Ruby Marshal raises errors by design whenever your objects reference unserializable objects like Proc.

The long answer is I needed a library that was written in Pure Ruby to ensure that it worked the same exact way in Opal, JRuby, and standard MRI Ruby so that I could use in network calls made by Glimmer applications, whether Glimmer DSL for SWT (JRuby), Glimmer DSL for Opal (Opal), or Glimmer DSL for Tk (MRI). Also, it had to silently ignore unserializable objects. Last but not least, developers are busy solving business domain problems, so the library has to require zero configuration. In other words, I don't want to fuss around with as_json methods or serializer configuration classes to manually specify attributes for JSON serialization. I just want serialization to work by passing objects in, period.

YASL took me exactly one week to write test-first till I reached the initial release. Not bad, right?

Don't get me wrong! When working strictly in standard MRI Ruby, I just use YAML. However, when building cross-Ruby apps in Glimmer that need to work in both desktop and web, YASL is the way to go!

Here is a quick intro taken straight out of the README. Enjoy!

No comments: