Tuesday, January 6, 2009

MGraph as a data rep

Today we have lots of XML on the wire.

There's also lots of JSON.

I want to see MGraph get there as well. So, over the holidays I wrote GraphReader and GraphWriter. Think of these in the same equivalence class as TextReader/Writer or XmlReader/Writer.

Now - you may ask yourself - what's the difference between this and what the lexer/parser does in the M toochain to process MGraphs? Conceptually, there's no difference. But, if you really want to use MGraph on the wire, then you need something that is highly tuned, capable of streaming, and supports doing other wire reps besides text.

The way to think about this is serialization format versus program text. We want both with the same textual syntax, but the usage scenarios are different.

So, I started off building the Writer. It was easy except I started down 1 path 1st, and then had to simplify. I started off by baking in our interpretation of Record and Sequence into the serializer. It was something like this:

class GraphWriter {
void WriteStartEntity();
void WriteStartSequence();
void WriteStartNode();
// ends and other basic write statements elided

But then with the help of my great colleagues, I realized that I do not want this because it bakes the interpretation into the serialized format. I actually want the interpretation to be done by the reader. Also, it makes the reader much harder to write.

So, now it's just basically WriteStartNode :) It's that simple.

I also built a serializer on top of the writer that takes an IGraphBuilder and a graph node and makes the appropriate calls to serialize.

I then started on the Reader as the inverse/deserialization process. I haven't finished this yet because my hard drive is failing. I'll provide more details later.

I have no idea if we will productive this kind of thing, but I hope so in V1.


startbigthinksmall said...

Great, really!

I could also imagine a MGraphXmlReader, that just treats successors as elements. That would make MGraph usable in alot of products rightaway :)

Pinky said...

Yep - that's my next thing to build :)

Serdar ( BlackFeel said...

sikiş izle
porno izle
porno izle
porno izle
sikiş izle
yabancı kızlarla chat