|Home » Learning Curve » A Gullible's Travels
~A Gullible's Travels~
Part Three in which Micro Luser Gullible learns how to arrange his new furniture.
III. Small Registries
'Keep it in ASCII.'
- Unix programming guideline
One of the most horrific design mistakes with Windows is its Registry. It's hard to understand this monster was once applauded by system engineers when it made its first full entrance onto the scene. The reason for this unfounded mirth was that before the Registry things were even worse.
Back before the Registry Windows had only one way to store system and application settings: small linear text files called INI files. They were called 'INI files' because they used the file extension 'INI'.
They're rather pathetic.
It's puzzling how (and unforgivable that) open source Unix systems shamelessly copied this INI file technology and haven't replaced it with something better. This can be because most open source developers have known only Windows - they've never seen anything better.
INI files are divided up into sections which in turn contain entries which in turn have values.
This is text only. Your API call specifies a particular file, section, and entry, and you get back a (text) value. Of course you can interpret this text value as a numerical value if you like.
But after that you're basically screwed. The system does have an API for getting the numerical value for the above but if you want to store a number you have to write the API yourself. All the system will do is save text.
The INI file system makes it impossible to store data hierarchically. And it makes it impossible to store binary data - characters with a zero or non-ASCII value will break the system. Finally: INI files can't be bigger than 64 KB. [A very well known television corporation in the UK had to write their own Windows INI file system for their teleprompters back in the day because Microsoft's own wouldn't do it.]
Given this situation it's no surprise developers were glad something came along to replace INI files. The Windows Registry replaced them. It has hierarchy and it can store binary data. It has two major keys corresponding to disk directories.
There are other keys commonly mentioned such as HKEY_CLASSES_ROOT and HKEY_CURRENT_USER but these are only shortcuts into the hierarchy of the first two.
Registry keys can have data (default values) but they can also have subkeys and values which are the Registry counterpart to disk files. The values then have data and the data can be stored in a number of formats (such a 'binary').
Note the confusing terminology here: the INI file 'value' doesn't correspond to the Registry 'value'. The actual correspondence is INI file entry → Registry value; and INI file value → Registry data.
There are a number of fatal disadvantages to the Windows Registry architecture which compound and ultimately make things impossible.
1. It looks like gobbledegook to ordinary users. The blasted thing is monstrous. It's intimidating even for seasoned professionals.
2. There's no 'undo' or 'save'. As soon as you type something in it's there and can't be changed back. Early versions of the Registry editors did try to have separate 'save' functions but that was back before the Registry grew to a nontrivial size.
3. It's all connected together. It's not all in one file but close to it. One slip of the keyboard and you hose your entire system. For that matter: one programming bug in your Registry editor, one glitch on your hard drive, and the same thing happens. Your system is toast. Not just a part of it - all of it.
4. No sporting chance to recover. If the worst does happen (and it will to most users at least once) the chances of recovery are next to nil. It's all binary gibberish anyway. You can't isolate any one thing and remove it if it's misbehaving - the entire system is misbehaving. All computer systems keep in mind that errors can happen - but not this one.
But the above compound on one another and make great vicious circles.
The Registry looks like gobbledegook to ordinary users. It's the perfect place to hide. The Registry is an unfathomable jungle; Microsoft change the rules all the time; you can't know from one day to the next what's new legit code and what's only a trojan hiding out. You need pretty advanced tools to detect what's going on and you need to watch things in realtime and what ordinary user is going to want to do that?
An attempt to practice self-defence involves going into the Registry to fight the bad guys mano-a-mano. But the typical user is at a tremendous disadvantage; hackers on the other hand know how to use the Registry. And one slip of the mouse and the whole system comes crashing down.
At least on Apple's OS you'll find the stronger more flexible defaults system. A complete description of this system is beyond the scope of this article. But all your settings come in small specific files that can be read as ordinary text. Each application has its own file on disk for settings. If an application is acting up you need only remove its configuration file. Nothing else in the system is affected.
And because there's no jungle like the Windows Registry there's nowhere for the bad guys to hide. If they somehow get in and try to hide on your system they'll stick out like a sore thumb.
And even though they're essentially text files (and can be saved as such) they contain data in a hierarchy in both binary format and a lot of sophisticated formats Windows can't come close to. The files themselves are classified as dictionaries - data objects that have pairs of keys and values. Where the values can be further subkeys, further dictionaries, arrays of dictionaries, of strings, of integers, of boolean values, arrays of arrays, and so forth. You can store anything you want.