Repository navigation
Description
It has been bugging me for a long time that our backends are kinda wrongly named: They are named after the OS / platform that they target, instead of the API that they use.
This is a bit incorrect though, because a lot of APIs can be used on other platforms than their primary one. The most erregious case here is probably UIKit, which is used on three of Apple's platforms, mostly iOS, but increasingly visionOS and tvOS too. And with Mac Catalyst in recent times, it can even be used natively on macOS as well. Another example is that there exist projects like GNUStep that tries to bring AppKit to Linux platforms, and I think even Wayland can be used on macOS (?).
So many of the names in winit::platform::* are effectively false. I've tried to improve it a bit in #3756, but that only resolved the iOS/UIKit discrepancy - the Android backend, for example, should probably be called the NDK backend, as Android could technically run other backends as well (Wayland on Android any1?). Similarly, other platforms could target the NDK.
This becomes important now with #3433, since with that we'll kind of be locked into specific names (since we'll be releasing crates). So I've put this in the milestone to be figured out before the release.
See the table below for an overview of the naming scheme (with a few imaginary backends thrown in there for a broader context):
| OS/Platform | Backend / Actual API | Name after platform | Name after API |
|---|---|---|---|
| Android | NDK | winit-android |
winit-ndk |
| iOS/visionOS/tvOS/Mac Catalyst | UIKit / Cocoa Touch | winit-ios ? |
winit-uikit |
| macOS | AppKit / Cocoa | winit-macos |
winit-appkit |
| watchOS | WatchKit | winit-watchos |
winit-watchkit |
| Redox | Orbital | winit-redox |
winit-orbital |
| Many (predominantly unixes) | Wayland | ? | winit-wayland |
| Many (predominantly unixes) | X11 | ? | winit-x11 |
| Web | Web | winit-web |
winit-web |
| Windows | Win32 | winit-windows |
winit-win32 |
| Windows | WinRT | winit-windows |
winit-winrt |
| Many | GTK | ? | winit-gtk |
| All | Terminal | ? | winit-terminal |
| OpenHarmony / OHOS | ? | winit-ohos |
winit-? |
Only problem is, clearly "Android", "iOS" and "macOS" are more discoverable and understandable terms than "NDK", "UIKit" and "AppKit". So maybe favouring consistency and correctness here is the wrong choice?
For a bit of prior art, GLFW uses "Cocoa", "Win32", "X11" and "Wayland" (API names). The SDL uses "Android", "Cocoa", "Windows", "Wayland", "UIKit" (bit of both). raw-window-handle uses API names.
Activity
kchibisov commentedon May 21, 2025
should be after the API in general, yes, naming with any other name doesn't make much sense.
madsmtm commentedon May 21, 2025
Do you have a preference between "Cocoa"/"Cocoa Touch" and "AppKit"/"UIKit"?
Cocoa is kinda the legacy name, it's the union between the Foundation, AppKit and CoreData frameworks. I guess AppKit is more precise, since Cocoa refers to more things (e.g. the desktop environment itself). But on the other hand, StackOverflow has almost 40k questions tagged "cocoa", while only 1,5k tagged "appkit", so perhaps Cocoa might be more readily understood by users?
I think my preference is AppKit, but maybe you/others have more insight?
kchibisov commentedon May 21, 2025
I usually don't.
AppKit/UiKitis more clear nowadays.I'm not sure about
Androidthough, since if backend combines multiple providers then justandroidcould be fine.madsmtm commentedon May 21, 2025
@MarijnS95 what's your preference on Android backend naming?
winit-ndkorwinit-android?MarijnS95 commentedon May 21, 2025
Naming the Android backend
winit-ndkwould imply limiting the backend to using just NDK primitives I think. I.e. that'd be theandroid-activity/native-activitybackend/feature, somewhat ruling outandroid-activity/game-activity(which still utilizes a bunch of NDK primitives since they're wrappers over or underlying implementations of standard Android Java components). The latter is provided by a separate Android JetPack package that build systems need to pick up (IIRC).The
android-activitycrate abstracts both features behind a common interface (which also provides shared NDK wrapper objects and concepts). Perhapswinit-android-activity, or is that too long?At the same time a new
android-viewcrate is currently being developed and perhaps proposed soon, which I don't know if it's going to replace "our Androidwinitbackend" or just be a completely new one. Given that it's going to be a completely different approach with its own drawbacks and features, a separate backend seems preferable.Here's my amends to the table to represent this:
NativeActivitywinit-androidwinit-(-android)-ndkGameActivitywinit-androidwinit-agdk1?android-viewwinit-androidFootnotes
https://developer.android.com/games/agdk ↩
https://developer.android.com/reference/android/view/View ↩
madsmtm commentedon May 21, 2025
Hmm.
android-viewis also using the NDK, right? They're all just different activities?I guess I disagree with that comment, I'd like to avoid that we provide different Winit backends for what is essentially the same overarching APIs. So while I wouldn't say
winit-android-activityis too long, it does seems to tie us to a specific crate, which I'd like to avoid. E.g. I didn't call the AppKit backendwinit-objc2-app-kit.But maybe there are benefits here that I'm not yet seeing?
CC @rib @mwcampbell, WDYT?
MarijnS95 commentedon May 21, 2025
Opening that repo, there's immediately some
gradlefiles. Meanwhile, NDK -> Native Development Kit -> only Native (C) code/bindings that can be called from Rust, no complicated (Java-tailored) build systems needed.Besides that, the NDK doesn't have a
Viewrepresentation that I know of. Only the backingSurfacebut that's "limited" to rendering / presentation.However, I do think (and this was my 3+-year-old idea for a
RustActivity) that any Java they need could possibly be precompiled and provided with the crate, leaving us to never need special/complicated build tools when I finally PR my "merge compiled Java-ish sources into aclasses.dexand embed into the APK" branch tocargo-apkandxbuild.(I digress, let's immediately hide this comment as OT and move this yet-another-Android-backend-design-quest to a separate issue?)
Calling it
winit-androidis preferable if we can merge all 3. At that point it's worth seeing ifandroid-activitycould be(come) the shared abstraction for all of them.madsmtm commentedon May 21, 2025
Okay, let's go with
winit-androidthen.I will move forwards with that, but until we do the actual release, we can always delete the crate again, and go with a different name.
madsmtm commentedon Jun 5, 2025
We discussed this in today's meeting, and decided that we're happy with the current naming (name after API, except for Android), so I'll close this for now.