dotgnu-visionaries
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Visionaries] Cross language serialization


From: Peter Minten
Subject: [Visionaries] Cross language serialization
Date: Sat, 21 Jun 2003 18:51:38 +0200
User-agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.4) Gecko/20030529

Hi folks,

YAML (www.yaml.org) is a quite good language for serialization. While looking in to that it occured to me that it should be possible to use YAML to serialize objects between languages.

Most languages (Perl, Python, Ruby, C#, Java, DG-Scheme) are pretty much the same in their data types. The scripting languages tend to have more flexible integers while the compiled ones usually stick to the C model but that's something that can be worked around.

YAML supports integers, floating points and strings natively but doesn't place any limit on the size of them. That means that a C# implementation of YAML must determine the correct data type.

YAML also supports arrays and hashes. It's reasonable to expect that all languages used in DotGNU support these too. So there's no problem here too.

Finally YAML allows you to create extra data types, for example a PerlRegex. While I'm not very keen on having too much extra data types this could solve potential problems.

Now to the serialization protocol. Here's some code in C# (I hope it's correct 
:-):

public class Foo
{
  public int bar;
  public Foo baz;
}
fred = new Foo();
fred.bar = 15;
fred.baz = new Foo();
fred.baz.bar = 10;

here's the YAML:
---
  !dotgnu/object:Foo
    bar: 15
    baz: !dotgnu/object:Foo
      bar: 10

and in Ruby a usage:
fred.bar + fred.baz.bar
=> 25

Get the picture?

To make the serialization work all non-common things can't be serialized using the language neutral serialization. This means no reflective stuff (classes), no functions (lambda), no intercalls, etc.

Greetings,

Peter




reply via email to

[Prev in Thread] Current Thread [Next in Thread]