From: Austin Ziegler Date: 2003-10-03T03:09:46+09:00 Subject: Re: xml in Ruby or no xml it's just a question On Fri, 3 Oct 2003 01:46:38 +0900, paul vudmaska wrote: "Chad Fowler" >> I can't see how hard-wiring XML as a part of Ruby's syntax >> provides much of a benefit at all. It would be fashionable >> (though not really all that fashionable these days), but barring >> that it's just more baggage to carry around. > It's interesting to me that you would wrap an xml file(rss) in an > object http://www.chadfowler.com/ruby/rss/ but belittle an > offhanded attempt to make inherent those attributes that you so > painstakingly crafted code for and call the former more baggage. > Help me understand that, Chad! I'm not Chad, but as someone who liked what Chad did and wrote a follow-up library that (mostly) conformed to his API, I can explain exactly why I did it much the same way. Basically, Chad is representing an object (a rich site summary, or a channel). That it happens to correspond to an XML format is somewhat irrelevant. There are actually four common variants on this, and two less common variants. By designing channels as objects, it becomes relatively easy to support those variant formats. >> more readable? >> blahblah2lkjsdf >> vs. >> ["blah", "blah2", "lkjsdf"] > More readable as in 'more context' not as in more succinct or > fewer letters or anything else. (ie are those an array of items in > a list or just a lot of blah?) There is no meaningful distinction between an array and a list in Ruby. In all likelihood, you might do: class List def initialize(*items) @items = *items end attr_reader :items end list = List.new(%w{blah blah2 ljksdf}) list.items # => ["blah", "blah2", "lkjsdf"] When you're writing a program, why would you want to add unnecessary semantic information (e.g., encode the list as XML) when the necessary semantic information is already present. The only time you need to worry about such semantic information is when you write it to an external format ... like XML. >> With REXML in the distribution you can already do this. Just >> requires a few more keystrokes. > Sure but fewer works for me better. Yeah, but you've traded fewer keystrokes here in favour of more keystrokes elsewhere. You may want to look around the archives for a discussion of %y{} (for YAML) and the like that happened around the 10th of September. Basically, some of the same suggestions you've made came up -- and weren't really liked. -austin -- austin ziegler * austin@halostatue.ca * Toronto, ON, Canada software designer * pragmatic programmer * 2003.10.02 * 13.58.40