What are the benefits of the registry in Windows?
Windows relies a lot on registry to store small pieces of information such as the IP address of the machine. Unix, and so Linux and OS-X, store everything in ordinary files.
When it comes to registry, I see several problems with it:
Accessing the information is not that easy. For instance, if the machine fails to boot and I try to solve the issue by mounting the disk on a different machine to access it from a different OS (would it be another Windows or Linux), I can access all the files with ease (with the exception of permissions and encryption), but with registry, although it's theoretically possible to read (and probably change) it, it requires additional applications.
Command-line access (in a context where the machine won't boot any longer) is impossible (unless there are apps for that too, but I'm pretty sure installing and using those apps is much more difficult than simply accessing files on disk).
Information can be located either in files or in registry, so one has to juggle two locations.
Common tools which are used when working with files (such as
findstr
, the Windows' little brother ofgrep
) are non-existent when working with registry keys.
I'm sure that if Microsoft originally implemented the registry, it was for a good reason and gave (even slight) competitive advantage to Windows over other operating systems of that time.
I thought about performance and space constraints, particularly important at the times Windows was born, but I can't see how storing something in registry improves performance or reduces the space used (storing DWORD as an actual DWORD in registry versus storing its string representation in files will save space, but would that matter that much, even in 1985?
Security-wise, it looks like there is no difference either. I'm not sure if this was the case in 1985, but today's file-based permissions look as—if not more—powerful as the ones implemented for registry keys.
Organization is similar as well: a tree-based structure, with no indexing/searching capabilities (while later versions of Windows implement indexing on files).
So what are or were originally the benefits of registry, compared to storing everything in files?
Before Microsoft started to use registry, they had INI files (text files). They found very difficult to develop a good platform using only INI files because:
- It isn't easy to support Unicode.
It's a text file, so the permissions are set at the file level, not at the key level. Whoever have access to the file have access to all parameters on it.
If two threads are trying to update an INI file simultaneously they can accidentally delete the changes made by the other one.
- A program can open an INI file in exclusive mode and lock out everybody else.
- INI files contain only strings. If you want to store binary data, you have to encode it somehow as a string.
- Parsing an INI file is slow.
- Central administration of INI files is difficult. Since they can be anywhere in the system, a network administrator can't write scripts to check application status and upgrade the outdated.
- Systems started to be multi user and keep control of the settings of every user started to be overwhelming. It meant sometimes separated INI files for each user.
Those are the main points that influenced Microsot to look for a new solution, and they came with the registry. The registry is a database, so it resolves the previous problems, but created new:
- It's a single point of failure.
- It's binary. In case of damage is very difficult to repair it with your bare hands.
- Applications that put their settings on registry are less portable.
- Complex navigation.
Credit to significant source: http://blogs.msdn.com/b/oldnewthing/archive/2007/11/26/6523907.aspx