4 ms·
> The Registry sounds like a great concept but it's the worst architectural decision Microsoft ever made for Windows. I think the problem wasn't so much the id
by skissane 5y ago
> The Registry sounds like a great concept but it's the worst architectural decision Microsoft ever made for Windows.
I think the problem wasn't so much the idea itself, it is just that the implementation left a lot to be desired. A better implementation of the same idea could have been much more successful.
The registry could have come with a schema, whereby each key has a class defining what values it is allowed to have. I think Microsoft may have actually had some plans to do that, because every registry key has a "class" (lpClass parameter of RegCreateKeyExW) – however, few registry keys have the class field set, and almost no software pays any attention to it – suggesting that whatever Microsoft was planning with respect to a registry schema never came to pass. There could have been a "schema hive" containing class/attribute definitions, and then any attempt to set a key/value on a schema-enforced key would be validated against the schema hive.
If keys had an enforced schema, the registry could be self-documenting – the class and attribute definitions could have a "description" value explaining what each is for. I suppose Microsoft couldn't force third parties to write meaningful descriptions, but they could have set a positive example. They could also have had a tool to auto-generate schema documentation (in HTML or RTF or whatever) from the descriptions in the registry schema.
They could have implemented something like a "foreign key" – a link type which will not let you delete the target while other keys have values pointing to it. (Not the existing REG_LINK which is much more limited; REG_SMART_LINK maybe?) This would likely need some kind of "backlink" index for fast retrieval of back-references. Maybe each key could have a "virtual attribute" which contains a list (REG_SMART_LINK_LIST) of backlinks. The schema could specify what are the allowed target types for any link attribute.
They could have a package database in the registry, and enforce that every registry key is owned by a package. Uninstalling a package automatically removes all the keys it owns.
They could have shipped with an IFS which exposes the registry as a pseudo-filesystem, which would have made it easier to manipulate. (Cygwin kind of does this with /proc/registry, and PowerShell has something similar, but it would have been better as a proper filesystem which appears like any other.)
It could even expose the registry data as JSON or XML files, dynamically generated at runtime. \\registry\HKEY_LOCAL_MACHINE\Foo\Bar\Baz\__REGDATA__.json could be a JSON file containing the values of the HKEY_LOCAL_MACHINE\Foo\Bar\Baz registry key. If you write to that file, it could parse the JSON you write and update the values appropriately.
> The unix model of plain text files for configuration is a much better idea than a Registry.
I actually don't like that model. You end up with text files littered all over the place. Automating configuration is a mess because every app has a different config syntax. It is a flawed model too, just with a different set of flaws.
> The Registry is the reason why you need an installer instead of being able to drop application files into a directory and run them.
Not really. An application can be designed to not require any registry keys, and so if all its registry keys are missing it just uses sensible defaults. Or an application can be defined to check for its required keys at every startup and create them if they are missing.
Microsoft could have defined a way for an application to embed a small registry hive in its EXE. When launching the EXE, it would check if those keys exist in the registry, and automatically load them.
In Microsoft's defence, the Registry was designed in the early 1990s (it first shipped in Windows 3.1 in 1992), and a lot of the ideas I am proposing may have had too high a performance cost for the limited machines of the early 1990s, or relied on technologies or ideas which people hadn't thought of yet.
- ogurechny 5y agolpClass most likely is a class name in COM/OLE sense. — A lot of WIN32.HLP articles from the 3.x to 9x transition era talk about “registration database”, which seems to be the original name for registry. https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/111585 https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Arch... https://docs.microsoft.com/en-us/cpp/mfc/registration?view=msvc-170 https://docs.microsoft.com/en-us/cpp/mfc/registration?view=m... > RegEdit merges the contents of the .reg text file into the registration database. — HKEY_CLASSES_ROOT is the lowest defined numerical constant, maybe it was the first one. — RegSetValue() only handles REG_SZ (string) values. — REG_SZ is the default format for new and empty registry keys. — System data about components stored in {CLSID} branches all use short REG_SZ values for everything: numbers, lists ("8,PBrush"). This is in line with handling such values in INI files, short string “verbs” and class names in ShellExecuteEx() (notice that the registry key can be used to define an object class — was it initially supposed that any registry key corresponded to some class in some hierarchy?), text messages in DDE, etc. — Finally, Wikipedia (ooh) says that the registry started as component registration database. So maybe the point of lpClass was tagging the branches that belonged to this or that class, or preventing components from messing with each other's data… I believe that some team created a nice, compact, and simple enough storage solution to hold a predictable amount of text values under first and third party CLSID keys to be used in system COM libraries operation. It was way better than some potentially enormous OLE.INI which would regularly fail to be written completely in case of power loss, among other problems. Then it was found to be so nice that upper management decided to use it for everything, and the team cursed, and tore their hair, but it was too late. It is possible that articles in computer journals introducing COM/OLE in Windows 3 have more information on first approach to registry and its goals back then.
- skissane 5y ago> lpClass most likely is a class name in COM/OLE sense. I don't think that is true. In the original Windows 3.1 registry, lpClass did not exist. You only had the RegCreateKey() function which had no lpClass parameter, that parameter was added in RegCreateKeyEx() which was only in NT (and later Windows 95 too). COM/OLE never used lpClass. Out-of-the-box, very few Windows registry keys have lpClass set, and those that do it is mostly some meaningless value like "Shell" or "Setup", which COM/OLE completely ignores. The one place (that I know of) which it is (or was) actually used, is to store the syskey encryption key [0]. I think using lpClass for that is just abusing it for a bit of security-by-obscurity, it is a way to store data in the registry but hide it from most registry tools (which provide no access to lpClass because almost nobody uses it.) Possibly other people are doing the same thing (to store license keys, detect expiration of trial periods, malware hiding stuff, etc.) [0] http://moyix.blogspot.com/2008/02/syskey-and-sam.html http://moyix.blogspot.com/2008/02/syskey-and-sam.html