2024-04-13
The UI frameworks of Windows are a bit of a mess: there are lots of them and it's unclear which one should be used and what to expect of it. Here I tried collecting some basic info about them to clear some of the confusion for myself and for others.
I will also try to benchmark each of the frameworks with a simple "hello world" application using two criteria: 1) the RAM usage and 2) the resize stress test: how the frameworks handles rendering of elements glued to the bottom or right border when resizing the application.
I like to use the resize test, as it demonstrates the attention to details even under conditions which are considered rare and difficult to implement correctly. Resizing a window often involves recreating the texture buffer of the window and synchronising it with the render loop. Particularly web-based UI tech fails at this, including Electron, WebView2, Tauri. This is best seen when resizing a window by the top-left corner, as in this case glued elements should not change their position on screen.
Not all frameworks are equal: some are foundational, i.e. they actually implement the rendering of UI widgets, and some are simply wrappers of other frameworks (mostly WinAPI actually).
Inspired by Reilly Wood's review.
Windows API (or Win32) is a name for all APIs provided by Windows for developing apps, not just GUI. The GUI part is implemented in the Windows USER dynamic library, located at System32/user32.dll
.
Win32 uses GDI for rendering, which itself is a pretty old API too, since then superseded by DirectX APIs. It does not support GPU-based acceleration of rendering.
Resize test: passes.
Foundation Class Library is the first wrapper of Windows API into C++-based object-oriented API. I didn't bother with it, since it does not bring too much in comparison to WinAPI or WinForms.
Windows Forms is an open-source framework for .NET written in C# which wraps the Windows API in C# APIs. The look-and-feel and the method of rendering stays the same, only the programming APIs are changed.
There are two versions of WinForms: the older one pre-open-source for .NET Framework versions up to 4.8; and the newer one for .NET Core 3.0 and later (.NET platform).
Visual Studio supports the WinForms visual designer, which generates C# code of the layout.
Resize test: passes.
Windows Presentation Foundation is the second foundational system API for GUI apps. It's open-source and written in C++ and C#. It uses DirectX APIs for hardware-accelerated rendering (the first one in line) and its SDK provides XAML-based layout definitions. Despite that, it shares the same look-and-feel with the classic Win32 UI.
Resize stress test: passes, but with noticeably lower FPS, at least in the debug mode.
Universal Windows Platform was introduced in Windows 8 for the next generation of apps using their new design system, formerly called Metro. After Windows 11 was released, WinUI 2 evolved to support the newest Fluent design system.
This is also the framework which was used in Windows Phone and Xbox, hence "universal" in the name.
Resize test: passes.
WinUI 3 is the fourth and the latest foundational GUI API focused fully on the Fluent design system. It's part of Windows App SDK – a new set of APIs for app development. Unlike older frameworks, Windows App SDK is not a part of Windows. Instead it is used by applications just like any other library via NuGet.
Resize test: fails.