On 02/14/2011 09:59 AM, Sven Van Caekenberghe wrote:
On 14 Feb 2011, at 00:18, Göran Krampe wrote:
Ok, sooo... not sure if I made the Pros/Cons clear enough to be understood here. Anyway,
in my quest earlier to build Deltas and Deltastreams I ended up investigating
"formats" and then I created Tirade:
http://goran.krampe.se/blog/Squeak/Tirade.rdoc
http://goran.krampe.se/blog/Squeak/Tirade2.rdoc
http://goran.krampe.se/blog/Squeak/Tirade3.rdoc
(sorry for lack of nice CSS there)
NOTE: Since those articles I have simplified it a bit - I scratched the complicated
"stack" logic around figuring out the receiver.
Anyway, Tirade is in short a very long cascade that only allows arguments in literal
forms. So basically Tirade doesn't serialize objects - it serializes a *sequence of
messages*. And then when we "deserialize it" we replay those messages onto a
receiver.
Thus, in syntax it is very Squeakish - it even uses the same number parser etc
as the Compiler does. But it is a very restricted subset of Smalltalk which
makes it fast and secure.
So, given the Pros/Cons above, let's see how Tirade would fit:
* Easy to read and edit: yes, it looks like Smalltalk, but without a receiver
to the left.
* Easy to store in a method: yes, quite simple, the easiest way may be to save it as
"Smalltalk" like this:
tiradeOn: recorder
"Create Tirade by sending messages to a Tirade recorder."
recorder message1; message2; message3
In that way you can still use senders/implementors etc of the message selectors.
* Easy to store outside of the language: yes, trivial, and fast to write and
read
* Very resilient against framework/library changes if we use a declarative
style.
Tirade looks cool, very nice idea, simple and powerful. Nice name too.
Some questions:
- don't you need a more formal (BNF) spec (I like the drawings on the
http://json.org/ site) ?
Sure! :) But it was still evolving, although slowly, when I got
distracted by other things. So I hadn't come to the "let's put it in BNF
stone"-phase.
- there does not seem to be a way to deal with non-ascii strings like 'Göran',
shouldn't there be something like JSON escapes ?
Ehm... my memory is weak here - I actually don't know what the code does
- but I agree with people saying UTF8.
- should there not be some kind of convention to note the expected reader (in a
comment as meta data maybe)
Sure, might be nice! :) Or one could say that in order to work nicely
with "known readers" the first message could be:
reader: #CoolFormatReader.
...there are endless ways to do that.
- has this since 2009 been used anywhere ?
I am using it in Deltastreams (although that project is not usable yet
and has been dormant) and a collegue actually used it in one of his
little projects - other than that I have no idea.
- how about inter Smalltalk interoperability ?
Sure, one might investigate that. If so then I think that number parsing
is the most brittle part. The code is very small and I wrote it using
vanilla Squeak I think so porting would probably be quite simple.
Sven
regards, Göran
PS. You could use Tirade for simple inter-Smalltalk communication too -
since over a Socket it would constitute an RPC mechanism.