Tuesday, July 08, 2008

How Google reinvented Ruby Hash or Protocol Buffers by Google

I was laughing out aloud when I saw the following example on Protocol Buffers:

person {
name = "John Doe"
email = "jdoe@example.com"
}

How close is it to Ruby?

person => {
name => "John Doe"
email => "jdoe@example.com"
}

4 comments:

  1. I really don't see the parallel. Protocol Buffers is a binary format for data transfer, more closely related to XML than a ruby hash.

    The example you're looking at is a textual representation of the binary values... They represented it that way because it's easy to understand for any software developer.

    ReplyDelete
  2. "Protocol Buffers is a binary format for data transfer, more closely related to XML than a ruby hash."

    How is this closely related to XML? If you refer about representation then please dont drag XML into it because frankly XML syntax is horrible and both examples up there are better than XML (this is not valid ruby syntax btw......... but i leave that to the original author to find and correct the errors ;> )

    There are no tags at all. I dont understand how anyone can say this is related to XML.

    Where is the connection exactly?

    It cant be in the syntax, for the syntax would look like that:


    pointless_tag>
    some_structure_here>
    hard_to_read_there>
    person
    /hard_to_read_there> ! yes it still continues here... man i even forgot how to comment in XML... why cant i use #
    /some_structure_here>
    some_other_setting_with_attribute_here xml="stinks">
    8958279879528795252 7285925897527892589752 annoying stuff here noone understands
    /some_other_setting_with_attribute_here>


    I really dont see the connection grande.


    PS: This comment form does not allow "html"... why not simply automatically escape it? I removed all starting '<' :/

    ReplyDelete
  3. Anonymous1:27 AM

    It is related to XML in the way that both JSON, XML and the binary format of Protocol Buffers can express a datastructure.

    The JSON-like syntax refered to in this post is only describing the "messages" used for the binary format + tools can generate code directly from making it easy to read and persist that specified structure.

    Protocol buffers is not a new and amazing thing. What i does was already done in a dozen ways. But it does it fast and in a flexible manner.

    ReplyDelete
  4. Anonymous2:38 PM

    I think Markus has a fundamental misunderstanding of this subject, as does the author. I also don't know how you can think ruby was the first language to come up with the idea of hash maps, I see that format and think yes, dictionary/hash map/whatever you want to call it, but the idea is very old indeed. Also as Michael said, the points of both are completely unrelated as well

    ReplyDelete