Hi, this is more OS architecture question than programming directly, but still. Why was the Windows registry created as a completely separate subsystem for storing system/application settings? In *nix OS'es there is /etc directory which is perfectly understandable, as filesystem is a natural hierarchical way for storing settings, while Microsoft decided to create a completely outside hierarchical subsystem, which seems to be a foolish investment, why didn't they just use a filesystem hierarchy?
This article discusses INI files vs registry: http://blogs.msdn.com/oldnewthing/archive/2007/11/26/6523907.aspx
For starters, it's quicker to read and write to the registry during the course of a user session.
The idea is to have all settings for all programs stored in one single place instead of having them spread all over your disk.
- Each application doesn't have to reinvent a config file format
- You can easily use the registry in kernel mode code
As mentioned in the Old New Thing article cited by Bastien:
- The system can handle concurrency issues for you
- You can ACL registry keys
I would also mention that many *nix frameworks have reinvented the registry... Like gconfd on GNOME.
- Centralized - which is useful for roaming profiles.
- Transactional - which makes it harder to smash your configuration.
- Security - You can enforce read/write with better granularity than a file (per-key/value).
Also, file system granularity: one cluster for each value is a bit to much, so you need to make a tradeoff where the file system ends and the settings file starts. That of course doesn't give you a consistent API. So why not pull all settings into a few key files, and give you a consistent API to access it? BAM - registry.
(And since MS generally considers API more importantthan format, it's no surprise the files are opaque)
[Raymond Chen voice]Remember, it was designed for computers where 4MB of RAM was plenty.[/Raymond Chen voice]
They did it, I believe, to support a separate setting for each login user. In Unix, there's a concept of home directory, while none in Windows.
It created a single point entry for the entire system's application configuration control. It would have been a nice usecase for an embedded network database (e.g. Raima used by Rational) or a text database (Bernstein's cdb).
So that when the binary registry gets corrupted, you'll just give up and go buy the newest version of windows for a fresh install.