Hacker News new | ask | show | jobs
by riceart 1125 days ago
> Something that isn't talked about much in the GUI world (outside of mobile development) is how essential multi-threading is to a great application experience.

Yes it is. Heavyweight desktop GUI applications like DAWs or CAD or image/video editing are old established technology.

> This has the advantage of a project feeling natural to the platform while still allowing for code reuse between platforms

Having written cross platform native applications: This is a pain in the ass to do well - and there isn’t a particular reason this hasn’t been doable in C/C++ since forever - Rust isn’t some silver bullet. “Abstracting” away the native GUI/UX seems to be a common pitfall for junior devs - how hard can it be they think - then they learn why Qt exists.

> It's not too far from the write-once-run-everywhere philosophy of React native, Electron and similar.

Electron is about as far removed from the philosophy of targeting platform native toolkits as one can get.

2 comments

> Rust isn't some silver bullet

Rust codebases extend in size and scale to larger teams fundamentally better than C++ / C. Rust offers more leverage in building ambitious system software.

Since you mention Qt, imagine writing all of Qt in x86 assembly, vs. C++. "There's not particular reason this isn't doable." C++ to Rust is a similar jump. No silver bullets; just leverage.

Cross-platform toolkits — especially those aiming to abstract over native UI/UX patterns — are an ambitious, if not Sisyphean domain. Qt was about the best we could do in the C++ era, but a new era has dawned.

> Qt was about the best we could do in the C++ era, but a new era has dawned.

Based on the way the Rust community has been spinning its wheels for years in getting something even within a light year of feature parity with Qt, if a new era has truly dawned you might need to wait for the next one.

> Rust codebases extend in size and scale to larger teams fundamentally better than C++ / C. Rust offers more leverage in building ambitious system software.

I like Rust - but this is classic RSF/RIIR copypasta.

> getting something even within a light year of feature parity with Qt.

Qt is also old as Jesus, and making a cross OS GUI is extremely hard.

And you can non-ironically say the same about non-Qt toolkit written in C++.

What grandparent probably means something that leverages parallelism and/or GPU acceleration.

> And you can non-ironically say the same about non-Qt toolkit written in C++.

Maybe. Gtk and its related libraries don’t cover everything Qt does, but they’re not small either. It’s also fair to include the native toolkits themselves on their respective platforms that are written in a mixture of C++/C/Objective C.

I also will point out that one of the cross platform toolkits with some traction in the Rust world is amusingly fltk.

> What grandparent probably means something that leverages parallelism and/or GPU acceleration.

You mean like QtQuick/QML, skia (basically this is the effective underpinning of electron and flutter) or Dear Imgui, etc. There are a handful of widely used GPU based GUI libraries. The above examples are all C++.

> leverages parallelism

The memory model of Rust is still whatever C++ does. I get that Rust has some nice features and C++ makes it easy to fuck your self but people have been doing large scale parallel software development for years in C++.

> Qt is also old as Jesus, and making a cross OS GUI is extremely hard.

The claim was we are in a new era of “leverage” that will make the hard very easy (that’s what it sounded like at least). I found the claim at best vague and low on specifics or evidence - hence the mention of RESF.

> Maybe. Gtk and its related libraries don’t cover everything Qt does

And therein lies the problem. Qt is semi-open (the parent company tried to close source it[1]). If a commercial company has no interest in maintaining it, there is even less hope for other open source approaches.

Best cross OS system are almost always backed by a commercial supporter. See Skia - Google, Java Swing - Oracle, Qt - QtCompany, etc.

OSS offerings were always runner ups (e.g. Gtk - Gnome).

> The memory model of Rust is still whatever C++ does. I get that Rust has some nice features and C++ makes it easy to fuck your self but people have been doing large scale parallel software development for years in C++.

Memory model of Rust is undefined[2]. It might be anything Rust does to accomodate C++ bindings, but I don't think they really settled on one.

I'd like to add - people have been doing large scale parallel software development for years in C++, in spite of C++. What is a line of comment in C++ in Rust is a type system constraint.

It's a difference between having a seatbelt (Rust) and holding a piece of seatbelt (C++).

Rust was literally made to address C++ shortcomings when it comes to parallelism.

> You mean like QtQuick/QML, skia (basically this is the effective underpinning of electron and flutter) or Dear Imgui, etc. There are a handful of widely used GPU based GUI libraries. The above examples are all C++.

No. I mean like WebRenderer[3], Lyon[4]. Most things should be parallelized and done on GPU/SIMD. Layout, font shaping, etc.

[1]https://news.ycombinator.com/item?id=25656932

[2]https://doc.rust-lang.org/reference/memory-model.html

[3]https://github.com/servo/webrender

[4]https://docs.rs/lyon/latest/lyon/

> No. I mean like WebRenderer[3], Lyon[4]. Most things should be parallelized and done on GPU/SIMD. Layout, font shaping, etc.

https://www.reddit.com/r/rust/comments/vwdxim/announcing_lyo...

https://www.reddit.com/r/rust/comments/vwdxim/announcing_lyo...

Also neither of your examples do any text shaping on the GPU. Lyon doesn’t do text and Webrender (which depends on freetype) does regular old glyph cache built in CPU texture rendering. Neither involve GPU shaping.

https://github.com/servo/webrender/blob/master/wr_glyph_rast...

Still trying to understand what earth-shattering, "leverage" levering feature this brings compared to Skia.

> Memory model of Rust is undefined[2]. It might be anything Rust does to accomodate C++ bindings, but I don't think they really settled on one.

> I'd like to add - people have been doing large scale parallel software development for years in C++, in spite of C++.

Do you not see at least some level of contradiction to these statements?

This is probably the more relevant explanation: https://doc.rust-lang.org/nomicon/atomics.html. "At very least, we can benefit from existing tooling and research around the C/C++ memory model."

Perhaps respect your elders a bit more?

Qt is fully open source. The LTS version is closed source, but other framework don't even have a LTS version.
> Rust codebases extend in size and scale to larger teams fundamentally better than C++ / C

There are about 3-4 orders of magnitude more large C++ projects developed by large teams compared to Rust projects as of now.

This might change in future, but your claim seems a bit premature.

In a previous company I worked at, we were forced to rewrite a greenfield project in C++ because it was going too slow with Rust. The team managed to ship the thing in a few months, compared to spending a month getting nowhere with Rust.

> Qt was about the best we could do in the C++ era, but a new era has dawned.

Nope, the best is C++ Builder with VCL, Visual Basic/Delphi like experience with C++.

However very few have tried it out unless they work for big corporations.

C++ to Rust is not a similar jump as assembly to C++.

Qt may be the best toolkit so far. If Rust is going to let us make a big jump, I can’t wait to see that happen. What are the best contenders so far?

I do have a naive view on native GUI development because I have little real experience in it - I very much appreciate your insight.

> “Abstracting” away the native GUI/UX seems to be a common pitfall for junior devs

I would like to know more about what you mean here; my description of a "virtual UI" that you bind to from the native toolkit is an abstraction to the UI - but it's not an abstraction like Flutter which tries to merge all native widgets into abstracted widgets. My concept still requires you to write multiple native entry points using the UI kits of the target platforms.

` (GTK entry || Cacao entry || Win entry) => Virtual UI => application logic `

The idea is that the virtual UI would be an in-memory representation of the UI (have virtual buttons, labels, etc). It would be the job of the entry to correctly represent/bind to that virtual UI with the relevant presentation tool kit. The output binary would be specialised to the platform/UI kit used in the source entry point.

It seems sensible on the surface to decouple the UI from the native presentation as it minimizes the requirements of the native side to constructing the UI and binding to the virtual UI - but I would love to hear your thoughts.

I have not tested this architecture outside of web development but I imagine adding new UI targets (like web assembly, QT, etc) would be easier as it wouldn't require any changes to the virtual UI or application logic and would be a matter of creating a new entry point representing the UI for the new target.

> then they learn why Qt exists

Does QT feel native on MacOS, Windows and Gnome?

> Yes it is [talked about]

Could be my personal echo chambers talking here - but multithreading is almost never spoken about and/or often intentionally disregarded in modern web/electron applications.

It sucks because so many applications are written using Electron or other similar web wrappers.

> there isn’t a particular reason this hasn’t been doable in C/C++ since forever - Rust isn’t some silver bullet

Not dismissing this, I was more impressed that Rust offers a thread safety guarantee through its ownership model making it interesting from a contributor scalability standpoint.

I was thinking that it might make it easier to have more engineers working on a high performance GUI project because it would be significantly harder to break.

As an example; I could imagine if a company assigned a team of TypeScript/JavaScript developers with different experience levels onto a GUI project written in something like Go, there would be a lot of thread safety issues and seniors would spend a lot of time combing PRs for thread safety issues.

Rust, while perhaps not as simple from a syntax/types/symbols standpoint, offers an interesting development modality for these sorts of projects. I would expect that it would result in a more hands off contributor experience.

> Electron is about as far removed from the philosophy of targeting platform native toolkits as one can get.

Sorry I wasn't describing Electron as targeting platform native decorations - just that it promises an OS agnostic UI framework (write once run anywhere) at the expense of a diminished native experience and poor performance.

My point was that it might be interesting to explore the idea that a multi-entry native toolkit application fulfils the same "write once run 'anywhere'" promise but without the downsides.