From: Richard Kilmer Date: 2003-03-19T15:35:41+09:00 Subject: Re: XML too hard (YAML opportunity?) On Wednesday, March 19, 2003, at 01:02 AM, wrote: > >> Now you can store anything in a configuration file, >> which is liberating. That something is a boolean, string, integer, >> array, hash or whatever...YAML deals with for me. That is really >> nice. > > But what if you don't want to couple your data to a particular language > type? > > Suppose I write a YAML file to hold, say, groups of name=value pairs. > My > understanding > is that I have to decide, when designing the data file, whether each > group > is to be a > hash, or a list, or some other type. My application code will then be > expecting to deal > with data arriving as this type. Ah...the key is that you do not design the data file...this is an XML thing. The to_yaml method creates the format off your object model. > > If, later, I decide that DataTypeFoo was a poor choice and would > rather my > app > process the data as DataTypeBar, I either have to change the config > format > or have > an extra step in my app to change the data from one format to another. > No? > > For example, if I have > > some_num: 23 > > it's an integer. If later I decide that floats are better and want > change > my > code, don't the older data files have to be rewritten? Actually, what will happen is a Hash will be created with a key ("some_key") and the value(23). If you change to floats, the Hash will have the key ("some_key") and the value(23.0). It all depends on your use of these objects as to whether this will fail. But this is the same for XML too. If you have a parser that expects a certain format in the value of an attribute like: some_num="23" and then do: some_num="23.0" you have to update your parser. If you update it, will it break with old files? How long does your parser read the old format and convert to the new? > > >> Oh, and did I say that YAML files are readable? > > You did, but I'm not always seeing that when I read the YAML spec. > And XML specs are readable???...I was talking about the YAML content, not specification. The YAML library deals with the spec. I write Ruby code and let it emit and parse it.