Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > YAML vs. Marshal

Reply
Thread Tools

YAML vs. Marshal

 
 
Bill Atkins
Guest
Posts: n/a
 
      05-03-2004
Is there any reason to use Marshal instead of YAML? Is there anything
Marshal can do that YAML cannot?
 
Reply With Quote
 
 
 
 
Joel VanderWerf
Guest
Posts: n/a
 
      05-03-2004
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.


 
Reply With Quote
 
 
 
 
why the lucky stiff
Guest
Posts: n/a
 
      05-04-2004
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


 
Reply With Quote
 
Hal Fulton
Guest
Posts: n/a
 
      05-04-2004
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




 
Reply With Quote
 
why the lucky stiff
Guest
Posts: n/a
 
      05-04-2004
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


 
Reply With Quote
 
Hal Fulton
Guest
Posts: n/a
 
      05-04-2004
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.

<flame>You know, _why, sometimes your code isn't as high-quality as it
usually is.</flame>


Hal



 
Reply With Quote
 
why the lucky stiff
Guest
Posts: n/a
 
      05-04-2004
Hal Fulton wrote:

> <flame>You know, _why, sometimes your code isn't as high-quality as it
> usually is.</flame>


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

_why



 
Reply With Quote
 
Gavin Sinclair
Guest
Posts: n/a
 
      05-04-2004
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

Gavin



 
Reply With Quote
 
Joel VanderWerf
Guest
Posts: n/a
 
      05-04-2004
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...


 
Reply With Quote
 
Ara.T.Howard
Guest
Posts: n/a
 
      05-04-2004
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...


wouldn't that be soap? i hate xml, but this would be wheel reinvention
for sure...

-a
--
================================================== =============================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL :: http://www.ngdc.noaa.gov/stp/
| TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done
================================================== =============================

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
marshal.dumps quadratic growth and marshal.dump not allowingfile-like objects bkustel@gmail.com Python 10 06-18-2008 12:52 PM
Can you explain what this repo (yaml/Marshal) code do? anne001 Ruby 4 08-02-2006 01:57 PM
YAML.dump/YAML.load bug Paul Battley Ruby 0 08-03-2005 08:28 PM
YAML Question: Using YAML::YamlNode#transform Method to get float values? RubyQuestions Ruby 0 12-03-2003 02:15 AM
Ruby 1.8 and Marshal.load/Marshal.dump Michael Davis Ruby 0 10-10-2003 10:15 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57