HNHacker News
TopNewBestAskShowJobs

delta_p_delta_x

5,063 karma · joined July 15, 2021

submissionscomments
delta_p_delta_x··on Windows: Prefer the Native API over Win32
Is there a source for this? My Google- and GitHub-fu turns up nothing.
delta_p_delta_x··on Windows: Prefer the Native API over Win32
Indeed. Anything documented has a function wrapper. `NtCreateFile` is a function wrapper for the syscall number, so any user-mode code that has `NtCreateFile` instead of directly loading the syscall number 0x55 will be stable. The latter might not. In fact, it is not; the number has increased by 3 since Windows XP[1].

One could probably produce some sort of function pointer loader library with these tables, but at that point... Why not just use the documented APIs?

[1]: https://github.com/j00ru/windows-syscalls/blob/8a6806ac91486...

delta_p_delta_x··on Windows: Prefer the Native API over Win32
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 changes, so linking against a newer glibc (almost certainly the 'host' glibc, because it is almost impossible to supply a different 'target' glibc without Docker) will result in a program that doesn't run on older glibc. So much for Torvalds' 'don't break userspace'.

Not so for a program compiled for 'newer' Win32; all that matters are API compatibilities. If one only uses old-hat interfaces that are documented to be present on Windows 2000, one can write and compile one's code on Windows 11, and the executable will run on the former with no issues. And vice versa, actually.

delta_p_delta_x··on GrapheneOS – Break Free from Google and Apple
correct horse battery staple; knew it before I clicked the link.
delta_p_delta_x··on GrapheneOS – Break Free from Google and Apple
Having more than just alphanumeric characters widens the domain of the password hash function, and this directly increases the difficulty of brute-force cracking. But having a such a small maximum password length is... puzzling, to say the least. I would accept passwords of up to 1 KiB in length.

With rainbow tables, even 11-character simple passwords like 'password123' can be trivially cracked, and as the number of password leaks show, not everyone is great at managing secrets and credentials.

delta_p_delta_x··on I fixed Windows native development
I dunno, it has its uses when porting software written for UNIX-first. Plus, I pointed out Clang, rather than GCC, because Clang is natively a cross-compiler. I don't like to be dogmatic about stuff; if it's useful then it's useful. If it isn't then I will say why (as I explained why there's no need for MSYS2/Cygwin below).
delta_p_delta_x··on I fixed Windows native development
'MinGW' is not GCC; it's an ABI, and from the developer perspective it is also the headers and the libraries. You can have GCC MinGW, Clang MinGW, Rust MinGW, Zig MinGW, C# AOT MinGW.

To answer your question, the headers.

delta_p_delta_x··on I fixed Windows native development
> MSYS2 CLANG64

I get your point. Although my point is that there is actually zero need for MSYS at all for this, even as a developer, and especially not with the 'CLANG64' environment. These binaries themselves are built to run in the MSYS2 environment This is how I cross-compile from Windows... to Windows with LLVM-MinGW[1]:

  > (gci Env:PATH).Value.Split(';') | sort
  > clang-21.exe --version
  clang version 21.1.2 (https://github.com/llvm/llvm-project.git b708aea0bc7127adf4ec643660699c8bcdde1273)
  Target: x86_64-w64-windows-gnu
  Thread model: posix
  InstalledDir: C:/Users/dpdx/AppData/Local/Microsoft/WinGet/Packages/MartinStorsjo.LLVM-MinGW.UCRT_Microsoft.Winget.Source_8wekyb3d8bbwe/llvm-mingw-20250924-ucrt-x86_64/bin
  Configuration file: C:/Users/dpdx/AppData/Local/Microsoft/WinGet/Packages/MartinStorsjo.LLVM-MinGW.UCRT_Microsoft.Winget.Source_8wekyb3d8bbwe/llvm-mingw-20250924-ucrt-x86_64/bin/x86_64-w64-windows-gnu.cfg
[1]: https://github.com/mstorsjo/llvm-mingw
delta_p_delta_x··on I fixed Windows native development
> compared to Linux, the Microsoft stack is much more annoying to install.

Not really. It's just different. As a cross-platform dev, all desktop OSs have their own idiosyncracies that add up to a net of 'they are all equally rather bad'.

delta_p_delta_x··on I fixed Windows native development
No one should use any of these weird Frankenstein monstrosities in 2026. And a batch script? :( PowerShell exists.

Install:

  - contrary to the blog post, the entirety of Visual Studio, because the IDE and debugger is *really damn good*.

  - LLVM-MinGW[1]
Load the 'VSDevShell' DLL[2] for PowerShell, and you're good to go, with three different toolchains now:

  cl.exe from VS
  clang-cl.exe—you don't need to install this separately in VS; just use the above-mentioned llvm-mingw clang.exe as `clang.exe --driver=cl /winsysroot <path\to\Windows SDK> /vctoolsdir <path\to\VC>`. Or you can use it in GNU-driver-style mode, and use -Xmicrosoft-windows-sys-root. This causes it to target the Windows ABI and links against the VS SDK/VC tools
  `clang.exe` that targets the Itanium ABI and links against the MinGW libraries and LLVM libc++.
Done and dusted. Load these into a CMake toolchain and never look at them again.

People really like overcomplicating their lives.

At the same time, learn the drawbacks of all toolchains and use what is appropriate for your needs. If you want to write Windows drivers, then forget about anything non-MSVC (unless you really want to do things the hard way for the hell of it). link.exe is slow as molasses, but can do incremental linking natively. cl.exe's code gen is (sometimes) slightly worse than Clang's. The MinGW ABI does not understand things like SAL annotations[3], and this breaks very useful libraries like WIL[4] (or libraries built on top of them, like the Azure C++ SDK[5] The MinGW headers sometimes straight up miss newer features that the Windows SDK comes with, like cfapi.h[6].

[1]: https://github.com/mstorsjo/llvm-mingw

[2]: https://learn.microsoft.com/en-gb/visualstudio/ide/reference...

[3]: https://learn.microsoft.com/en-gb/cpp/c-runtime-library/sal-...

[4]: https://github.com/microsoft/wil

[5]: https://github.com/Azure/azure-sdk-for-cpp

[6]: https://learn.microsoft.com/en-gb/windows/win32/cfapi/build-...

delta_p_delta_x··on I fixed Windows native development
> MSYS2 just enough development environment

Doesn't it come with `pacman` too?

delta_p_delta_x··on I fixed Windows native development
It was not clear what the parent commenter was addressing; I was under the impression they meant 'compile against the MSYS2 environment', which is broadly Cygwin, yes, which should not be forced onto a user.
delta_p_delta_x··on I fixed Windows native development
There are some pretty useful abstractions and libraries that MinGW doesn't work with. Biggest example is the WIL[1], which Windows kernel programmers use and is a massive improvement in ergonomics and safety when writing native Windows platform code.

[1]: https://github.com/microsoft/wil

delta_p_delta_x··on I fixed Windows native development
MSYS2 is horrible. It brings a massive runtime environment and is a bad idea to foist on users.
delta_p_delta_x··on Windows NT/OS2 Design Workbook
I have a hot take. manpages are really bad for noob examples, or if you actually want to learn how to use something. They are great references if you already know 95% of the tool, but for the most common use cases, they completely lack any sort of examples.

In this sense, LLMs (as much as I am sceptical about them) are much more useful.

delta_p_delta_x··on Windows NT/OS2 Design Workbook
For more modern Windows, Windows Internals Parts 1 and 2[1][2], and Windows 10 System Programming Parts 1 and 2. Basically anything by Yosifovich, Russinovich, Ionescu et al.

[1]: https://www.microsoftpressstore.com/store/windows-internals-...

[2]: https://www.microsoftpressstore.com/store/windows-internals-...

[3]: https://leanpub.com/b/windows10systemprogrammingP1and2

delta_p_delta_x··on Zed editor switching graphics lib from blade to wgpu
vk.xml[1] is the canonical Vulkan specification; this is updated essentially weekly.

The C++ equivalent, Vulkan-Hpp[2], follows extremely closely behind. Plus, ash isn't just an FFI wrapper; it does quite a bit of RAII-esque state and function pointer management that is generally required for Vulkan.

[1]: https://github.com/KhronosGroup/Vulkan-Docs/blob/main/xml/vk...

[2]: https://github.com/KhronosGroup/Vulkan-Hpp/

delta_p_delta_x··on Both GCC and Clang generate strange/inefficient code
Even at a higher level of abstraction, the compiler seems to pull through: https://godbolt.org/z/1nvE34YTe
delta_p_delta_x··on Microsoft is walking back Windows 11's AI overload
> The pain of ripping this all out properly is likely too high.

That is just completely illogical and betrays a complete lack of understanding of how Windows works. Most problems people have with Windows are in the user mode, and not in the kernel. The pain of reverting straightforward UI/UX/vendor-provided application code that is probably version-controlled and tagged for specific historic Windows releases is 'too high', so, therefore, let's do something that's even higher cost, and...

> windows 13 or 14 will just be a linux distro

Ugh, not this again. It looks like this train of thought will never leave HN commenters who probably have never seriously actually used or programmed on Windows. Literally every week I see 'Windows should keep the same user mode and move to the Linux kernel'.

You guys know what another Linux kernel running a locked-down user mode stack is called? Android.

delta_p_delta_x··on Implementing a tiny CPU rasterizer (2024)
Ah yes, great book; thanks for pointing it out. Added to the list.

As for similarity, I think the sections you've highlighted are broadly similar, but I can't detect any phrase-for-phrase copy-pasting that is typical of LLM or thesaurus find-replace. I feel that the topic layout and the motivations for any tutorial or course covering the same subject matter will eventually converge to the same broad ideas.

The website's sequence of steps is also a bit different compared to your book's. And most telling, the code, diagrams, and maths in the website are all different (such assets are usually an instant giveaway of plagiarism). You've got pseudocode; the website uses the C++ standard library to a great extent.

If it were me, I might rest a little easier :)

delta_p_delta_x··on Implementing a tiny CPU rasterizer (2024)
This is a great resource. Some others along the same lines:

TinyRenderer: https://haqr.eu/tinyrenderer/

ScratchAPixel: https://www.scratchapixel.com/index.html

3D Computer Graphics Programming by Pikuma (paid): https://pikuma.com/courses/learn-3d-computer-graphics-progra...

Ray-tracing:

Ray Tracing in One Weekend: https://raytracing.github.io/

Ray Tracing Gems: https://www.realtimerendering.com/raytracinggems/

Physically Based Rendering, 4th Edition: https://pbr-book.org/

Both:

Computer Graphics from Scratch: https://gabrielgambetta.com/computer-graphics-from-scratch/

I'll also link a comment[1] I made a while back about learning 3D graphics. There's no better teacher than manually implementing the rasterisation and ray-tracing pipelines.

[1]: https://news.ycombinator.com/item?id=46410210#46416135

delta_p_delta_x··on GOG: Linux "the next major frontier" for gaming as it works on a native client
> $90k a year.

$90K a year goes much further in most of Europe barring the centres of the biggest cities—let alone eastern Europe—than it does in the US.

NYC and Bay Area salaries are outrageously inflated, with much of the take-home being funnelled into four/five digit rents or mortgages for houses built out of matchsticks, car loans, health insurance payments, and more. None of this is necessary or costs as much in most of Europe, or the rest of the world, really.

delta_p_delta_x··on Microsoft forced me to switch to Linux
> BMW drivers

£50 for a heated seat, perhaps, but you also get by far one of the best turbocharged inline-6 engines ever put in a 4-door saloon, the S58. Analogous to Windows NT, a well-engineered kernel.

delta_p_delta_x··on Winapp, the Windows App Development CLI
> the utterly insane UX around the C++ redistributable

It could be worse—it could be Linux, with no forward compatibility. The VC/C++ redistributable means that applications can be written on modern Windows that targets much older Windows, by simply providing a sidecar installer that brings with it a newer C/C++ standard library. This situation is basically impossible on Linux without messing with Docker.

delta_p_delta_x··on Winapp, the Windows App Development CLI
> plain Win32

Plain Win32 needs a renaissance. I worked with it and felt like a wizard. Message boxes, dialogue boxes, wizards, hammered out in pure C++. Combined with the Windows Implementation Library[1] I was writing fast, modern code.

[1]: https://github.com/microsoft/wil

delta_p_delta_x··on Xmake: A cross-platform build utility based on Lua
> not sure about C++20 modules and import std support

XMake supports both.

delta_p_delta_x··on Microsoft forced me to switch to Linux
That just means you can't perceive it. Sorry, but raster scaling is how Apple's algorithm works, and just because you can't see it doesn't mean it is not the case.

For the record, this isn't just visual. Rasterising to a framebuffer that is considerably larger than the physical resolution and then scaling produces a tangible effect on battery life. Not that it matters much with the impressive efficiency of the M-series SoCs, but it is there nonetheless.

delta_p_delta_x··on Microsoft forced me to switch to Linux
> All of these involve external monitors as far as I can tell

This happens on the native displays of MacBooks and iMacs, too. Try any of the 'looks larger'/'looks smaller' settings and it'll show up.

delta_p_delta_x··on Microsoft forced me to switch to Linux
> ringing or any specific artifacts at all around text

There are a few Reddit threads that crop up when one searches for 'macOS ringing artifacts scaling'. For instance, these ones:

https://www.reddit.com/r/macbookpro/comments/1252ml8/strange...

https://www.reddit.com/r/MacOS/comments/1ki58zk/fractional_s...

https://www.reddit.com/r/MacOS/comments/l8oadr/macos_fringin...

All are ringing artifacts, typical of downscaling. I no longer have a Mac (chose one for work to try it out, saw this issue, returned it immediately), but I assure you this is what happens.

> The only complaint people tend to make is ever-so-slight additional blurriness

At no scale factor should there be any blurriness unless a framebuffer resolution is explicitly set. The 'scale factor' should be entirely independent of the physical resolution, which macOS simply does not do.

Apple's understanding and implementation of 'Retina' comes from a singular source: the straightforward doubling in each dimension of the display resolution of the iPhone 4 compared to the iPhone 3GS. It has not changed since, and has applied this algorithm throughout its OS stack.

delta_p_delta_x··on Microsoft forced me to switch to Linux
These were probably written against the old-school Win32. It's pretty easy to fix.

  Right-click on the `.exe`
  Properties
  Compatibility tab
  Change settings for all users
  Change high DPI settings
  Under 'High DPI scaling override' section, tick box for 'Override high DPI scaling behaviour. Scaling performed by'
  In the drop-down box below, select 'Application'
Done.

For MMC snap-ins like `diskmgmt.msc`, `services.msc`, or `devmgr.msc`, there's a Registry key you can set. See this ServerFault question: https://serverfault.com/q/570785/535358

← PreviousPage 8 of 34Next →