# Ron 0.1.0 Released

**URL:** <https://www.ruby-forum.com/t/ron-0-1-0-released/71677>\
**Category:** Ruby\
**Created:** [October 10, 2006, 6:54pm UTC](https://www.ruby-forum.com/t/ron-0-1-0-released/71677 "2006-10-10T18:54:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pandemic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8491ac/32.png) [@pandemic](https://www.ruby-forum.com/u/pandemic)\
**Post date:** [October 10, 2006, 6:54pm UTC](https://www.ruby-forum.com/t/ron-0-1-0-released/71677/1 "2006-10-10T18:54:16Z")

</div>

Ron version 0.1.0 has been released!

[http://rubyforge.org/projects/ron](http://rubyforge.org/projects/ron)

Well, who needed another serialization format? Not me, but that’s what  
I’ve made. Ruby Object Notation (Ron) is a textual format for the  
representation of Ruby data structures. It’s somewhat like YAML, XML,  
or (most of all) JSON. However, since it is defined entirely within and  
as a subset of Ruby, it has the slick property that Ron expressions are  
legal Ruby. Thus it is very like JSON, except that it’s Ruby-centered  
instead of being JavaScript-centered.

Another way to look at Ron is as a purely declarative language for  
creating (almost) any type of Ruby data structure.

Ruby already has formats for representing a literal Array, Hash, Set,  
String, Symbol, Integer, etc. Ron simply reuses the same notations for  
those data types. The major new feature of Ron is that it provides a  
literal syntax for representing arbitrary Ruby Objects.

Say you have a class that looks like this:

class K  
attr :a  
attr :b  
end

A Ron literal that represents a K instance might look like this:

K-{:@a=\>1, :@b=\>2}

Better yet, if you provide setters as well as getters, you can leave  
off the @ signs:

class K  
attr\_accessor :a,:b  
end

K-{:a=\>1, :b=\>2}

This construct breaks encapsulation, so use the capability with  
moderation and prudence, please.

An existing object can be rendered into Ron form with a call to  
Ron.dump:

Ron.dump([1,2,3]) #=\>“[1, 2, 3]”

Ron.load is the inverse operation; it takes a Ron-formatted string and  
converts it back to a live Ruby object. (This is just an alias of  
eval.):

Ron.load(“K-{:@a=\>1, :@b=\>2}”) #=\> #\<K:@a=2, @b=2\>

bugs and limitations  
Currently, some types of ruby object cannot be dumped. In some  
cases, this is because it is impossible to (correctly) dump those  
objects. In others, it’s merely difficult. Here are the ones I  
think I should eventually be doing, mostly with ParseTree help:

(anonymous) Class and Module  
Method  
UnboundMethod  
Proc

These are very difficult, and I don’t see how to approach them  
correctly (but it would be very nice…):

Thread  
Continuation

These are more or less impossible:

File  
Dir  
Process  
IO

---

<div class="post-metadata">

**Author:** ![pandemic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8491ac/32.png) [@pandemic](https://www.ruby-forum.com/u/pandemic)\
**Post date:** [October 10, 2006, 7:18pm UTC](https://www.ruby-forum.com/t/ron-0-1-0-released/71677/2 "2006-10-10T19:18:21Z")

</div>

This looks really interesting. So you overloaded the - operator on  
classes to achieve the K - {} ?

–  
Cheers,  
zimbatm

> **[oree.ch](http://zimbatm.oree.ch)**
>
> This domain may be for sale!

---

<div class="post-metadata">

**Author:** ![pandemic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8491ac/32.png) [@pandemic](https://www.ruby-forum.com/u/pandemic)\
**Post date:** [October 10, 2006, 7:20pm UTC](https://www.ruby-forum.com/t/ron-0-1-0-released/71677/3 "2006-10-10T19:20:22Z")

</div>

Caleb C. wrote:

> Ron version 0.1.0 has been released!
> 
> [http://rubyforge.org/projects/ron](http://rubyforge.org/projects/ron)

How does it compare with amarshal?

[http://raa.ruby-lang.org/project/amarshal/](http://raa.ruby-lang.org/project/amarshal/)

At first glance, the notation

K-{:a=\>1, :b=\>2}

for a literal instance of K seems new and interesting.

Unfortunately, both the link to Ron ([http://rubyforge.org/projects/ron](http://rubyforge.org/projects/ron))  
and the download for Amarshal seem broken at the moment.

---

<div class="post-metadata">

**Author:** ![pandemic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8491ac/32.png) [@pandemic](https://www.ruby-forum.com/u/pandemic)\
**Post date:** [October 10, 2006, 7:21pm UTC](https://www.ruby-forum.com/t/ron-0-1-0-released/71677/4 "2006-10-10T19:21:25Z")

</div>

> Unfortunately, both the link to Ron ([http://rubyforge.org/projects/ron](http://rubyforge.org/projects/ron))  
> and the download for Amarshal seem broken at the moment.

RF is down @ moment it seems

Nic

---

<div class="post-metadata">

**Author:** ![pandemic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8491ac/32.png) [@pandemic](https://www.ruby-forum.com/u/pandemic)\
**Post date:** [October 10, 2006, 10:25pm UTC](https://www.ruby-forum.com/t/ron-0-1-0-released/71677/5 "2006-10-10T22:25:05Z")

</div>

On 10/10/06, Joel VanderWerf [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> How does it compare with amarshal?
> 
> [http://raa.ruby-lang.org/project/amarshal/](http://raa.ruby-lang.org/project/amarshal/)

Both are ruby-based serialization packages/languages. Amarshal  
generates imperative code, tho, whereas in Ron I’ve tried to take a  
purely declarative approach.  
For instance the amarshal representation of [1,2,3] (taken from the  
website) is:

v = []  
v[0] = Array.allocate()  
v[0] \<\< 1  
v[0] \<\< 2  
v[0] \<\< 3  
v[0]

In Ron, it’s merely: “[1,2,3]”. A more interesting example would be a  
recursive data structure, say an array containing itself. Here’s  
amarshal (extrapolating , haven’t tried this):

v = []  
v[0] = Array.allocate()  
v[0] \<\< v[0]  
v[0]

Versus Ron:

Recursive(v1\_={}, [v1\_])

Since this is essentially a declarative problem, my declarative syntax  
should be shorter and (hopefully) more readable in most cases.

> At first glance, the notation
> 
> K-{:a=\>1, :b=\>2}
> 
> for a literal instance of K seems new and interesting.

Well, thanks. As to Jonas’s question about this syntax, yes, it’s just  
a matter of defining Class#-.

---

<div class="post-metadata">

**Author:** ![pandemic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8491ac/32.png) [@pandemic](https://www.ruby-forum.com/u/pandemic)\
**Post date:** [October 18, 2006, 10:38am UTC](https://www.ruby-forum.com/t/ron-0-1-0-released/71677/6 "2006-10-18T10:38:56Z")

</div>

Jonas P. wrote:

> This looks really interesting. So you overloaded the - operator on  
> classes to achieve the K - {} ?

I agree, interesting. I would recommend howerver using something other  
then ‘-’, b/c there is talk of using that for trait-like extensions to  
class/module in future versions of Ruby. ‘\<\<’ comes to mind a possilble  
alternative.

K \<\< { a:1, b:2 }

T.

---

<div class="post-metadata">

**Author:** ![pandemic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8491ac/32.png) [@pandemic](https://www.ruby-forum.com/u/pandemic)\
**Post date:** [October 11, 2006, 3:26pm UTC](https://www.ruby-forum.com/t/ron-0-1-0-released/71677/7 "2006-10-11T15:26:03Z")

</div>

“Caleb C.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> Ron version 0.1.0 has been released!
> 
> [http://rubyforge.org/projects/ron](http://rubyforge.org/projects/ron)

“(Converting back is just eval.)”

Do you plan to write a facility for “safe” loading? (Think of Lisp’s  
READ.)
