|
Boost : |
Subject: Re: [boost] Environment Variables Library?
From: Klaim - Joël Lamotte (mjklaim_at_[hidden])
Date: 2015-05-19 05:18:35
On Tue, May 19, 2015 at 8:38 AM, Andrey Semashev <andrey.semashev_at_[hidden]>
wrote:
> On Tue, May 19, 2015 at 2:27 AM, Gavin Lambert <gavinl_at_[hidden]>
> wrote:
> > On 19/05/2015 09:23, Michael Ainsworth wrote:
> >>
> >> Such a library would be reasonable small, but do you think it would
> >> be a useful addition to Boost? I'm still shaking my head that
> >> environment variables aren't better supported by standard C++.
> >
> > They're more popular in POSIX; but at least on Windows, environment
> > variables are considered old-fashioned and discouraged from use without
> > significant compelling reason.
>
> Is there a reference for such a discouragement? Sure, most
> Windows-only programs just use registry but I wouldn't say environment
> variables are discouraged from being used. For instance, most
> development software, including MSVC, use environment for
> configuration, and registry is not seen as a replacement.
>
>
I'm not sure for other devs but my personal guideline so far is:
1. Don't use the register except if you must (mostly because of
requirements from the kind of application you are making).
2. Don't use environment variables except if you must (mostly for dev tools
helping locating each other).
3. Prefer user-specific or shared directories to put config data in (config
files or databases).
The reasons for the first two are mainly to avoid issues like "pollution"
of the system with montains of unuseful data
(in particular with computers used by non-developers).
Part of the source of the issue is the lack of common good uninstallation
system,
part of it is just historical scars itching (from windows98/me era).
There is also the cross-platform code issue: if you want to provide data to
the whole system in a cross-platform way,
the environment variables is the only way to do so, because there is no
register on non-windows platforms (that I know of).
The environment variables in windows have a limited size which is small
enough to be hit very quickly if you abuse it.
For example the famous PATH can be filled with paths to tools like
git,hg,svn, python, ruby, your favorite C++ compilers and hit
the point where you can't add anything anymore. Of course, this can be
worked aroudn but it's still an annoying limitation.
Finally there is the "it's a public global state" issue, which I kind of
like public global non-const variables in a program.
It's just problematic.
I'm not a specialist of the windows specifics so any of my assumptions
might be wrong.
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk