Modern Windows 10 can run binaries that were compiled on 20 years ago for Windows 95 or NT4, however I imagine that the libraries that the code is calling would have changed massively since then.

I know that it is possible to maintain binary compatibility while further developing a library (in C++ for example by not adding any virtual member functions, not changing the size of a class/struct by reserving space for future use, etc.), but I imagine it requires a lot of forward planning and may cause updated code to be messy. Alternativley it is possible to retain old versions of libraries, but this is inefficient.

What have Microsoft done to maintain this binary compatibility in Windows for so long?

  • 2
    Read Raymond's blog. Its full of gems and anecdotes on the subject.
    – user44761
    Oct 29, 2017 at 12:15
  • 5
    "How has Windows maintained binary compatibility for over 20 years?" – Painfully. Very painfully. One example: Windows 7 has version number 6.1. Why? Because a large number of broken applications checked for major == 6 to figure out whether to enable advanced Vista features and reverted back to old XP style for a major version of 7. Therefore, even those application were wrong and broken MS decided to rather change the version number than "break" those existing apps. Example 2: Vista enforced certain security rules that were already documented but not enforced for over a decade. … Oct 29, 2017 at 14:43
  • 5
    … Yet, this broke tens of thousands of applications. Rather than saying "we have documented that this doesn't work, it's your fault if you do it anyway", Vista ships with a database of over 20000 signatures (filenames, hashes, etc.) of applications for which various workarounds are built into the OS. (For example, writing to system directories is relaxed for executables which are named setup.exe, install.exe and similar.) Oct 29, 2017 at 14:45