GUI tools and libraries: native, cross-platform or web¶
Exercise gui-tools-and-libraries-annex.pdf · PDF
Put three windows side by side: VS Code, any web app in your browser, and a grey Java dialog. All three have buttons. Which of them could you have on your phone tonight?
The web app, yes. VS Code is web technology inside, but packaged for the desktop. The grey dialog, never. Last unit you drew your app. Before you build it, you have one decision to make, and it is not a colour: what will draw your buttons?
What you will learn
- Define a GUI toolkit and say what a UI library adds on top of it
- Sort any tool into one of three families by asking one question: what draws the interface?
- Place 15 real tools in those families, with their language and year
- Explain the difference between Electron and Tauri in one sentence
- Choose a toolkit for a brief, and defend the choice with a fact from the brief
- Explain why this course builds with Svelte + Tauri and not with Swing or JavaFX, and what that choice costs
- The trap: why the language you type does not decide the family
Who speaks the language?¶
Keep one picture in your head for the whole page: languages. Every platform (Windows, macOS, Android, iOS, the browser) speaks its own language for drawing windows and buttons. You have three ways to be understood:
| You can... | In a foreign country | On screens |
|---|---|---|
| Be a native speaker | Perfect in one country, useless across the border | You use the platform's own toolkit |
| Travel with an interpreter | You write once, the interpreter speaks for you everywhere | A toolkit carries its own interface layer to each platform |
| Use the lingua franca | The one language every country already understands | HTML + CSS, because every platform ships a browser engine |
You can see the old grey dialog for yourself. If you have a JDK and a graphical session, type jshell in a terminal, then this line:
That window comes from Swing, a Java toolkit from 1998.
Toolkit or library?¶
Two words get mixed up all the time, so let us separate them.
A GUI toolkit is the set of ready-made pieces (windows, buttons, text fields) and the code that draws them and delivers the user's clicks to your program.
A UI library (or UI framework) is code that sits on top of a toolkit and helps you organise your interface into components.
GUI stands for graphical user interface. Svelte, which you will use from Unit 3, is a UI library: it draws nothing by itself.
Careful: the toolkit is not the language
Kotlin is a language; Jetpack Compose is a toolkit. Java is a language; Swing is a toolkit. You can change one without changing the other. The family is decided by what draws, not by what you type.
Three families¶
Here is the whole map. Read the row "Draws with" first: it decides everything else.
| Native | Cross-platform toolkit | Web technology | |
|---|---|---|---|
| Analogy | Native speaker | Interpreter | Lingua franca |
| Draws with | The platform's own toolkit | Its own non-web interface layer, carried to each platform | A browser engine: a tab, or a webview inside a window |
| You write | Swift, Kotlin, C#... | Java, Dart, C#, Kotlin, C++, JavaScript | HTML + CSS + JavaScript |
| Best at | The newest platform features, the platform's exact look | One team, several platforms | Reaching everything; the biggest pool of developers and components |
| The cost | One codebase per platform | You wait for the interpreter to learn each new platform feature | Not the platform's own controls; you depend on the webview |
flowchart TB
Q["<b>What draws the interface?</b>"]
Q -->|"the platform's own toolkit"| N["<b>Native</b><br>the native speaker"]
Q -->|"its own layer, not a browser"| C["<b>Cross-platform toolkit</b><br>the interpreter"]
Q -->|"a browser engine"| W["<b>Web technology</b><br>the lingua franca"]
One new word is hiding in that table.
A webview is a browser engine without the browser around it: no address bar, no tabs, just the part that draws HTML, embedded in an app's window.
Fifteen real tools¶
Now you can place real names. Ask the question for each one: what does it draw with?
| Tool | Language · year | Draws with | Runs on |
|---|---|---|---|
| SwiftUI | Swift · 2019 | Apple's controls | Apple platforms only |
| Jetpack Compose | Kotlin · 1.0 in 2021 | Android's toolkit | Android |
| WPF | C# + XAML · 2006 | Windows' toolkit | Windows only |
| GTK | C · 1.0 in 1998 | The GNOME toolkit | Linux desktops first |
| Swing | Java · 1998 | Its own widgets | Any desktop with a Java Virtual Machine |
| JavaFX | Java · 2008 | Its own widgets | Desktops with a Java Virtual Machine |
| Qt | C++ · 1995 | Its own widgets, styled per system | Desktop, mobile, embedded |
| Flutter | Dart · 1.0 in 2018 | Its own rendering engine | Android, iOS, web, desktop |
| React Native | JavaScript · 2015 | Real native widgets, driven from JavaScript | Android, iOS |
| .NET MAUI | C# + XAML · 2022 | Native controls behind one API | Android, iOS, macOS, Windows |
| Compose Multiplatform | Kotlin · by JetBrains | The Compose engine | Android, iOS, desktop, web |
| Browser app (PWA) | HTML, CSS, JS · term from 2015 | The user's browser | Everywhere |
| Electron | HTML, CSS, JS · 2013 | A Chromium shipped inside each app | Windows, macOS, Linux |
| Tauri | HTML, CSS, JS + Rust · 1.0 in 2022, 2.0 in 2024 | The system's webview | Desktop; Android and iOS since 2.0 |
| Svelte | A compiler · 2016, Svelte 5 in 2024 | Nothing by itself: it outputs HTML, CSS and JS | Needs a host |
The first four are native. The next seven are cross-platform toolkits. The last four are web technology. A PWA (progressive web app) is a web app that a browser can install and run like an ordinary app.
Some of these are worth arguing about, and the arguments teach you more than the table:
| Tool | The question | The answer |
|---|---|---|
| Swing | "It is real Java on my PC, so it is native?" | No. It paints its own buttons on any desktop with a Java Virtual Machine. That is why the grey dialog looks the same on Windows and on Linux, and like neither. |
| React Native | "It is JavaScript, so it is a website in an app?" | No. There is no HTML at all: JavaScript gives orders to real native buttons. It is an interpreter. |
| Svelte | "Is it like Tauri?" | No. Svelte builds the page, and Tauri gives the page a window. Svelte counts as web technology, but it is a library, not a toolkit. |
| GTK | "It also runs on Windows and macOS. Cross-platform?" | You can defend that. Its home is the Linux desktop, so we file it as native. |
| Qt | "It looks like each system. Native?" | It imitates each system's look, but paints the widgets itself. |
Careful: native does not mean fast
"Native means fast, web means slow" is a myth. Native means the platform's own toolkit. A notes app is fast in all three families. A 3D game is another story.
Electron or Tauri?¶
Both put web technology in a desktop window. The difference is what they pack.
| Electron | Tauri | |
|---|---|---|
| The engine | Ships its own Chromium inside every app | Uses the webview the system already has |
| Empty app | On the order of 100 MB | As little as 600 KB, according to its own site |
| Same engine everywhere? | Yes: your Chromium | No: WebView2 on Windows, WKWebView on macOS and iOS, WebKitGTK on Linux, the system WebView on Android |
| You must... | Accept the weight | Test on each system |
| Famous users | VS Code, Slack, Discord, the Figma desktop app |
Same idea, opposite packing: Electron carries a browser, Tauri borrows one.
Electron started in 2013 under the name Atom Shell. Tauri reached 1.0 in June 2022, and 2.0 on 2 October 2024 added Android and iOS.
Choosing: a reason needs a fact¶
"Because it is better" is not a reason. A real reason quotes a number or a platform from the brief. Look at how the fact decides in each of these:
| The brief | A good choice | The fact that decides |
|---|---|---|
| A ticket reader that only runs on one model of Android device, and needs the newest camera features | Native: Jetpack Compose | One platform, and the newest features: only the native speaker has them on day one |
| A timetable app for phones and the browser, with one developer | Web technology, or Flutter | Several targets and one person: one codebase is the only way |
| A desktop tool for old laptops, with 4 GB of RAM and a small download | Tauri | Carrying a whole Chromium in each app is what those numbers rule out |
Often the fastest step is to rule a family out. "My app must run on Android phones and in the browser, so native is out: I would need two codebases." That is a complete, defensible sentence. Write one like it for your own project.
Looking the same everywhere is not automatically better
If an app looks the same on every system, it looks native on none of them. In Apple's Human Interface Guidelines you saw that each platform has its own highway code. Cross-platform is a trade, not a prize.
Why Svelte + Tauri here?¶
You learned Java last year. So why are we not building the interface in Swing or JavaFX? It is a fair question, so here is an honest comparison.
| Swing / JavaFX | Svelte + Tauri | |
|---|---|---|
| Born | 1998 / 2008. JavaFX left the JDK with Java 11 (2018) and lives on as OpenJFX | Svelte 2016, Svelte 5 in October 2024. Tauri 1.0 in 2022, 2.0 in October 2024 |
| Reaches | Desktops with a Java runtime. No phone, no browser | Browser, Windows, macOS, Linux; Android and iOS since Tauri 2.0 |
| From your Figma file | Nothing carries over: you rebuild every measure by hand | Figma speaks CSS, and your variables become CSS variables |
| Styling | Look-and-feel classes; JavaFX has its own CSS dialect | Real CSS: the same you can inspect in any website |
| What it costs | Nothing new to learn in the language | A new set of languages (HTML, CSS, JavaScript), and webview differences between systems |
We are not saying Java is dead. It runs a huge share of the world's servers. What aged is its desktop toolkits. We are choosing the one family where your design file, your code and every screen your users own speak the same language.
Key takeaways¶
- A GUI toolkit provides the pieces and draws them. A UI library such as Svelte organises your interface on top, and draws nothing by itself.
- The family is decided by what draws, not by the language: native (the platform's toolkit), cross-platform toolkit (its own layer), web technology (a browser engine).
- A webview is a browser engine with no browser around it.
- Electron carries its own Chromium in each app. Tauri borrows the system's webview, so it is small but you test on each system.
- A good choice of toolkit quotes a number or a platform from the brief.
- This course uses Svelte + Tauri because design file, code and screens share one language. The cost is learning HTML, CSS and JavaScript.
Quick check¶
1. What is the difference between a GUI toolkit and a UI library?
- A toolkit draws the pieces and delivers clicks; a library organises your interface on top
- A toolkit organises your interface on top; a library draws the pieces and delivers clicks
- A toolkit only runs on desktops; a library only runs in a browser window
- A toolkit is written in Java; a library is written in JavaScript or in Rust
A GUI toolkit is the set of ready-made pieces and the code that draws them and passes clicks to your program. A UI library helps you organise those pieces into components. Svelte is a library: it draws nothing by itself.
2. Which question decides the family of a tool?
- What draws the interface?
- What language do you write?
- What year was it released?
- How large is the download?
Java is a language, and Swing is a toolkit. Kotlin can sit behind a native toolkit or a cross-platform one. The language does not decide the family: what draws does.
3. Why is Swing not a native toolkit?
- It paints its own widgets on any desktop with a Java Virtual Machine
- It draws its widgets with a browser engine inside each desktop window
- It sends its widgets to the system's toolkit through a JavaScript layer
- It only works on one operating system and on no other desktop at all
Swing is an interpreter: a cross-platform toolkit, for desktops only. It paints its own buttons, which is why its dialog looks the same on Windows and on Linux, and like neither.
4. What is a webview?
- A browser engine with no address bar or tabs, embedded in an app's window
- A website that has been saved to disk so that it can be read with no network
- A native toolkit control that shows a preview of the page behind a link
- A browser extension that resizes a page to fit the screen of a phone
A webview is only the part of a browser that draws HTML. Electron ships its own, and Tauri uses the one the operating system already has.
5. What is the main difference between Electron and Tauri?
- Electron ships its own Chromium in every app; Tauri uses the system's webview
- Electron uses the system's webview; Tauri ships its own Chromium in every app
- Electron draws native controls from Java; Tauri draws its own widgets from Dart
- Electron only runs on phones; Tauri only runs on desktop operating systems
Same idea, opposite packing. Electron carries a browser, so even an empty app weighs on the order of 100 MB. Tauri borrows one, so it is much smaller, but your app is drawn by a different engine on each system and you must test on each.
6. React Native lets you write JavaScript. Which family does it belong to, and why?
- Cross-platform toolkit, because JavaScript drives real native widgets with no HTML
- Web technology, because JavaScript always needs a browser engine to draw with
- Native, because each platform ships React Native as its own standard toolkit
- None of the families, because it is a UI library that draws nothing by itself
Do not look at the language: look at what draws. React Native has no HTML: JavaScript gives orders to real native buttons, so it is an interpreter.
7. A vending machine company wants a screen app that will only ever run on one model of Android board, which it builds itself. Which argument stops being useful?
- One codebase for many platforms, because here there is only one platform
- Keyboard access, because a screen on a machine is not able to use a keyboard
- Contrast, because the machine sits in a well lit corridor all through the day
- Testing, because a webview behaves in the same way on every operating system
The main argument for cross-platform is one team, several platforms. With a single platform on controlled hardware, that argument disappears, so a native toolkit such as Jetpack Compose becomes a real option. You would still have to defend your choice with a fact from the brief.
8. What does this course pay for choosing Svelte + Tauri over Swing or JavaFX?
- A new set of languages, plus webview differences between systems
- A paid licence, plus a separate codebase for each operating system
- A loss of CSS, plus a need to rebuild every Figma measure by hand
- A loss of desktop apps, plus a limit of one browser on each machine
You learn HTML, CSS and JavaScript, and Tauri's system webviews differ between systems, so you test on each. In return you reach the browser, the desktop and the phone, and your Figma variables carry over as CSS variables.
You know what can draw an interface. Next you try a tool that draws one for you and puts it on the internet: Framer: the canvas is the website.