No, Your UI Is Not Native

It have become a trend recently to rewrite Electron user interfaces into other, more performant UI frameworks, such as GPUI. This trend is long overdue and is welcomed by what it seems like almost everyone. But I think this trend, in addition to other factors, have diluted the meaning of “native UI”. Not every GUI program that is written in Rust / Go is a native UI, in fact, most of them aren’t.

But first, what do I claim that native UI actually means? I think that native UI should be kept reserved for programs that have used the desktop environment framework, meant for user interfaces. In the case of Windows I think it’s currently WinUI, but before that were WPF, WinForms and more. In the case of MacOS, the current recommendation is SwiftUI. In the case of Linux, it’s more fragmented but GTK+ and QT cover almost all of the usage.

The other usage of the phrase native UI, is any UI framework that is written in a language that is eventually compiled to machine code, as opposed to an interpreted or JITed language1. That distinction is a bit weird, since HTML and CSS are almost always implemented in a native programming language, like C++ or Rust. Some would say that using a markup is not native language, so does it mean that GTK+ (written in C) is not native because it can use declarative XML for its windows? Others would say that JavaScript is the problem, but believe me that even without JavaScript the rendering of a web page will be much slower and heavier than a proper GUI toolkit.

I think this dilution is rooted in the coupling of two separate problems that arose from Electron. The first problem, that is in counter to my definition of native UI, is that Electron programs do not feel at home with the rest of the environment. Each desktop environment have a HIG and patterns that programs should follow, but they are different in each environment, so Electron will almost always feel out of place. The second problem, that is in counter to the new usage of native UI, is that Electron programs are slow and a memory hog. That is because Electron uses a document viewer with a lot of legacy as its GUI toolkit. Sure, the JavaScript on top does not make it better, but JavaScript is not what will make Electron fast or slow.

So there are two ways to think about native UI and it seems that one is becoming more popular. My problem with that, beside the confusion, is that native UI as compiled to machine code doesn’t really have a proper definition and doesn’t convey any meaningful meaning. A native UI in that sense can be fast (GPUI, QT etc.) and slow (HTML, GPUI with no GPU). The same code can be native (Java AOT) and non-native (Java JITed). The other meaning of native UI have a very clear definition, aside of bespoke Linux systems. It feels like the open source definition all over again, where people that don’t care suddenly think that every code dump on GitHub is open source.


  1. Some languages can be either compiled or JITed so that distinction is a bit fluid. ↩︎