Friday, August 3rd, 2007

Really Simple Data: YAYAML

Category: JavaScript, Library

It was a pleasure to meet Dan Yoder last week, and right after the conference he pings me with an idea he cooked up called Really Simple Data.

RSD is another data format. Yup, you got it, yet another yaml :) It tries to achive:

  • The quote-free simplicity of CSS.
  • The flexibility of YAML.
  • The meta-data friendliness of XML.
  • The lean grammar of JSON.

Examples

RSD as an object:

[json]
person {
name { last: Yoder, first: Dan }
title: Web Applications Architect
degrees {
degree {
school: University Of Michigan
certificate: [ BS, Computer Science ]
year: 1989
}
}
born: date( 8/29/1967 )
objective: —
I am looking for a challenging position with an
innovative firm doing cutting edge Web apps in
beautiful Santa Monica, CA. —
email: ‘dan@zeraweb.com’
}
[/json]

CSS w/ Behaviours and nesting:

[json]
div.blog div.entry {
font { weight: bold, size: 10pt }
click {
binding: url( /blogs/my-blog )
action: get, pre-load: true
}
hover {
action: hint
tip: Click on any entry to view more detail.
}
}
[/json]

Dan has a working JavaScript parser and a Ruby version is forthcoming.

Posted by Dion Almaer at 7:07 am
13 Comments

+++--
3.1 rating from 16 votes

13 Comments »

Comments feed TrackBack URI

It looks very much like Groovy and Grails builders. The example could be rewritten slightly differently:


person {
name(last: Yoder, first: Dan)
title "Web Applications Architect"
degrees {
degree {
school "University Of Michigan"
certificate "BS", "Computer Science"
year 1989
}
}
born date( "8/29/1967" )
objective """
I am looking for a challenging position with an
innovative firm doing cutting edge Web apps in
beautiful Santa Monica, CA. """
email 'dan@zeraweb.com'
}

Comment by Guillaume Laforge — August 3, 2007

That date format is obviously a bad idea. Can we finally learn from the mistake that is date strings and move on (or back) to UNIX timestamps? :)

Comment by Tim Cooijmans — August 3, 2007

I can’t see a good example of metadata with this format.

Comment by Calvin Spealman — August 3, 2007

Guillaume: It has been awhile since I looked at Groovy, but I will revisit builders. One thing that I didn’t make clear in the examples is that the keys can be arbitrary strings, including spaces. So some kind of delimiter is needed (proposed as ‘:’).

Tim: Any date format can be used, including timestamps, and in many cases, that is what would make sense. The destination language’s date parsing facilities would be used to turn it into a Date object.

Comment by Dan Yoder — August 3, 2007

I don’t see the advantage of this format over plain JSON. JSON is ‘limited’ with string delimeters, won’t contain dangerous characters, doesn’t need/mind newlines, and already has similar structure to CSS and XML to make it easy, safe and portable. This RSD format is just going to add another level of abstraction, as keys that are ‘arbitrary strings’ will not match JS, CSS, nor X(HT)ML tags… It is already easy to recognize floats, integers, etc. *because* of string delimeters, and although RSD will parse dates and urls on its own, the code will have to be expecting dates and urls anyway due to the arbitrary keys.

Once the click…binding…action is introduced, this looks just like writing jQuery’s $(‘div.blog,div.entry’).css({fontWeight: bold, fontSize: 10pt}).click(action).hover($(this).jTip(tip))….. etc. I don’t see how someone who has a great enough understanding of UI design, CSS, and binding events would pick RSD over existing methods. Plus, RSD is *harder* to parse than CSS, XML, JSON because of its loose grammar. Why further abstract the design?

Comment by Charles — August 3, 2007

Hi Dan Yoder, are you?
Cheers!
I do something same like,
http://www.jroller.com/qinxianscript/entry/wa_new_object_notation_on

Could we make some share with it?
ha, Happy thing!
Cheers!

Comment by Qinxian — August 3, 2007

whats wrong with s-expressions again

Comment by ffff — August 3, 2007

Calvin: The enhanced CSS example is a meta-data example.

Charles: The more syntax there is, the more error-prone and difficult to read. This tends to scare off non-programmers, which I suspect is one reason both CSS and YAML don’t require quoted strings.

It is quite easy for me to imagine a good UI designer with CSS skills and the ability to follow an API finding it easier to work with something like RSD than using JSON or writing anonymous functions in jQuery.

And, yes, RSD is slightly more complicated to parse than JSON or CSS, but much less so than YAML. Fortunately, our Parser library makes it easy! :-)

4fs: s-expressions rule. But I’m tired of typing quotes. Funny, this same topic came up in my blog comments. Pete, is that you? :-)

Comment by Dan Yoder — August 3, 2007

Qinxian: I’m fine, how are you? :-) I took a look at your site and would be happy to share ideas and code. I will be posting a grammar soon, so feel free to post comments on my blog or email with your suggestions.

Comment by Dan Yoder — August 3, 2007

any sufficiently complicated JSON alternative contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of N3..

Comment by carmen — August 3, 2007

Hi Dan,I tried antlr make a problemed grammar:)
http://www.jroller.com/qinxianscript/entry/on_grammar_m1
Because I cannot email you, nor comment your blog, so place message in here:)
I have some question in it:
1, I hope do context-related grammar, seem that is a trouble.
2,about array, I hope can give some parser option for user who can make choice if use [] pair.
3, string quote free, and if before after have whitespaces, use “” pair. so there should have escape chars.
4,I agree with you, name:value pair can be kinds: name:string, name{object}, name:array,array,array
5,there some newline placeholders to handle.
See you next!
Regards
qinxian

Comment by Qinxian — August 4, 2007

I, too, am tired of typing quotes. There’s a shift key involved and everything. It’s almost as exhausting as running across a bug and trying to figure out what the original coder was thinking because his code is five levels abstracted from its actual meaning.

Comment by Trav — August 4, 2007

And who needs the wheel anyway? I say the octagon is an excellent substitute.

Comment by Ivan — August 5, 2007

Leave a comment

You must be logged in to post a comment.