[Catalyst] YAML vs. *
kiki at bsdro.org
Sun Jun 11 15:26:44 CEST 2006
A. Pagaltzis wrote:
> I like JSON… just not for configuration files.
> And Apache-style config has verbose elements, but they’re only
> for sections… and if you have a lot of tiny sections, you’re
> doing something wrong anyway. Look at your `httpd.conf`: lots of
> minimal-noise config directives, interspersed with an occasional
> open/close tag every 20 or 30 lines or so on average. The virtual
> host section is denser than the rest, but IMO still excellently
A basic httpd.conf is indeed so, but once you start adding modules and
setup config directives for all those SVN, DAV, mod_perl, etc. modules
it becomes pretty cluttered in my experience. The reason the basic
config is simple, is also the reason you use Catalyst instead of relying
on just mod_perl, namely at it's heart Apache is a http server for
static files, which don't need much in the way of configuration. Once
you get past that part, configuration is, like it or not, complex. In a
larger Cat app, I'd have a config section per component, that is 2 (or
3) View sections, 1 (or 2) Model sections and a shitload of controller
sections, each component having a few adjustable options, resulting
exactly in "a lot of tiny sections". What is so wrong with that and how
could I avoid it then?
> And it’s very easy to figure out what goes where just
> by looking at the format; no manual or cheat sheet necessary.
It is to me too after years of editing apache config files. The first
months of dealing with it however were hell, esp. in regard to directive
and options overriding.
The point is any sufficiently complex data structure will be confusing
no matter what format it is expressed as. Once you get familiar with it
(the data structure, not the format), you will be able to deal with the
format as well (YMMV, though).
>> Well, the "perl way" would be Data::Dumper + eval in a Safe
>> compartment. It's indent insensitive, doesn't look like XML
>> (which is my pet peeve regarding C::G) and instantly
>> readable/writable if you know Perl.
> Suffers from the same problems as JSON and YAML: hard to write
> for non-programmers. Also hard to read, like JSON.
I don't see why writing YAML would get suddenly easier if you learned a
programming language. It's a matter of conventions. If the user is
inexperienced enough to really mess up indentation (after being warned
about it), chances are he'll forget to close tags, misspell option names
or set creative option values like: "Allow from all my friends" or "Deny
from Russia" [with love] ;) too.
More information about the Catalyst