News for hackers. Stuff that matters.
Re:Emerging Rust GUI libraries in a WASM world by echelon on Thursday April 27, 2023 @01:11AM (#35723556)
Obligatory jaw-dropping egui demo:

https://www.egui.rs/#demo

Egui slaps and is clearly going places.

Re:Emerging Rust GUI libraries in a WASM world by tristanMatthias on Thursday April 27, 2023 @01:38AM (#35723711)
Got this to crash by change the font size in the font book demo.
Re:Emerging Rust GUI libraries in a WASM world by vincnetas on Thursday April 27, 2023 @01:59AM (#35723830)
Trying to copy/paste in safari also crashes the demo.
Re:Emerging Rust GUI libraries in a WASM world by Animats on Thursday April 27, 2023 @01:48AM (#35723758)
"Loading..."

I've run it before. I know what it looks like.

I use egui. It's OK. But you have to code up all your dialog boxes in Rust. This is misery if you have fifty dialog boxes and widgets you need. The widget library is weak and the themes are poor. I don't care, because I'm doing a metaverse client, and all the visuals are in the 3D image. The 2D GUI on top is minimal, as is normal for games. So minimal that it disappears completely, like YouTube controls, when you're not using it, to give you a clean 3D world.

(Egui hint: don't use bottom-up layout. Always work top-down, left to right. Egui layout is one pass, and while it tries to look ahead, it's not good at it.)

Re:Emerging Rust GUI libraries in a WASM world by potamic on Thursday April 27, 2023 @01:51AM (#35723769)
It's pretty lagging for me on a beefy machine with hardware acceleration enabled. What gives?
Re:Emerging Rust GUI libraries in a WASM world by flohofwoe on Thursday April 27, 2023 @06:50AM (#35726125)
Are other WebGL demos also slow (e.g. check https://webglsamples.org/)? How uptodate are your graphics drivers? In some rare cases WebGL is blacklisting old drivers if they have known vulnerabilities, and instead falls back to software rendering.
Re:Emerging Rust GUI libraries in a WASM world by bschwindHN on Thursday April 27, 2023 @02:54AM (#35724235)
egui is nice for internal tools, and for quickly creating UIs for games and such, but I don't think I'd ever release a consumer-facing app with it. It has too many quirks compared to a more "native" UI that it can be quite awkward to use interfaces made with it. I'm talking about things like inertial scrolling, text selection, window resizing, etc.

It's certainly nice to work with from a developer's perspective, what could be easier than

    if ui.button("Say hello").clicked() {
        println!("Hello!");
    ]
?

But it's quite a pain to style if you're particular about typography and pixel-perfect layouts. Between styling an egui app and styling something with CSS (or some flexbox/grid system), I'll take CSS every time.

Still looking forward to how Xilem turns out, and what people build on top of that.

Re:Emerging Rust GUI libraries in a WASM world by echelon on Thursday April 27, 2023 @03:24AM (#35724445)
For this there's Leptos and a half dozen other "DOM in Rust" frontend frameworks:

https://github.com/leptos-rs/leptos

These are already orders of magnitude faster than React, and as the WASM<->DOM bridge improves, they will only get faster.

Sycamore:

https://github.com/sycamore-rs/sycamore

https://sycamore-rs.netlify.app/examples/todomvc/#

Dioxus:

https://dioxuslabs.com/

In about 3-5 years these frameworks will start to consolidate and reach maturity.

It's already possible to build reactive isomorphic apps in Rust.

If you haven't checked out Actix/Axum, it feels a lot like Python/Flask. The ecosystem is coming along quickly.

Re:Emerging Rust GUI libraries in a WASM world by bschwindHN on Thursday April 27, 2023 @03:51AM (#35724640)
Yep, my current favorites are Axum and Dioxus for web things (and some desktop apps too).
Re:Emerging Rust GUI libraries in a WASM world by arethuza on Thursday April 27, 2023 @04:58AM (#35725203)
That looks awesome - are there any accessibility features (e.g. supporting screen-readers)?
Re:Emerging Rust GUI libraries in a WASM world by emilern on Thursday April 27, 2023 @07:15AM (#35726337)
Yes! egui uses https://github.com/AccessKit/accesskit for accessibility
Re:Emerging Rust GUI libraries in a WASM world by Kiro on Thursday April 27, 2023 @05:38AM (#35725554)
Are you being sarcastic?
Re:Emerging Rust GUI libraries in a WASM world by galangalalgol on Thursday April 27, 2023 @06:02AM (#35725752)
I certainly was extremely impressed the first time I saw it. Other than the font book I haven't found anything there that is slow. What makes you think the op might have been sarcastic? Egui was in a thread yesterday and it seems like canvas rendering is a dividing issue between people who value portability and performance most vs people who value consistency of ergonomics and style/look most.
Re:Emerging Rust GUI libraries in a WASM world by josephg on Thursday April 27, 2023 @10:05AM (#35728275)
Its certainly controversial. Using canvas based rendering like this is essentially reverse-electron.

Electron builds native software by embedding a web browser and using the browser's layout engine and DOM. Canvas based rendering like this is the inverse. Here the application discards the browser's layout engine and DOM, and instead embeds its own layout engine. - Despite the browser being right there and available.

Hilariously, in a demo like this there's 3 layers of UI controls nested inside each other. First, there's the OS's native UI toolkit. Then there's the browser. The browser discards most of those UI elements, and reimplements its own controls. And then Egui discards all of that and embeds its own, third layout engine all written in wasm. No inertial scrolling. No web inspector. No native controls (especially a problem on iOS or android). No CSS - so I hope Egui's layout engine supports the layout you're after.

Downside: Its a 5mb wasm bundle. But on the plus side, 5mb is positively tiny compared to shipping electron!

Re:Emerging Rust GUI libraries in a WASM world by jenadine on Thursday April 27, 2023 @10:36AM (#35728802)
The idea is that instead of shipping electron, you ship a native binary that use egui without using wasm or the canvas.

Egui only use wasm in situations where you must use the user browser because you have no choice. Eg: showing a demo of the app on the web without having to install anything.

> Its a 5mb wasm bundle. But on the plus side, 5mb is positively tiny compared to shipping electron

This comparison makes no sense. Situation where electron could be used are exactly the kind of situations where a wasm bundle would not be shipped (a native binary would be shipped instead)

Re:Emerging Rust GUI libraries in a WASM world by josephg on Thursday April 27, 2023 @06:32PM (#35735360)
> This comparison makes no sense. Situation where electron could be used are exactly the kind of situations where a wasm bundle would not be shipped (a native binary would be shipped instead)

Sure; but given the insane size of shipping chrome, it’s fun seeing a full app complete with widget library, layout engine and text input elements in 5mb. It’s terrible to make websites that big. But if chrome could do all that stuff in only a 5mb binary then I’d be much happier with electron.

If you didn’t catch it, the wasm bundle is running in a 32mb memory slab. Positively slim by the standards of modern gui apps!

Re:Emerging Rust GUI libraries in a WASM world by galangalalgol on Thursday April 27, 2023 @11:27AM (#35729571)
I'm curious to see if they took every effort to strip that demo down or not. I think eframe doesn't get a ton smaller than 2mb no matter what you do, so maybe they did.
Re:Emerging Rust GUI libraries in a WASM world by tluyben2 on Thursday April 27, 2023 @08:34AM (#35727073)
I am working in vr on nreal glasses; this demo made me almost barf in my coffee. Everything looks like i'm having a stroke. Not sure why that is, but jaw dropping is it is not.
Re:Emerging Rust GUI libraries in a WASM world by int_19h on Thursday April 27, 2023 @06:08PM (#35735188)
The first thing I noticed here is that the textbox doesn't have the usual context menu with commands like "Select all" and various IME features. It's not clear whether RTL and bidirectional capabilities are there, and if so, how to use them.

Next I clicked on the combo box, it opens the dropdown, and I try to use arrow keys to navigate it. That doesn't work. Is that because I opened it using the mouse? Nope, still doesn't work if you tab through the widgets and use Enter to open. Looking up items by typing the first few characters doesn't work, either.

This is all really basic stuff that native widgets offer to any app for free on any platform.