in reply to Re: An Idiot's Guide to YAML
in thread An Idiot's Guide to YAML

Why bother? Good question! Most likely no one will use this but me. Like I said before, I had read about YAML and thought that it was cool. I wanted to learn something new. It should NOT have taken any longer to write than any other config reader. Maybe I'm the only one who ever had this problem? I did find a lot of hits when I googled for it... I think the root of the problem was a) I'm used to using other config file readers, and they all load based on filename, not file contents; b) after a quick scan of the docs, I thought I knew what I was doing; c) the error message I got led me off in the wrong direction.

I'm fairly new to perlmonks and haven't made many contributions, and thought someone might appreciate the examples.

Replies are listed 'Best First'.
Re^3: An Idiot's Guide to YAML
by perrin (Chancellor) on Jun 08, 2007 at 21:18 UTC
    Oh, don't get me wrong. Your post is very welcome, and we're glad to have you here. I was mostly interested in what your motivation was because I personally find YAML kind of pointless. It looks a lot harder to work with than most of the other config choices to me. Nevertheless, it seems to be very popular in certain camps.
      I don't understand the problems that people have with YAML. I have thousands of lines of YAML config files, all produced by hand, and the only problem I ever had was using an editor that added a tab rather than four spaces.

      The whitespace for me is a bonus, rather than a limitation - it makes it easy to read and thus easy to scan through.

      For XML, you really need an XML editor - it is good for portability because it is well supported, but for maintaining config data by hand, for me, nothing beats YAML

      clint

        Well, my original question was why you prefer a YAML config over a perl one, or something simpler like an INI file.
      Because it beats XML :)
        If it does, so what?

        Colon-delimited files are great for strictly table-natured data. CSV is great for slightly more complex table-natured data.

        Windows-style INI files are widely supported and can handle grouping. Unfortunately, many things which look a little like them are found in the wild.

        XML is verbose, but it's standard, well-supported, and can represent arbitrarily complex relationships. Perl hashes are, within Perl programs, exactly as flexible on all three counts. They do come up a bit short if one decides to port a Perl program to another language, as either the config format changes or you end up having to parse Perl hashes in another language. Parsing Perl's hash syntax shouldn't be that difficult, but chances are the other language already has an XML library or seven.

        YAML seems to be an interesting solution to not much of a problem. I applaud you for wanting to learn it because it's interesting. That's enough reason to learn something. As for useful purpose, the legibility does seem nice from the examples I've seen. A lay person might be taught how to write it without being much intimidated. However, I think the standard for dealing with lay people these days is a pretty configuration wizard. So that, I think, limits the truest audience for YAML as a configuration tool to non-programming sysadmins.
        Does it? For what? Both seem pretty clunky for config files, and XML is probably better for data exchange between different languages since it's better supported.
Re^3: An Idiot's Guide to YAML
by Anonymous Monk on Jan 23, 2010 at 00:41 UTC
    Appreciate!