Comment by bni
6 years ago
"Microsoft has pretty much abandoned the API"
No they havent. Everything else in Windows land is just built on top of it.
I also made some Win32 development at one point. The programs made using only Win32 have a very snappy and light weight feel to them that is very nice. It is fairly low level and more for the machine than for humans. But I doubt you can have both of these things.
No they havent. Everything else in Windows land is just built on top of it.
There were even some articles recently about that:
https://news.ycombinator.com/item?id=19873198
I started with a bit of Win16 and then moved to Win32, and don't really see why it gets a lot of hate; it's not perfect, but it looks like it does exactly what it was meant to do, and does it well. Perhaps it's because all of the tiny and fast applications I've used in the past were pure Win32. You can do a lot with it in only a few KB or tens of KB. In contrast, I don't find all the other multi-megabyte UI frameworks appealing.
> I started with a bit of Win16 and then moved to Win32, and don't really see why it gets a lot of hate; it's not perfect, but it looks like it does exactly what it was meant to do, and does it well.
From a birds' eye view: Because it's just not productive to write apps without some type of modularity, and the WndProc abstraction encourages enormous monster functions that do everything. There's a reason why all UI frameworks have some kind of modular paradigm, whether it's object-oriented or functional reactive or what have you.
More specifically: A lot of the core APIs are just bad. RegisterWindowEx has a struct with a dozen random fields, and CreateWindowEx has a ton of confusing random parameters. For example, why do you have to specify a menu when you're creating a button? Why is dwExStyle the first parameter and dwStyle is the fourth? Why do you have to specify a cursor explicitly instead of just having a function that sets it if you want a non-default one? It's possible to make a low-level C API that's actually reasonably pleasant to use, as in GTK+. Win32 is just a mess.
I have worked with both and i find Gtk+'s C API to be very bad actually, much worse than Win32. Sure, it looks more consistent but that doesn't help when what you want to do is done in a hair-pulling way. It is also much more verbose, though it hides that because it is overall a higher level API than Win32.
The issues you mentioned do exist but they are just minor nitpicks - at the end of the day it doesn't matter at all if the dwExStyle parameter is at the first, fourth or at the last (my guess was that is first to allow for a quick textual search and replace in code to "upgrade" from "CreateWindow(..." to "CreateWindowEx(0, ..."). This is the sort of stuff that will never cause any sort of issue in practice.
Also there are no confusing random parameters in CreateWindow if you actually read the documentation. The menu parameter for a button isn't used for a menu but for an identifier that allows you to distinguish that button from other controls in the window.
Finally your winproc's switch can actually call dedicated functions. You can even write a couple of macros that do that for you so you do something like
which is pretty much the same as what you'd do in other toolkits with setting up event handles such as
(or your favorite toolkit's equivalent)
5 replies →
Those articles seem overblown. Providing access to UWP APIs from regular desktop apps will, if anything, increase the number of applications using those APIs. UWP GUI APIs could be especially attractive option to those applications currently using win32 forms.
I wonder how exactly will those WinUI (or UWP GUI) APIs will be used in practice though. The vast majority of applications that still use Win32 do it through some sort of framework (be it wxWidgets, MFC, VCL/LCL, etc) that has specific assumptions about what desktop applications are and how they are made. From what i've seen, mixing WinUI and Win32 on the same application kinda feels like dropping a web control in a VB6 application and using HTML+JS to create the UI (which ignores pretty much all the strengths of VB6 while retaining all the limitations).
I have a hard time imagining why anyone who isn't forced to use WinUI in their Win32 application (forced in the sense that some middle manager heard about it and believes it is a good idea so forces the developers to use it) would use it in the first place. I mean, many applications/frameworks do not even use stuff available through COM since Vista and instead prefer to recreate them using the plain C APIs and that is for a seemingly simpler and more understood variety of COM.
> Now in Windows 10, User32/GDI is deprecated and obsolete for high-performance applications (and it’s really slow too after they axed GDI hardware acceleration in Vista), but there isn’t a single replacement, instead there’s like 5 of 6 - all incompatible with each other. While it’s true that it shouldn’t matter because OLE objects were rendered to their own separate hWnd, consider that the new UWP system doesn’t use hWnds, and frameworks like WPF have “air gap” issues with rendering their content overlaying another hWnd and often resort to hacks using window content blitting which drastically hurts performance (as you need to blit to/from RAM, instead of keeping it all in VRAM).
https://news.ycombinator.com/item?id=21450112
I may be totally off-base, here, but isn't WPF independent from Win32?
Sort of. It uses Win32's windowing and input/message loop primitives for top-level windows but within a window's content all the layout, controls and rendering are WPF-bespoke. This is different from Windows Forms which wraps Win32 controls. It's also different from UWP/WinUI which can use Win32 windowing primitives, but doesn't necessarily depend on them. This is all using Win32 to refer specifically to the UI side of things, but if we use "Win32" to refer to the entire set of flat C-style Windows APIs then all these frameworks are heavily dependent on Win32
It is. It’s based on DirectX. I think version 9.