How do you write a proper cross-platform app?
Forum rules
The Off-Topic area is a general community discussion and chat area with special rules of engagement.
Enter, read and post at your own risk. You have been warned!
While our staff will try to guide the herd into sensible directions, this board is a mostly unrestricted zone where almost anything can be discussed, including matters not directly related to the project, technology or similar adjacent topics.
We do, however, require that you:
Please do exercise some common sense. How you act here will inevitably influence how you are treated elsewhere.
The Off-Topic area is a general community discussion and chat area with special rules of engagement.
Enter, read and post at your own risk. You have been warned!
While our staff will try to guide the herd into sensible directions, this board is a mostly unrestricted zone where almost anything can be discussed, including matters not directly related to the project, technology or similar adjacent topics.
We do, however, require that you:
- Do not post anything pornographic.
- Do not post hate speech in the traditional sense of the term.
- Do not post content that is illegal (including links to protected software, cracks, etc.)
- Do not post commercial advertisements, SEO links or SPAM posts.
Please do exercise some common sense. How you act here will inevitably influence how you are treated elsewhere.
-
- Moon lover
- Posts: 77
- Joined: 2020-12-10, 18:46
How do you write a proper cross-platform app?
Compiling something for Windows, MacOS or Linux is easy, but supporting android, iOS and the web too seems difficult.
I think the best answer is that you don't, but creating a separate application for mobile, web and desktop is time consuming.
Electron is just a way for WebApps to force everybody to use embedded Chromium, so compiling native code to Webassembly and running it in the browser or a runtime looks like the best option. Or are there any great Cross-platform Toolkits and Frameworks that I'm not aware of?
I think the best answer is that you don't, but creating a separate application for mobile, web and desktop is time consuming.
Electron is just a way for WebApps to force everybody to use embedded Chromium, so compiling native code to Webassembly and running it in the browser or a runtime looks like the best option. Or are there any great Cross-platform Toolkits and Frameworks that I'm not aware of?
-
- Moonbather
- Posts: 50
- Joined: 2020-09-01, 15:19
Re: How do you write a proper cross-platform app?
Mono and .NET are pretty nice options.
-
- Pale Moon guru
- Posts: 37762
- Joined: 2011-08-28, 17:27
- Location: Motala, SE
Re: How do you write a proper cross-platform app?
If you want to write a fully cross-platform "app" then you're going to be limited to very high level languages by definition. Transpiling is a crutch. While it may work relatively well, it's going to inevitably run into issues of some sort.
So you'll have to focus on things like java, html+js+webengine, XUL+UXP+js, or cross-platform things like rapid application builders with native OS support on your targets.
By definition you can't do more than basic GUI design since you can't rely on os-specific native controls. Alternatively you make your own UI and widgets like XUL allows.
So you'll have to focus on things like java, html+js+webengine, XUL+UXP+js, or cross-platform things like rapid application builders with native OS support on your targets.
By definition you can't do more than basic GUI design since you can't rely on os-specific native controls. Alternatively you make your own UI and widgets like XUL allows.
"A dead end street is a place to turn around and go into a new direction" - Anonymous
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
-
- Knows the dark side
- Posts: 5605
- Joined: 2015-12-09, 15:45
Re: How do you write a proper cross-platform app?
Cross platform apps just end up being shitty to use everywhere, as seen with Electron, the most popular framework for them. In my experience, Qt framework apps are the best at offering native look and feel compatibility on all platforms.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX
Jabber: moonbat@hot-chili.net

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX
Jabber: moonbat@hot-chili.net
Re: How do you write a proper cross-platform app?
"Give to Wintel what is Wintel's, give to ARMdroid what is ARMdroid's"
Or use a scripting solution with HTML.
Or use a scripting solution with HTML.
-
- Knows the dark side
- Posts: 5605
- Joined: 2015-12-09, 15:45
Re: How do you write a proper cross-platform app?
That's what they're doing currently, resulting in a shitty app that doesn't follow any platform conventions beyond the obvious target of mobile touchscreen. At this point one has to ask why even bother calling it cross platform. I had this issue with web based applications long before smartphones for the same reason - every website has its own design and layout and navigation style unlike a regular desktop application.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX
Jabber: moonbat@hot-chili.net

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX
Jabber: moonbat@hot-chili.net
-
- Moon lover
- Posts: 77
- Joined: 2020-12-10, 18:46
Re: How do you write a proper cross-platform app?
Couldn't this just be solved by detecting what the OS is? On Windows and MacOS, imitating the default style can't be that hard.
On linux, only the Desktop Enviroment matters. If it's KDE, imitate QT, else imitate GTK.
On linux, only the Desktop Enviroment matters. If it's KDE, imitate QT, else imitate GTK.
-
- Pale Moon guru
- Posts: 37762
- Joined: 2011-08-28, 17:27
- Location: Motala, SE
Re: How do you write a proper cross-platform app?

have a look at different versions of Windows and MacOS X and how the "default style" is different in pretty much every iteration...
Same with Linux.. Imitate GTK... 2? 3? 4?
"A dead end street is a place to turn around and go into a new direction" - Anonymous
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
-
- Contributing developer
- Posts: 1612
- Joined: 2018-10-28, 19:56
- Location: Georgia
Re: How do you write a proper cross-platform app?
You could, but you would have to write a separate theme for every version of the OS that changed the default styling. So you'd need a Windows 7 theme, a Windows 8 theme, a Windows 10 theme, and a Windows 11 theme for Windows. Plus you'd want to detect any changes the user made to the default theme to try and match them. It's not so much that you can't do that, as that you would be reinventing the wheel by doing that instead of tapping into the default way of using the OS native styling. It would ultimately be more work than keeping up with the changes required to keep using the native styling on various platforms.leothetechguy wrote: ↑2022-08-01, 17:00Couldn't this just be solved by detecting what the OS is? On Windows and MacOS, imitating the default style can't be that hard.
Linux is actually the worst platform on this front. At least with Windows and Mac, there is a native system styling to tap into that you can be sure will look good. On Linux, there is no guarantee the user is using KDE (Qt) or GNOME (GTK). They could using Enlightenment, Motif, or just about anything really. Even if they are using GTK, you don't know if they're using GTK2, GTK3, or even something newer.On linux, only the Desktop Enviroment matters. If it's KDE, imitate QT, else imitate GTK.
What our platform does (I'm not a fan of this approach, we inherited it, and I would not recommend it), is it just assumes that if the user is on Linux or any other platform that uses X11, it should use GTK styling. It actually makes some fairly GNOME 2-centric assumptions that are somewhat applicable to forks like MATE. It uses libcanberra for the "system" sound effects, for instance. The only reason UXP-based apps don't look terrible on KDE is because most distros that use KDE have to install some version of GTK and apply a default theme that doesn't look terrible against whatever the default KDE theme is. This is because there are a ton of GTK apps with no Qt versions, and GNOME was historically treated as a sort of "standard" on Linux, even though there really is no consistent standard and GNOME/GTK changes all the time anyway without regard to backwards compatibility.
Off-topic:
I used early versions of KDE, and I kept finding that all the applications I wanted to use were written against GTK and looked awful on KDE as a result. In general, Linux users often have to deal with having a patchwork of applications that use different frameworks and never having anything look native anyway. It's the price they pay for having as much freedom as they do, and they are pretty much used to it. It's really Windows and Mac users that find an inconsistent user interface jarring. In practice, developers can pick GTK or Qt for Linux, then shrug and tell those users using the other one who aren't happy with the decision to be happy Linux is supported at all.
Interestingly, you could absolutely use Qt or GTK on Windows and Mac if you wanted to, and just have one toolkit for your application that way. I have even used a few GTK/Qt applications on Windows and they don't look too bad. But most Windows and Mac users wouldn't stand for that... because they are used to having applications target the OS native toolkit and would view anything else as broken. Linux users have to be more tolerant of things not matching the moment they go outside of what their distro gives them by default.
I used early versions of KDE, and I kept finding that all the applications I wanted to use were written against GTK and looked awful on KDE as a result. In general, Linux users often have to deal with having a patchwork of applications that use different frameworks and never having anything look native anyway. It's the price they pay for having as much freedom as they do, and they are pretty much used to it. It's really Windows and Mac users that find an inconsistent user interface jarring. In practice, developers can pick GTK or Qt for Linux, then shrug and tell those users using the other one who aren't happy with the decision to be happy Linux is supported at all.
Interestingly, you could absolutely use Qt or GTK on Windows and Mac if you wanted to, and just have one toolkit for your application that way. I have even used a few GTK/Qt applications on Windows and they don't look too bad. But most Windows and Mac users wouldn't stand for that... because they are used to having applications target the OS native toolkit and would view anything else as broken. Linux users have to be more tolerant of things not matching the moment they go outside of what their distro gives them by default.
"The Athenians, however, represent the unity of these opposites; in them, mind or spirit has emerged from the Theban subjectivity without losing itself in the Spartan objectivity of ethical life. With the Athenians, the rights of the State and of the individual found as perfect a union as was possible at all at the level of the Greek spirit." -- Hegel's philosophy of Mind
-
- Moon Magic practitioner
- Posts: 2415
- Joined: 2018-05-05, 13:29
Re: How do you write a proper cross-platform app?
Off-topic:
In theory, the Linux (not UNIX or BSD) approach would be to have an initial toolkit like GTK and then one or more community-backed alternatives that can be chosen before compiling with the configure script.
Nobody does it except a handful of small-to-medium projects because it's not easy to manage especially as new features are introduced, but the "bazaar" model that Linux taught us would work like that.
In theory, the Linux (not UNIX or BSD) approach would be to have an initial toolkit like GTK and then one or more community-backed alternatives that can be chosen before compiling with the configure script.
Nobody does it except a handful of small-to-medium projects because it's not easy to manage especially as new features are introduced, but the "bazaar" model that Linux taught us would work like that.
-
- Lunatic
- Posts: 355
- Joined: 2016-03-19, 23:24
Re: How do you write a proper cross-platform app?
Off-topic:
Extra padding was added to gtk3 and gtk4 for touch devices - luckily it's CSS so theme makers can make normal themes. I think the Gnome 2 design fits in everywhere, because it's unintrusive and desktop centric. If you really want big padding a gtk3 theme can add that.
This is why Pale Moon looks so good no matter if you use the gtk2 or gtk3 version. There is nothing oversized about Pale Moon unlike the default Adwaita theme for gtk3. Pale Moon only becomes oversized if you apply an oversized gtk3 theme.athenian200 wrote: ↑2022-08-02, 07:53It actually makes some fairly GNOME 2-centric assumptions that are somewhat applicable to forks like MATE.
Extra padding was added to gtk3 and gtk4 for touch devices - luckily it's CSS so theme makers can make normal themes. I think the Gnome 2 design fits in everywhere, because it's unintrusive and desktop centric. If you really want big padding a gtk3 theme can add that.