5 ms·
Ask HN: Fastest cross-platform GUI stack/strategy
I want to build a cross-platform native app that starts up as fast as possible and responds as fast as possible, and has minimal memory use.
Something that when the rest of someone's computer is slowing down, this can stay responsive.
Not everyone has the fastest hardware or much ram; people like to have 100s of tabs open; and CPU's overheat and throttle, especially laptops.
- 4silvertooth 3y agoGive https://sciter.com/ https://sciter.com/ a try. It's fast and small.
- mikewarot 3y agoLazarus/Free Pascal, I've run the IDE on a Raspberry Pi Zero W, it wasn't anywhere near as fast as I'm used to on a PC, but it got the job done. It makes small compact efficient GUI and command line applications.
- fuzztester 2y agoYup. I've tested it for sizes of the generated binaries, versus C and Go, for a hello world program. C was smallest, next FP, last Go. Both C and FP were under 50 KB, IIRC. Go, much more, in the 1 MB range, IIRC. I have also written a few small CLI and GUI utilities in FP and Lazarus respectively, and it was mostly a breeze. Had fun. If you have Delphi or VB experience, it is very similar, conceptually, so fairly easy to pick up.
- api 2y agoThis is because Go bundles a big runtime in every binary.
- fuzztester 2y agoIs there a way to not do that?
- cookiengineer 2y agoYou can also write allocation free Go, by computing everything on the stack. (Use pprof tool to analyze your code's allocations) If you want smaller binaries without a runtime or GC bundled, you can try out tinygo [1] [1] https://github.com/tinygo-org/tinygo https://github.com/tinygo-org/tinygo
- petabyt 3y agoLinux/Windows/MacOS: https://github.com/libui-ng/libui-ng https://github.com/libui-ng/libui-ng
- cookiengineer 3y agoAlternatively there's also ImGui: https://github.com/ocornut/imgui https://github.com/ocornut/imgui
- valty 3y agoWow 55K GitHub stars. This is like some record.
- toast0 3y agoIf you want the fastest cross-platform native app. Build a native app for each platform and have the design teams review each other's work so everyone stays roughly on the same page. You're not going to hit your responsiveness goals otherwise. And it's not going to feel native otherwise (if anyone actually cares about that anymore, I dunno)
- valty 3y agoWhen I said "stack/strategy", the _strategy_ part implied this build-for-each-platform approach. The question still remains then of which to use for each platform. On macOS there is Cocoa (Swift or ObjC(++) or pure CPP) and Swift UI. On Windows there is .NET C# or CPP and a bunch of other stuff. Any thoughts?
- toast0 2y agoFor Mac, I'm not super in touch, but I get the impression Apple is all in on Swift UI, and their developer support model is clear: use old tech at your peril, it may not be supported in the next version. So I would use Swift UI. For Windows, I think it goes the other way. Microsoft is always coming around with a new UI model that's half-ass and will be dead next year. Use the old ways: MFC will never die.
- hermitcrab 2y agoApple Nuke their entire developer ecosystem from orbit every few years. Using a cross-platform UI like Qt insulates you from this to an extent. But the downside is that you never get it to look quite 100% native and you may not have easy access to the latest bells and whistles from Apple. Microsoft can't seem to make up their mind on what UI platform people should be using. It's a mess. But they generally do support old platform, unlike Apple. I gag at thought of writing MFC code in 2024. But each to their own.
- fuzztester 2y ago>I gag at thought of writing MFC code in 2024. In any year. Could never grok it, when it was newish, what with its crazy opaque AFX macros, although I could somewhat easily understand Win 32 C programming (Petzold book etc.), even though that was lower level, and I was new to event-driven GUI programming then.
- ActorNightly 3y ago>Something that when the rest of someone's computer is slowing down, this can stay responsive. Yeah so without having to overwrite some very deep OS settings, which will likely raise some red flags for your app requiring administrator privilege to run, you aren't going to get this. If someone has a browser thats taking up most resources, its gonna throttle everything. There is generally very little reason to write anything but web apps these days for things that don't need to touch specific hardware. If you stick to as much native js/css/html as possible (i.e avoid large libraries), it will load blazingly fast and use way less resources then web apps that are considered fast.
- valty 3y agoGood point. I would prefer to write in HTML/JS. Vanilla JS is probably the way to go. I think modern frameworks are so bad at perf because they assume people just have so much compute available and are focusing on one app at a time.
- throwaway38375 3y agoI think HTML, CSS, and JS could be the answer here. However it relies on two important things: 1. Using something which uses the OS's built in browser (rather than something like Electron). 2. Keeping your JS very lightweight. This was shared a few days ago, combined with py2app could be a winner: https://github.com/r0x0r/pywebview https://github.com/r0x0r/pywebview
- cookiengineer 2y agoPersonally I'd like to use github.com/webview/webview because they have bindings for a lot of languages (including golang) and use WebkitGTK behind the scenes on e.g. Linux distros. With go you can embed all your assets and serve them on a local network port where the webview points to, which makes this combination ideal for fullscreen/kiosk like applications on older machines. I am currently also trying out to build an opinionated UI library where I want to be able to reuse the defined structs on the client side (using web assembly), which would make interaction between clients and servers much easier. Not sure if I'm gonna be happy with it this way, but a man can only dream!