Hacker News new | ask | show | jobs
by Hello71 2958 days ago
if it's trying to be a database, it's doing a terrible job. all the problems of not being files (can you do "find HKEY_CURRENT_USER -name mypackage" to see what the uninstaller left behind?) with none of the benefits of a database (ACID).
4 comments

When they were working on Windows 7, Microsoft tried to be more open about the development process in order to repair some of the damage Vista had done. So one day, I came across this video, an interview of a few Windows developers.

At one point, the person doing the interview asks, "So, what do you guys think of the Registry?". Awkward silence, followed by uncomfortable laughter. Finally, one of the programmers says, "I think it's fair to say it was far more [widely used] than any of its designers had anticipated."

(Quoting from memory from a video I saw once, ~10 years ago, so the wording might not be perfectly accurate, but that's how I remember it.)

> can you do "find HKEY_CURRENT_USER -name mypackage"

Powershell comes with a kind of FUSE mount for the registry:

    PS C:\> Set-Location HKCU:
    PS HKCU:\> Get-ChildItem -Recurse | where-object { $_.Name -match "HeidiSQL" }
Or for those who come from Unixland and see way too much typing, PowerShell has aliases that make this much shorter:

    cd HKCU:
    ls -r -i *HeidiSQL*
Or if you really want to use the match operator, regex, or other expression, you can still pipe it through the Where-Object alias:

    ls -r | ? {$_.Name -match "HeidiSQL"}
Just to make sure everyone on HN knows you can get real pithy with PowerShell, this also works:

  PS C:\> cd hkcu:
  PS HKCU:\> ls -r | ? name -m 'HeidiSQL'
> with none of the benefits of a database (ACID)

This is not correct, Windows Registry updates are atomic and transactional. There may be other problems with the registry model, but it is a "real" database.

ACID means more than atomic updates, though. To be ACID-compliant, you'd have to be able to group several changes to the registry and have them take effect either all at once or not at all.
> To be ACID-compliant, you'd have to be able to group several changes to the registry and have them take effect either all at once or not at all.

You mean transactions? Windows registry supports them since Vista when they added Kernel Transaction Manager: https://msdn.microsoft.com/en-us/library/windows/desktop/bb9...

See CreateTransaction, RegCreateKeyTransacted, RegOpenKeyTransacted, CommitTransaction[Async], RollbackTransaction[Async] APIs.

I stand corrected. Good to know, thank you!
To be fair, I’ve never used KTM in my apps.

In cases when I need to write several values atomically (e.g. in a program with persistent window positions, after user moved a window I want to write all 4 coordinates of the rectangle), I just keep them in a single value, either string or binary. Even without KTM, registry API already guarantees value writes are atomic.

A word for that is transactional.
It's implied by the I (isolation).
https://msdn.microsoft.com/en-us/library/windows/desktop/ms7...

Could you point out which of these doesn't work as intended?