HowToDesktop-870x220

A look at all the different ways to build for desktop today. Choose your life partner wisely.

Congratulations. If you are reading this in 2021, you’ve time travelled to next year. The global pandemic is behind us and the world is crawling back to normalcy. For developers on Microsoft stack, .NET 6, .NET MAUI and associated tooling are out as of last November. Apple has solidified macOS Monterey and iOS 15 with stable XCode releases. If you are tasked to start a greenfield desktop app project today, what would you use?

First up, please do not let anyone tell you that desktop apps are “legacy”—look around and you shall see a majority of enterprise workflows depending on desktop software.

Now, it is 2022 and developers have a lot of choices in how to build for desktop. Based on who you talk to, the plethora of technologies and choices is either liberating or daunting. At the end of the day, it may come down to developer experiences and what else you are building so as to better share code.

Let’s explore technology stacks for desktop apps—with the lens of three types of developers and how Indian bread may be served.

Traditionalist

Builds for desktop as it was meant to be. Uses native tooling. Targets one platform.

Traditionalist 

WinForms

Launched in 2002 with .NET 1.0, Windows Forms is one of the oldest Windows desktop technologies—surprisingly still going strong. Part of WinForms’ success is simplicity of tooling, high developer productivity and a rich tooling ecosystem. Modern-day WinForms apps on Windows can run on the latest .NET runtimes, have robust UI and full access to the latest Windows APIs.

WPF

Windows Presentation Foundation was introduced in 2006 with .NET 3.0 as a Windows desktop technology—and also ushered in a UI stack defined in Extensible Application Markup Language (XAML) that could be separated from business logic. Not surprisingly, WPF runs on the latest .NET runtimes and is still going strong, while boasting a rich developer ecosystem. Modern-day WPF apps have deep system integration and the latest touch/inking support, and exude in modern UX. Albeit with a little learning curve, WPF enables developers to be productive and offers a platter of rich tooling.

UWP

As .NET evolved with modern languages like C#/VB/F#, the trend of combining .NET with XAML for UI markup continued in Windows 8 and Windows 10. Modern times call for a variety of Windows device form factors—tablets, computers, 2-in-1s, HoloLens, Surface Hub, XBox, IoT and more. Universal Windows Platform promised to unite the developer experience to build for all Windows devices with adaptive UI and have apps be available through the Microsoft Store.

Subsequent developments like the Desktop Bridge allowed developers to package up their older Win32 apps in a UWP container to publish to the Store and be able to embed modern UWP UI in other Windows desktop apps through XAML Islands. While the original UWP vision may have evolved, the underpinnings of a native runtime and decoupled API access layers serve Windows apps well today.

AppKit/Cocoa

Want to build native desktop apps for macOS? AppKit is your friend—defining all the objects you need to implement the UI components that make a macOS app and the details to efficiently draw on screen. AppKit is baked into Cocoa—the Objective-C API framework for macOS—but AppKit can also be used from SwiftUI. With modern tooling in XCode, building for the macOS desktop is just another target in addition to iOS and other Apple platforms.

Reformist

Builds for desktop while being future-facing. Aware of cross-platform needs. Wants code sharing.

Reformist 

WinUI 3

The Windows UI Library (WinUI) is a native user experience (UX) framework for both Windows desktop and UWP applications. And WinUI 3 is the next-generation native Windows UI stack that is decoupled from Windows 10 and incorporates Fluent Design System into all experiences for consistent, intuitive and accessible UX. WinUI 3 provides developers with the latest tooling and support for both desktop and UWP apps. The Windows App SDK provides a unified set of APIs and tools that can be used in a consistent way by any desktop app on a broad set of target Windows 10 and later OS versions.

Mac Catalyst

Turns out, most developers want to build for iOS, relegating native macOS development catering to a niche audience. Apple wants to fix that with Mac Catalyst—enabling iOS, in particular iPad apps, to run seamlessly on macOS. Mac and iPad apps can now share the same project/source code with XCode. There is seamless mapping between AppKit and UIkit, with visual interface optimized for touch on iOS and keyboard/mouse on macOS.

Flutter

Flutter has been gaining popularity for cross-platform mobile development—write code in Dart and paint pixels onscreen with widgets. Flutter can now be used to make cross-platform apps targeting desktop—the Flutter engine can render UI for Windows, Linux or macOS. While desktop support for Flutter is still in beta, developers can target Windows UWP, macOS and Linux from a single codebase, and be able to add desktop support to existing Flutter apps.

.NET MAUI Desktop

For .NET developers, Xamarin.Forms has long been one of the easiest ways to make cross-platform apps—but Xamarin.Forms mostly catered to mobile platforms of iOS/Android. While there were Xamarin.Forms renderers targeting desktop, developers did not have a lot of confidence targeting desktop. That changes with the evolution of Xamarin.Forms into .NET MAUI.

Along with iOS/Android, .NET MAUI has full support for desktop platforms—both Windows and macOS. What inspires developer confidence in .NET MAUI is the fact that desktop platform support is a first-class citizen with polished tooling and shared app architectures from a single VS project. And instead of reinventing the wheel, .NET MAUI choses to render native UI on desktop through two well-accepted technologies—WinUI 3 for Windows and Mac Catalyst for macOS.

Uno Platform

For .NET developers really wanting to go cross-platform with “Windows” XAML markup, Uno Platform presents a nice open-source alternative. With the goal of taking WinUI everywhere, Uno Platform can power desktop apps on Windows, macOS and Linux—all from a single codebase of C# and XAML and preferred IDE.

Avalonia

Touted as the .NET XAML Framework, Avalonia presents another open-source option with XAML-based renderers that can power apps on desktop platforms—Windows, macOS and Linux.

Hipster

Builds for desktop with non-desktop things. Argues the web is ubiquitous.

Hipster 

Electron

The desire to see web apps running on desktop is nothing new. Enter the most ubiquitous solution for such needs—Electron. ElectronJS is an open-source project to build cross-platform apps with web technologies and can target any desktop—Windows, Mac OS and Linux.

Many of the most heavily used desktop apps are essentially web apps wrapped inside the Electron shell, like Visual Studio Code, Microsoft Teams, Slack and Figma.

Electron has been around for a while and gains credibility from a strong developer community/ecosystem. Most modern web apps written with JavaScript SPA frameworks or with .NET/Blazor can be powering desktop solutions with Electron. At the core of Electron’s benefits as a shell to host web apps is the idea of a stable and predictable environment.

To that end, every Electron app comes bundled with two things that provide dependability—its own copy of Chromium engine for rendering consistency and the Node.js runtime. While developers should watch their app size/memory footprint, Electron is battle-tested and provides developers extensive APIs for deep native desktop integration.

Blazor Hybrid

If one assumes a stable computing environment and the presence of a modern browser today, perhaps web apps can be hosted on desktop with lightweight WebViews—thus creating a smaller footprint and making it easier to bootstrap apps.

With Blazor, developers get to build modern web apps with C#/.NET, running on server or fully client-side through WebAssembly. Blazor is very popular with modern .NET developers and the desire to see Blazor power desktop solutions is only natural.

With .NET 6, .NET MAUI can provide the perfect bootstrapping to enable Blazor hybrid apps to run on desktop through modern WebViews—WebView 2 on Windows and WKWebView on macOS. Blazor can be used to build truly native or hybrid cross-platform apps, thus inviting .NET web developers into desktop land. The familiarity of the Blazor component model, the Razor rendering engine, CSS styling and extensibility can now be applied toward building desktop apps, all the while sharing code with web.

A Bright Future

Like it or not, desktop is here to stay. Desktop apps will continue to power lots of enterprise workflows, and developers will have to build solutions for Windows/MacOS/Linux desktops. The good news is there are lots of choices as to how one arrives at desktop—traditional desktop technologies coexist happily with web or cross-platform solutions, thus enabling more code sharing. Like a good parent, desktop does not judge—come as you may. And good bread is good bread—no matter how you serve it.


SamBasu
About the Author

Sam Basu

Sam Basu is a technologist, author, speaker, Microsoft MVP, gadget-lover and Progress Developer Advocate for Telerik products. With a long developer background, he now spends much of his time advocating modern web/mobile/cloud development platforms on Microsoft/Telerik technology stacks. His spare times call for travel, fast cars, cricket and culinary adventures with the family. You can find him on the internet.

Related Posts

Comments

Comments are disabled in preview mode.