This repository has been archived on 2017-04-03. You can view files and clone it, but cannot push or open issues/pull-requests.
blog_post_tests/20110531124609.blog

13 lines
2.1 KiB
Plaintext

Configuration files and switches considered harmful
<p>Someone on the gpsd-users list asked:</p>
<blockquote><p>
I was just wondering why gpsd doesn&#8217;t have a configuration file in /etc/gpsd.conf, like most other Unix/Linux software?
</p></blockquote>
<p>Because configuration files are evil, and not to be countenanced unless they become an absolutely necessary evil. Which in gpsd&#8217;s case is not yet, and I sincerely hope not <em>ever</em>.</p>
<p><span id="more-3290"></span></p>
<p>Yes, I know this sounds like heresy coming from a Unix programmer. But the trouble with configuration files is that they too easily become an excuse for not doing the right thing. (The same is true of command-line switches; all of what I have to say here against config files applies to switches as well, which is why gpsd has so few of them.)</p>
<p>Can&#8217;t decide whether that new feature is a good idea or not? Create an option. Can&#8217;t settle a design issue? Create an option. Can&#8217;t be bothered to figure out how to autoconfigure your software properly? Create an option. Want to double your software&#8217;s test complexity? Create an option.</p>
<p>Lots of options and elaborate config files are sometimes necessary for Swiss-Army-knife-like system utilities; I implemented a boatload of them in fetchmail because I had to. But doing that made me unhappy and I junked a lot of delivery options when I figured out that forwarding fetched mail to SMTP was the right thing.</p>
<p>It&#8217;s better to design so you don&#8217;t <em>need</em> a configuration file. One of gpsd&#8217;s goals is to be zero-configuration; when it&#8217;s installed properly, you plug in a USB GPS and it just works. Nothing to tweak, nothing to configure, nothing you have to mess with. </p>
<p>While gpsd sometimes departs from this ideal, we treat those departures as bugs to be actually fixed rather than kluged around with an option. So the right question to ask youself is not &#8220;how might an option fix this?&#8221; but &#8220;how can we teach the program to figure out the right thing itself?&#8221;.</p>