# YAML vs. Marshal

**URL:** <https://rubytalk.org/t/yaml-vs-marshal/11342>\
**Category:** ruby-talk\
**Created:** [3 May 2004 21:13 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342 "2004-05-03T21:13:58Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dejaspam](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@Dejaspam](https://rubytalk.org/u/Dejaspam)\
**Post date:** [3 May 2004 21:13 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/1 "2004-05-03T21:13:58Z")

</div>

Is there any reason to use Marshal instead of YAML? Is there anything  
Marshal can do that YAML cannot?

---

<div class="post-metadata">

**Author:** ![Joel\_VanderWerf1](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@Joel\_VanderWerf1](https://rubytalk.org/u/Joel_VanderWerf1)\
**Post date:** [3 May 2004 21:28 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/2 "2004-05-03T21:28:35Z")

</div>

Bill Atkins wrote:

> Is there any reason to use Marshal instead of YAML? Is there anything  
> Marshal can do that YAML cannot?

Here’s one:

> Marshal.dump [String, Integer]

# =\>“\004\010[\ac\vStringc\fInteger”

> YAML.dump [String, Integer]  
> ArgumentError: can’t dump anonymous class Class

However, you can get around that–see [ruby-talk:95432].

Marshal is, in my experience, a bit faster.

---

<div class="post-metadata">

**Author:** ![Kirk\_Haines](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@Kirk\_Haines](https://rubytalk.org/u/Kirk_Haines)\
**Post date:** [3 May 2004 21:29 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/3 "2004-05-03T21:29:07Z")

</div>

Marshal is a lot fater than YAML.

Kirk Haines

> **···**
>
> On Tue, 4 May 2004, Bill Atkins wrote:
> 
> > Is there any reason to use Marshal instead of YAML? Is there anything  
> > Marshal can do that YAML cannot?

---

<div class="post-metadata">

**Author:** ![why\_the\_lucky\_stiff1](https://avatars.discourse-cdn.com/v4/letter/w/898d66/32.png) [@why\_the\_lucky\_stiff1](https://rubytalk.org/u/why_the_lucky_stiff1)\
**Post date:** [4 May 2004 16:28 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/4 "2004-05-04T16:28:24Z")

</div>

Joel VanderWerf wrote:

> Marshal is, in my experience, a bit faster.

For small documents, my benchmarks have Marshal running at 3x the speed  
of Ruby’s YAML parser. For larger documents, this often decreases to  
2x. For output, I’m sure YAML is quite a bit slower than Marshal. I  
haven’t benched it, though.

I’m also working on the YAML bytecode parser, which should run as  
quickly as Marshal does. Yep.

Mostly you want to use YAML in place of Marshal if:

- You need portable serialization.
- You will be hand-editing your objects.
- You need to read saved objects (for debugging).

YAML bytecode will only really solve the first of those.

\_why

---

<div class="post-metadata">

**Author:** ![HAL\_9000](https://avatars.discourse-cdn.com/v4/letter/h/90ced4/32.png) [@HAL\_9000](https://rubytalk.org/u/HAL_9000)\
**Post date:** [4 May 2004 16:35 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/5 "2004-05-04T16:35:34Z")

</div>

why the lucky stiff wrote:

> Mostly you want to use YAML in place of Marshal if:
> 
> - You need portable serialization.
> - You will be hand-editing your objects.
> - You need to read saved objects (for debugging).
> 
> YAML bytecode will only really solve the first of those.

Can you explain this to me? I sense some irony here. You’re taking a  
format which is renowned for making persistent objects readable in  
plain text, and you’re making it unreadable.

No flame intended. I like YAML, I use it all the time, and I appreciate  
all your hard work.

But YAML bytecode does sound to me a bit like a step backward.

Reminds me a bit of the early days of Java:

1. Hey, let’s make a virtual machine that’s PROCESSOR INDEPENDENT!
2. Hey, let’s make a new chip that will run this natively!

I don’t know that they ever did, though.

Hal

---

<div class="post-metadata">

**Author:** ![why\_the\_lucky\_stiff1](https://avatars.discourse-cdn.com/v4/letter/w/898d66/32.png) [@why\_the\_lucky\_stiff1](https://rubytalk.org/u/why_the_lucky_stiff1)\
**Post date:** [4 May 2004 17:35 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/6 "2004-05-04T17:35:08Z")

</div>

Hal Fulton wrote:

> Can you explain this to me? I sense some irony here. You’re taking a  
> format which is renowned for making persistent objects readable in  
> plain text, and you’re making it unreadable.

Well, the bytecode is sort of a sideproject and it’s one of those things  
that probably doesn’t make sense but actually fills a need. I can’t  
think of anything else really that is “one of those things,” so I’m  
proud to present a first-of-breed nonsensical necessity.

Why not provide a wire format that is more efficient than YAML and keep  
its portability? My big use case is this: I love DRb. I want it to  
work across languages. I guess you could do this with plain YAML. But  
we don’t really need YAML’s readability. And we could use the  
efficiency a bit.

It took me an afternoon to write the bytecode parser, so I don’t think  
it’s been expensive. But I want to rewrite it again, having some new  
insights, which will take another afternoon. So, I just need to decide  
if it’s worth an afternoon. Keep in mind that summer afternoons are  
prettier than any other kind of afternoon. Perhaps I will wait till  
October.

> No flame intended. I like YAML, I use it all the time, and I appreciate  
> all your hard work.

Didn’t you just say “No flame intended” in another thread? Seriously.  
It’s starting to sound really insincere, Hal.

\_why

---

<div class="post-metadata">

**Author:** ![Hugh\_Sasse](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@Hugh\_Sasse](https://rubytalk.org/u/Hugh_Sasse)\
**Post date:** [5 May 2004 09:50 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/7 "2004-05-05T09:50:21Z")

</div>

> Reminds me a bit of the early days of Java:
> 
> 1. Hey, let’s make a virtual machine that’s PROCESSOR INDEPENDENT!
> 2. Hey, let’s make a new chip that will run this natively!
> 
> I don’t know that they ever did, though.

> **[Hardware | Oracle](https://www.oracle.com/it-infrastructure/)**
>
> Lower total cost of ownership with powerful on-premises Oracle hardware solutions that include unique Oracle Database optimizations and Oracle Cloud Infrastructure integrations.

There seems to be a [www.picojava.com](http://www.picojava.com) as well.

> Hal

```
    Hugh

```

> **···**
>
> On Wed, 5 May 2004, Hal Fulton wrote:

---

<div class="post-metadata">

**Author:** ![Dick\_Davies1](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@Dick\_Davies1](https://rubytalk.org/u/Dick_Davies1)\
**Post date:** [5 May 2004 14:01 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/8 "2004-05-05T14:01:30Z")

</div>

- Hal Fulton [hal9000@hypermetrics.com](mailto:hal9000@hypermetrics.com) [0535 17:35]:

> Reminds me a bit of the early days of Java:
> 
> 1. Hey, let’s make a virtual machine that’s PROCESSOR INDEPENDENT!
> 2. Hey, let’s make a new chip that will run this natively!
> 
> I don’t know that they ever did, though.

Oh yeah, they built the chip. By the time it came out the API  
had changed, and the hardware had about the power of a 90-Mhz cpu  
right as 300Mhz hit commodity prices.

Silly billies…

> **···**
>
> –  
> Rasputin :: Jack of All Trades - Master of Nuns

---

<div class="post-metadata">

**Author:** ![HAL\_9000](https://avatars.discourse-cdn.com/v4/letter/h/90ced4/32.png) [@HAL\_9000](https://rubytalk.org/u/HAL_9000)\
**Post date:** [4 May 2004 17:40 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/9 "2004-05-04T17:40:25Z")

</div>

why the lucky stiff wrote:

> Why not provide a wire format that is more efficient than YAML and keep  
> its portability? My big use case is this: I love DRb. I want it to  
> work across languages. I guess you could do this with plain YAML. But  
> we don’t really need YAML’s readability. And we could use the  
> efficiency a bit.

OK, I’ll buy that.

> Didn’t you just say “No flame intended” in another thread? Seriously.  
> It’s starting to sound really insincere, Hal.

Haha, I noticed that after it was too late.

Maybe I should introduce a new Usenet abbreviation, NFI.

You know, \_why, sometimes your code isn’t as high-quality as it  
usually is.

Hal

---

<div class="post-metadata">

**Author:** ![Gavin\_Sinclair](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Gavin\_Sinclair](https://rubytalk.org/u/Gavin_Sinclair)\
**Post date:** [4 May 2004 21:43 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/10 "2004-05-04T21:43:56Z")

</div>

Doesn’t DRb use Marshal, and isn’t Marshal faster than YAML? Won’t  
YAML bytecode be no faster than Marshal? Isn’t Marshal suitably  
cross-platform?

No flame intended, but you got a lot of questions to answer 🙂

Gavin

> **···**
>
> On Wednesday, May 5, 2004, 3:35:08 AM, why wrote:
> 
> > Why not provide a wire format that is more efficient than YAML and keep  
> > its portability? My big use case is this: I love DRb. I want it to  
> > work across languages. I guess you could do this with plain YAML. But  
> > we don’t really need YAML’s readability. And we could use the  
> > efficiency a bit.

---

<div class="post-metadata">

**Author:** ![NAKAMURA\_Hiroshi1](https://avatars.discourse-cdn.com/v4/letter/n/fbc32d/32.png) [@NAKAMURA\_Hiroshi1](https://rubytalk.org/u/NAKAMURA_Hiroshi1)\
**Post date:** [5 May 2004 05:37 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/11 "2004-05-05T05:37:29Z")

</div>

Hi,

I’m interested in this (YAML byte code) project. I have questions, but  
feel free to ignore these questions, because I may be expecting too much.

why the lucky stiff wrote:

> My big use case is this: I love DRb. I want it to  
> work across languages.

Does ‘DRb’ here mean ‘RPC’? ‘ORPC’? Or do you expect some DRb specific  
paradigm with your YAML byte code, such as object by reference,  
distributed garbage collection and distributed anonymous code block  
handling? Or more such as message boxing or object activation?

Does the goal of YAML byte code (+ message invoking?) includes these  
features across languages?

Currently, Ruby’s SOAP marshalling implementation passes all existing  
unit test for Ruby’s marshaler (I hope YAML do, too [ruby-talk:95352]).  
So I can use SOAP as wire format of DRb environment as you can see the  
figure in [http://rrr.jin.gr.jp/rwiki?cmd=view;name=SOAP-DRb+router](http://rrr.jin.gr.jp/rwiki?cmd=view;name=SOAP-DRb+router)  
(written in 840 days ago). But it does not mean “cross language DRb  
environment” though it uses SOAP serialization format which is language  
independent. Cross language object environment has some common paradigm  
as I listed above.

I wrote too much '?'s. I summarize my question. What is the goal of  
YAML byte code project?

Regards,  
// NaHi

---

<div class="post-metadata">

**Author:** ![why\_the\_lucky\_stiff1](https://avatars.discourse-cdn.com/v4/letter/w/898d66/32.png) [@why\_the\_lucky\_stiff1](https://rubytalk.org/u/why_the_lucky_stiff1)\
**Post date:** [4 May 2004 18:14 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/12 "2004-05-04T18:14:52Z")

</div>

Hal Fulton wrote:

> You know, \_why, sometimes your code isn’t as high-quality as it  
> usually is.

I swear: the only quality to my code is that which Ruby inherently brings.

\_why

---

<div class="post-metadata">

**Author:** ![Joel\_VanderWerf1](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@Joel\_VanderWerf1](https://rubytalk.org/u/Joel_VanderWerf1)\
**Post date:** [4 May 2004 21:47 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/13 "2004-05-04T21:47:46Z")

</div>

Gavin Sinclair wrote:

> **···**
>
> > On Wednesday, May 5, 2004, 3:35:08 AM, why wrote:
> > 
> > > Why not provide a wire format that is more efficient than YAML and keep  
> > > its portability? My big use case is this: I love DRb. I want it to  
> > > work across languages. I guess you could do this with plain YAML. But  
> > > we don’t really need YAML’s readability. And we could use the  
> > > efficiency a bit.
> > 
> > Doesn’t DRb use Marshal, and isn’t Marshal faster than YAML? Won’t  
> > YAML bytecode be no faster than Marshal? Isn’t Marshal suitably  
> > cross-platform?
> > 
> > No flame intended, but you got a lot of questions to answer 🙂
> 
> I guess \_why’s suggestion is to make it possible for the drb protocol to  
> talk between languages, if someone wanted to develop DRb for Python or  
> Perl. But that does raise a lot of questions…

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@Ara.T.Howard](https://rubytalk.org/u/Ara.T.Howard)\
**Post date:** [4 May 2004 22:13 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/14 "2004-05-04T22:13:59Z")

</div>

wouldn’t that be soap? 😉 i hate xml, but this would be wheel reinvention  
for sure…

-a

> **···**
>
> On Wed, 5 May 2004, Joel VanderWerf wrote:
> 
> > Gavin Sinclair wrote:
> > 
> > > On Wednesday, May 5, 2004, 3:35:08 AM, why wrote:
> > > 
> > > > Why not provide a wire format that is more efficient than YAML and keep  
> > > > its portability? My big use case is this: I love DRb. I want it to  
> > > > work across languages. I guess you could do this with plain YAML. But  
> > > > we don’t really need YAML’s readability. And we could use the  
> > > > efficiency a bit.
> > > 
> > > Doesn’t DRb use Marshal, and isn’t Marshal faster than YAML? Won’t  
> > > YAML bytecode be no faster than Marshal? Isn’t Marshal suitably  
> > > cross-platform?
> > > 
> > > No flame intended, but you got a lot of questions to answer 🙂
> > 
> > I guess \_why’s suggestion is to make it possible for the drb protocol to  
> > talk between languages, if someone wanted to develop DRb for Python or  
> > Perl. But that does raise a lot of questions…
> 
> # –
> 
> > EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov  
> > PHONE :: 303.497.6469  
> > ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328  
> > URL :: [Solar-Terrestrial Physics Data | NCEI](http://www.ngdc.noaa.gov/stp/)  
> > TRY :: for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done  
> > ===============================================================================

---

<div class="post-metadata">

**Author:** ![why\_the\_lucky\_stiff1](https://avatars.discourse-cdn.com/v4/letter/w/898d66/32.png) [@why\_the\_lucky\_stiff1](https://rubytalk.org/u/why_the_lucky_stiff1)\
**Post date:** [4 May 2004 22:21 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/15 "2004-05-04T22:21:36Z")

</div>

Ara.T.Howard wrote:

> > I guess \_why’s suggestion is to make it possible for the drb protocol to
> > 
> > talk between languages, if someone wanted to develop DRb for Python or  
> > Perl. But that does raise a lot of questions…
> 
> wouldn’t that be soap? 😉 i hate xml, but this would be wheel reinvention  
> for sure…

Reinvention? YAML is already a serialization language. All we’re  
talking about is providing a bytecode to allow efficiency where  
readability isn’t needed. It’s no different from Rite in that regard.  
We don’t need to tax the parser all the time.

You could use the same useful YAML APIs but have Marshal’s tightness. I  
don’t know about you, but I’m convinced!

\_why

> **···**
>
> > On Wed, 5 May 2004, Joel VanderWerf wrote:

---

<div class="post-metadata">

**Author:** ![Jamis\_Buck4](https://avatars.discourse-cdn.com/v4/letter/j/54ee81/32.png) [@Jamis\_Buck4](https://rubytalk.org/u/Jamis_Buck4)\
**Post date:** [4 May 2004 22:54 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/16 "2004-05-04T22:54:40Z")

</div>

why the lucky stiff wrote:

> Reinvention? YAML is already a serialization language. All we’re  
> talking about is providing a bytecode to allow efficiency where  
> readability isn’t needed. It’s no different from Rite in that regard.  
> We don’t need to tax the parser all the time.
> 
> You could use the same useful YAML APIs but have Marshal’s tightness. I  
> don’t know about you, but I’m convinced!

I’ll speak up in \_why’s defense here, and say I’m convinced, too.  
Besides: where in Ruby is there only a single way to do anything? It  
certainly can’t hurt to have YAML bytecode, and once it is available,  
people will find ways to use it. Possibly even ways that \_why didn’t  
foresee.

I say, go for it!

> **···**
>
> –  
> Jamis Buck  
> jgb3@email.byu.edu  
> [http://www.jamisbuck.org/jamis](http://www.jamisbuck.org/jamis)
> 
> ruby -h | ruby -e  
> ‘a=;readlines.join.scan(/-(.)[e|Kk(\S\*)|le.l(…)e|#!(\S\*)/) {|r| a \<\<  
> r.compact.first };puts “\n\>#{a.join(%q/ /)}\<\n\n”’

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@Ara.T.Howard](https://rubytalk.org/u/Ara.T.Howard)\
**Post date:** [4 May 2004 23:03 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/17 "2004-05-04T23:03:59Z")

</div>

don’t get me wrong, i’m running four peices of code that use yaml heavily as  
we speak…

by reinvention i meant the ‘object access protocol’ bit. i mean, soap is a  
lot more than just serialization, it’s **what** you are serializing (an object  
request) that has had much work done… but i guess if you leveraged drb…  
then who knows…

my latest yaml project is an nfs accessed on disk priority queue that i’m  
using to distribute jobs to consumers located on 36 machines. the cool thing  
about it is that grep and vi work to modifiy it - too cool… so - i’m  
definitely a believer…

-a

> **···**
>
> On Wed, 5 May 2004, why the lucky stiff wrote:
> 
> > Ara.T.Howard wrote:
> > 
> > > On Wed, 5 May 2004, Joel VanderWerf wrote:
> > > 
> > > > I guess \_why’s suggestion is to make it possible for the drb protocol to
> > > > 
> > > > talk between languages, if someone wanted to develop DRb for Python or  
> > > > Perl. But that does raise a lot of questions…
> > > 
> > > wouldn’t that be soap? 😉 i hate xml, but this would be wheel reinvention  
> > > for sure…
> > 
> > Reinvention? YAML is already a serialization language. All we’re  
> > talking about is providing a bytecode to allow efficiency where  
> > readability isn’t needed. It’s no different from Rite in that regard.  
> > We don’t need to tax the parser all the time.
> > 
> > You could use the same useful YAML APIs but have Marshal’s tightness. I  
> > don’t know about you, but I’m convinced!
> > 
> > \_why
> 
> # –
> 
> > EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov  
> > PHONE :: 303.497.6469  
> > ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328  
> > URL :: [Solar-Terrestrial Physics Data | NCEI](http://www.ngdc.noaa.gov/stp/)  
> > TRY :: for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done  
> > ===============================================================================

---

<div class="post-metadata">

**Author:** ![Kevin\_McConnell1](https://avatars.discourse-cdn.com/v4/letter/k/bb73d2/32.png) [@Kevin\_McConnell1](https://rubytalk.org/u/Kevin_McConnell1)\
**Post date:** [5 May 2004 03:38 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/18 "2004-05-05T03:38:59Z")

</div>

> > wouldn’t that be soap? 😉 i hate xml, but this would be wheel reinvention  
> > for sure…
> 
> Reinvention? YAML is already a serialization language. All we’re  
> talking about is providing a bytecode to allow efficiency where  
> readability isn’t needed.

I certainly think it would be cool to have both formats – both  
functionally equivalent, but one being faster and the other being a  
lot handier for debugging.

Maybe it’s not so much reinventing the wheel, as constructing a  
unicycle… 🙂

Kevin

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@Ara.T.Howard](https://rubytalk.org/u/Ara.T.Howard)\
**Post date:** [4 May 2004 23:13 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/19 "2004-05-04T23:13:59Z")

</div>

i stand corrected. 😉

-a

> **···**
>
> On Wed, 5 May 2004, Jamis Buck wrote:
> 
> > I say, go for it!
> 
> # –
> 
> > EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov  
> > PHONE :: 303.497.6469  
> > ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328  
> > URL :: [Solar-Terrestrial Physics Data | NCEI](http://www.ngdc.noaa.gov/stp/)  
> > TRY :: for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done  
> > ===============================================================================

---

<div class="post-metadata">

**Author:** ![why\_the\_lucky\_stiff1](https://avatars.discourse-cdn.com/v4/letter/w/898d66/32.png) [@why\_the\_lucky\_stiff1](https://rubytalk.org/u/why_the_lucky_stiff1)\
**Post date:** [4 May 2004 23:46 UTC](https://rubytalk.org/t/yaml-vs-marshal/11342/20 "2004-05-04T23:46:57Z")

</div>

Ara.T.Howard wrote:

> by reinvention i meant the ‘object access protocol’ bit. i mean, soap is a  
> lot more than just serialization, it’s **what** you are serializing (an object  
> request) that has had much work done… but i guess if you leveraged drb…  
> then who knows…

Right, yeah. Method dispatch stuff would have to be worked out. That  
would be a bit of reinvention.

> my latest yaml project is an nfs accessed on disk priority queue that i’m  
> using to distribute jobs to consumers located on 36 machines. the cool thing  
> about it is that grep and vi work to modifiy it - too cool… so - i’m  
> definitely a believer…

Your faith is unimpeachable, Ara. And give my best to your 36 machines.

\_why

[Next page](https://rubytalk.org/t/yaml-vs-marshal/11342.md?page=2)
