Comments on: What is your favorite config file format? http://www.terminally-incoherent.com/blog/2013/08/28/what-is-your-favorite-congfig-file-format/ I will not fix your computer. Tue, 04 Aug 2020 22:34:33 +0000 hourly 1 https://wordpress.org/?v=4.7.26 By: Shrutarshi Basu http://www.terminally-incoherent.com/blog/2013/08/28/what-is-your-favorite-congfig-file-format/#comment-51456 Fri, 13 Sep 2013 02:50:17 +0000 http://www.terminally-incoherent.com/blog/?p=12123#comment-51456

I tend to prefer config file formats that are either executable, or have standard formats. When I used to a lot of Python coding, I tended to make my config files Python files. That way I could import configs just by importing the file and accessing its variables. Of course this is kinda untenable if you’re writing software to deploy, but I was doing personal projects or research projects with a small team.

Currently I’m doing a lot of work relating to graphs and I’m using the DOT language/format for representing them. That way I can serialize/import from a well-known format (and share easily) and make use of all the other tools for working with (in particular, visualizing) them.

Reply  |  Quote
]]>
By: Chris Wellons http://www.terminally-incoherent.com/blog/2013/08/28/what-is-your-favorite-congfig-file-format/#comment-49901 Thu, 29 Aug 2013 15:16:27 +0000 http://www.terminally-incoherent.com/blog/?p=12123#comment-49901

@ IceBrain:

Yup, you’re right. I was going off of the Wikipedia article which makes no mention of null. Now that I know this I think JSON a subset of YAML.

Reply  |  Quote
]]>
By: IceBrain http://www.terminally-incoherent.com/blog/2013/08/28/what-is-your-favorite-congfig-file-format/#comment-49899 Thu, 29 Aug 2013 14:55:01 +0000 http://www.terminally-incoherent.com/blog/?p=12123#comment-49899

Chris Wellons wrote:

@ Athanor:
Hmm, I thought about this and I think neither is a subset of the other … but only barely so. JSON has null, but I think it’s the only thing JSON can express that YAML cannot.

YAML does have nulls: http://yaml.org/type/null.html

Reply  |  Quote
]]>
By: mhd http://www.terminally-incoherent.com/blog/2013/08/28/what-is-your-favorite-congfig-file-format/#comment-49834 Thu, 29 Aug 2013 00:10:44 +0000 http://www.terminally-incoherent.com/blog/?p=12123#comment-49834

sendmail.cf?

But seriously, lisp/lua/tcl or a similar simple scripting language, for anything sufficiently advanced. And as some kind of variant of Greenspun’s Law, this happens pretty often. And if the syntax can’t cope, you’ll just end up with a bunch of stupid “DSLs” or people bending over backwards to write or apply preprocessors. Sometimes even m4!

Speaking of which, I did kinda like the X11 resources format, e.g. used in your .Xdefaults. And there you could actually use the C preprocessor…

Never been a big fan of YAML for some kind of reason (indenting & formatting, probably), but at least it’s more readable as config format than XML or JSON. I think TOML might be worth watching, too. Basically .ini++.

Reply  |  Quote
]]>
By: k00pa http://www.terminally-incoherent.com/blog/2013/08/28/what-is-your-favorite-congfig-file-format/#comment-49794 Wed, 28 Aug 2013 16:35:30 +0000 http://www.terminally-incoherent.com/blog/?p=12123#comment-49794

If I were creating application, I would go with XML/json/properties/yml file depending on the language in use.

As user I have always liked the .cfg files in source/gold source engine. Its just list of commands, so its possible to do little scripts right in the config file:

bind DEL "toggle net_graph 0 3"
bind PGUP "toggle_con"
cl_disablehtmlmotd 1
viewmodel_fov 70
fov_desired 90

Simple and easy to edit. Also, all the commands are the same as in the in-game console.

Reply  |  Quote
]]>
By: IceBrain http://www.terminally-incoherent.com/blog/2013/08/28/what-is-your-favorite-congfig-file-format/#comment-49791 Wed, 28 Aug 2013 16:18:05 +0000 http://www.terminally-incoherent.com/blog/?p=12123#comment-49791

That’s a difficult question, because while I can easily name some terrible formats, it’s hard to choose my favorite; it really depends on the application. For example, I like how I can configure my WM (Awesome) using a Lua script, but it’d be completely inadequate for most software. Likewise, YAML is nice for more complex formats, but usually overkill, in my opinion.

I added “resolv.conf” because I think it’s the most readable configuration format I know, and I often use it for my own scripts. It doesn’t handle very complex settings, but I wager it’s good enough for 90% of well-designed programs.

Reply  |  Quote
]]>
By: Chris Wellons http://www.terminally-incoherent.com/blog/2013/08/28/what-is-your-favorite-congfig-file-format/#comment-49790 Wed, 28 Aug 2013 16:08:13 +0000 http://www.terminally-incoherent.com/blog/?p=12123#comment-49790

@ Athanor:

Hmm, I thought about this and I think neither is a subset of the other … but only barely so. JSON has null, but I think it’s the only thing JSON can express that YAML cannot. On the other hand, YAML has references, so it’s possible to express a circular or otherwise non-hierarchical data structure in YAML but not in JSON (or most other languages).

YAML numbers are also less specified than JSON, which follows the JavaScript specification. So YAML can potentially express an arbitrary precision while JSON is limited to double-precision floating point. However, in practice YAML will probably be under similar constraints, so I’m not counting this. It’s like when we call a programming language Turing-complete even though a Turing machine is impossible to build. A practical implementation will not be Turing-complete.

Reply  |  Quote
]]>
By: Chris Wellons http://www.terminally-incoherent.com/blog/2013/08/28/what-is-your-favorite-congfig-file-format/#comment-49786 Wed, 28 Aug 2013 15:50:31 +0000 http://www.terminally-incoherent.com/blog/?p=12123#comment-49786

I’m with you that XML is the worse of text configuration files. I prefer it over a binary-only config but I don’t have to like it! The worse offender is alternating normal form XML — i.e. Apache Maven style. It’s extra overly-verbose, even for XML.

Outside of specific Java build systems, fortunately there’s only one program I use that has an XML config that I bother to version control: Openbox (rc.xml). Everything else in my dotfiles repository generally follows a simple-types “key = value” paradigm: bash, ssh, VLC, GTK, Pentadactyl, s3cmd (ini), git (ini), quilt, reportbug, Xmodmap, and lxterminal (ini). My blog is configured using YAML.

As for having a favorite format, I don’t know if I can pick an overall favorite. I see config files as prime examples of domain-specific languages. The syntax and grammar should be powerful within the context of the system it’s configuring. Emacs is configured with s-expressions and YAML would be a poor fit, but using s-expressions as Jekyll front matter would be awkward.

You can slurp it up from disc, exec() it and have a live object.

I think you mean eval(). :-)

Reply  |  Quote
]]>
By: Athanor http://www.terminally-incoherent.com/blog/2013/08/28/what-is-your-favorite-congfig-file-format/#comment-49785 Wed, 28 Aug 2013 15:47:56 +0000 http://www.terminally-incoherent.com/blog/?p=12123#comment-49785

I’m confused by the remark that “[YAML] is almost as flexible as JSON”. JSON is a subset of YAML. YAML should be more powerful and flexible.

Reply  |  Quote
]]>