Live data from Hacker News

Windows: Prefer the Native API over Win32

codeberg.org

61–70 of 99 posts

Re: Windows: Prefer the Native API over Win32

#61

For people not familiar with Windows development, another name for the NT native API is "the API that pretty much every document on Windows programming tells you not to use". It's like coding to the Linux syscall interface instead of libc.

Yeah, I know go has had issues because they subvert libc themselves in similar fashion. I wonder how this will turn out.

Same way it turned out for Go: they had to walk it back.

Re: Windows: Prefer the Native API over Win32

#62
post #31
post #29

>> Microsoft are free to change the Native API at will, and you will be left holding both pieces when things break. > [...] the worst case scenario is really mild: A new version of windows comes out, breaking ntdll compatibility. Zig project adds a fix to the std lib. Application developer recompiles their zig project from source, and ships an update to their users. That assumes the application developer will continu…

> Microsoft are free to change the Native API at will,... But they won't, because if there is one thing that Microsoft has always been extremely good at and cared for is backward compatibility. And changing Native API will break a ton of existing software, because even though undocumented it is very widely used.

Actually they do change the native API quite a bit. Not in minor releases so much but in major releases

Re: Windows: Prefer the Native API over Win32

#63
post #33

> Comparing the comprehensive Win32 API reference against the incidentally documented Native APIs, its clear which one Microsoft would prefer you use. The native API is treated as an implementation detail, whilst core parts of Windows' backwards compatibility strategy are implemented in Windows subsystem. > A general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software. Zi…

The Zig maintainers clearly think that keeping up with the undocumented native API is less headache than using the documented but notoriously inelegant win32 API.

This might very well be a good idea. Microsoft is not going to change a vital piece of their OS just on a whim. I would wager that even if they wanted to, they would not be able to do so that easily. A large organization maintaining a large software with a billion users just does not move that fast.

Re: Windows: Prefer the Native API over Win32

#64

Earlier quoted context omitted.

Zig is proposing the opposite problem: future versions of windows wont run even trivial zig programs from today. I can tell you that old Linux binaries run just fine on current distros. Looking at how many times you repeated your misunderstanding in this thread it's clear that, not only do you not understand the solution, you don't understand the problem either.

> I can tell you that old Linux binaries run just fine on current distros. Simple: I don't believe you. Grab this copy of Firefox from 2022, https://www.firefox.com/en-US/firefox/96.0/releasenotes/ , and run it on a modern distribution in 2026. If you fail, my point is made.

I dunno about firefox (newer crypto libs wont work) but I ran a gimp compiled in 2018 on a 2025 distro.

Why specifically FF? Software without TLS does run just fine 5 years later on 5 year newer distros.

Re: Windows: Prefer the Native API over Win32

#65
post #16

Why not use both DLLs? Prefer win32 wherever possible and use the lower level APIs only if absolutely necessary. Benchmark after you have figured this out. Performance is probably not a thing at this level of abstraction.

What makes you think they haven't benchmarked? Here's one fun example from following development on Zulip: advapi.dll loads bcrypt.dll, which loads bcryptprimitives.dll. bcryptprimitives.dll runs an internal test suite every time it's loaded into any process. So if you can avoid loading advapi.dll, your process will start faster.

Are you talking about the cipher tests that are run when any cipher library is loaded?

There's a reason they do that and it's not for shits and giggles. You could find yourself with broken ciphers and not know it.

Skipping the cipher (or hash - not sure now) tests seem like a good way to get exploited.

Re: Windows: Prefer the Native API over Win32

#66

Earlier quoted context omitted.

What makes you think they haven't benchmarked? Here's one fun example from following development on Zulip: advapi.dll loads bcrypt.dll, which loads bcryptprimitives.dll. bcryptprimitives.dll runs an internal test suite every time it's loaded into any process. So if you can avoid loading advapi.dll, your process will start faster.

Is there a source for this? My Google- and GitHub-fu turns up nothing.

He might be talking about cipher test that respected cryptography libs do on initialisation to verify integrity.

Skipping those seem like a really bad idea.

Re: Windows: Prefer the Native API over Win32

#67

Earlier quoted context omitted.

Zig is proposing the opposite problem: future versions of windows wont run even trivial zig programs from today. I can tell you that old Linux binaries run just fine on current distros. Looking at how many times you repeated your misunderstanding in this thread it's clear that, not only do you not understand the solution, you don't understand the problem either.

> I can tell you that old Linux binaries run just fine on current distros. Simple: I don't believe you. Grab this copy of Firefox from 2022, https://www.firefox.com/en-US/firefox/96.0/releasenotes/ , and run it on a modern distribution in 2026. If you fail, my point is made.

Does Debian Stable count?

The page didn't include a download link, so I found it here: https://ftp.mozilla.org/pub/firefox/releases/96.0/linux-x86_...

And yes, it runs perfectly fine on Debian 13.

Re: Windows: Prefer the Native API over Win32

#68
post #56

Earlier quoted context omitted.

On Windows, the stability guarantees are opposite to that of Linux. The kernel ABI is not guaranteed to be stable, whereas the Win32 ABI is . And frankly, the Windows way is better. On Linux, the 'ABI' for nearly all user-mode programs is not the kernel's ABI but rather glibc's (plus the variety of third-party libraries, because Win32 has a massive surface area and is an all-in-one API). Now, glibc's ABI constantly c…

The Win32 ABI is also just a wrapper on the native API, which is only stable in practice, but not officially according to any Microsoft documentation. Glibc is userspace seen from the perspective of the Linux kernel.

It doesn't really matter if it's 'just a wrapper', because said wrapper provides an ABI. Even if the underlying Native API changes, the interface the wrapper presents to other compiled binaries won't. The latter will contain caller/callee register setup, type layouts, function arguments and more for that wrapper.

Cygwin is also 'just a wrapper' for the Native API and Win32, and look how drastically it changes the ABI of applications.

Re: Windows: Prefer the Native API over Win32

#69

Earlier quoted context omitted.

> I can tell you that old Linux binaries run just fine on current distros. Simple: I don't believe you. Grab this copy of Firefox from 2022, https://www.firefox.com/en-US/firefox/96.0/releasenotes/ , and run it on a modern distribution in 2026. If you fail, my point is made.

Does Debian Stable count? The page didn't include a download link, so I found it here: https://ftp.mozilla.org/pub/firefox/releases/96.0/linux-x86_... And yes, it runs perfectly fine on Debian 13.

He doesn't understand the problem.

You aren't going to convince him because he doesn't know what the problem is.

Re: Windows: Prefer the Native API over Win32

#70
post #7

Fool's errand. Apps built with this will have to be maintained forever (vs the apps from Win 9x which still work in Windows 11).

The reason apps from Win 9x runs on Windows 11 is that MS puts a ton of effort into explicitly supporting old apps. For popular apps that includes supporting undocumented APIs and even app-specific bug compatibility.

Putting it on app developers to account for infinite forward compatibility is not at all reasonable.

The best outcome would be if many Zig apps become popular enough that Windows is forced to maintain backward compatibility for ntdll. The API is clearly superior to win32 as many other developers have discovered and discussed before. It’d be nice to force MS to take low lever programming seriously instead of chasing AI slop.

Post reply on HN