17 ms·
Emerging Rust GUI libraries in a WASM world
- Cuteaesthetic 3y ago[dead]
- Kawaiiaesthetic 3y ago[dead]
- Jinxcosplay 3y ago[dead]
- MeshFresh456 3y ago[dead]
- Veranorooz67 3y ago[dead]
- DorkyDweeb2 3y ago[dead]
- HilariousRed3 3y ago[dead]
- Soverinowu09 3y ago[dead]
- Storystork790 3y ago[dead]
- Soverinowu689 3y ago[dead]
- Lucitabee46 3y ago[dead]
- Infamousxwho70 3y ago[dead]
- Arcadezwade22 3y ago[dead]
- Gameclord34 3y ago[dead]
- givemethrill09 3y ago[dead]
- ruggedhuman3 3y ago[dead]
- out_lurking4 3y ago[dead]
- tiger_hoods8 3y ago[dead]
- imma_adonis1 3y ago[dead]
- corden_kimmel1 3y ago[dead]
- slay_hearts7 3y ago[dead]
- lion_ankles6 3y ago[dead]
- peez_weez9 3y ago[dead]
- steel_rebel6 3y ago[dead]
- heart_stealer1 3y ago[dead]
- shadow_lord3 3y ago[dead]
- wolf_gang7 3y ago[dead]
- crow_srows9 3y ago[dead]
- SasukeUchiha1 3y ago[dead]
- Tangy_sushi0 3y ago[dead]
- FairyTail9 3y ago[dead]
- Namecheckr4 3y ago[dead]
- TheOneandonly1 3y ago[dead]
- fabulously_your 3y ago[dead]
- CitySlicker1 3y ago[dead]
- OfHearts00 3y ago[dead]
- Irish_Lass2 3y ago[dead]
- steelersfan5 3y ago[dead]
- Charmed_Beauty0 3y ago[dead]
- GloryBringer2 3y ago[dead]
- born_to_flirt 3y ago[dead]
- Kingofallking 3y ago[dead]
- OneTruePerson 3y ago[dead]
- BadGuy4U 3y ago[dead]
- DungeonDevil3 3y ago[dead]
- IzzaBigDeal8 3y ago[dead]
- SoHapppyy2 3y ago[dead]
- SoExcited 3y ago[dead]
- ImImpatient4 3y ago[dead]
- eslaught 3y agoI've been building a profiler UI in egui recently, and have been pretty happy with it. I didn't try out all of the options in this article (there are rather a lot of them), but I did try several, and out of the ones I tried, egui was by far the highest performance. Since my goal is to shove as many rectangles onto the screen as possible, this was the killer feature for me, but it was also nice that it did most of the other GUI stuff I needed. WASM demo here if you want to see it (with dummy, and not particularly realistic, profiling data): https://elliottslaughter.github.io/legion-prof-viewer/ https://elliottslaughter.github.io/legion-prof-viewer/ For comparison, the UI I'm replacing falls down with about 16 nodes worth of data. (The demo has 8192 "nodes" worth of fake data.)
- josephg 3y agoCool demo, but by the looks of things the whole site is rendered into a canvas element. As a result, the browser's dev tools are useless, it won't work with screen readers, and you can't copy+paste text. And any text rendering and input elements will be non-native. (So, no nice iphone controls. No native / system configurable keyboard shortcuts. And so on.) I sincerely hope the web as a whole doesn't move in this direction. The inspectibility of the DOM is one of the web's greatest strengths. Lets not throw that away.
- deleted 3y ago[deleted]
- chrismorgan 3y agoAnd scrolling is unavoidably all wrong: dragging two fingers from one end of my touchpad to the other should scroll by about four screenfuls, but only manages two thirds of one screenful; a quick swipe should send it dozens of screenfuls, with inertia, but manages even less than that two thirds of a screenful; and these limitations are fundamental due to the web not possessing the right primitives. (Then there are more fixable bugs like that, after focusing the page, you have to move the mouse before scrolling will work.) And input element behaviour is non-native, which will never be properly fixable since different UAs have different behaviours, some of which cannot be emulated even if you sniff which platform you’re on (e.g. scroll bar grab and drag behaviour when you move far outside the window). (Then there are also simple bugs: holding Left or Right while the range element is focused only bumps the value once, not according to key repeat. And Up and Down don’t work.) I have written about these things a number of times, fundamental limitations of the pure-canvas approach that make it unavoidably and permanently unsuitable. https://news.ycombinator.com/item?id=33861831 https://news.ycombinator.com/item?id=33861831 is probably the best thread. (And just for a bit of fun: the demo can have slightly negative utilisation, drawing outside the box!)
- LatticeAnimal 3y agoThat is unfortunate that Druid was discontinued. I really enjoyed working with it a few months ago.
- serial_dev 3y agoIm a Flutter developer, and, though I love Dart, it's still only my second favorite language, so I can't wait for a viable "flutter alternative to emerge in the Rust ecosystem.
- mcluck 3y ago> GUI in Rust progresses with unprecedented speed – 3 months in Rust GUI-land is like 3 years in the mortal world. areweguiyet.rs was started almost exactly 5 years ago. That means it's been about 60 mortal years and we still don't have a definitive solution to GUIs.
- KRAKRISMOTT 3y agoThat's because Rust GUI people are like Lispers and functional programmers — too obsessed with doing things correctly "from first principles" and "purity". For GUI programming, there is only one feature that matters: having a fuck ton of well supported widgets for every situation across every platform. Almost everything else is secondary. This is why HTML/CSS, Flutter (and to a lesser extent Qt) are so successful. No end user cares about data mutational elegance when at the end of the day, somebody has to do the unsexy work to maintain and support each individual button, scrollbar, and toggle.
- vbezhenar 3y agoI'd argue that the most successful UI platform is a browser. And guess what? Browser does not have a fuck ton of well supported widgets. All it does it some button with outdated UI, few inputs nobody really uses and dropdown select suitable only for the most basic uses. Anything other built on divs with CSS and JS. And it works. So my opinion is that it's definitely solid foundations what matters. Rest will come with time from third party libraries.
- KRAKRISMOTT 3y agoThe browser is successful not because it has a solid foundation but because a ridiculous amount of engineering effort has been put into it. Most of the "beautiful foundation" you see are all post 2012. You young'uns don't remember the days before HTML5 and CSS3. Before npm and PWAs and the "cloud native" nonsense. Adobe Flash anyone? Silverlight? Before WebAssembly/WebGL/WebGPU unity (yes that game engine) even required a browser plugin. Web browsers were often severely incompatible with each other and web standards were a suggestion at best. Now, it's bad form to slander dead people so I will just say that the nice kind folks at apple under the orders of their dear leader did their best to destroy as much of the pre-2012 web as possible by gatekeeping the iPhone browser and using their market power to strong arm web technology.
- CJefferson 3y agoSearched for “accessibility” — 0 results (I couldn’t see anything skimming down the page). Speaking as a Rust user, everyone in Rust land loves insulting Electron, but they have put some solid work into accessibility. In particular, using WASM to draw text with webgl or canvas, instead of DOM, may in the long term be one of the biggest steps back in accessibility ever.
- hnon 3y agoI think it's interesting that we take it for granted that accessibility is primarily the responsibility of GUI toolkit developers. I would think that maybe some amount of blame would fall on OS vendors, who have billions of dollars flowing through their organizations, rather than some random open source projects. If your app can be described to a screen reader, then there should be an easy cross platform API[0] for GUI toolkit makers to use, provided by the underlying platform in a reasonably simple way. [0]: I am aware of AccessKit. Where's the OS backing?
- capableweb 3y agoI'm not familiar with the entire ecosystem but at least egui offers accessibility via AccessKit
- CJefferson 3y agoThanks. Last time I looked in depth (about 6 months ago), nothing supported accessibility, but you are right, it looks like egui at least has made excellent progress. I still keep my comment about the article -- I feel discussions of GUIs should talk about this type of thing, as so many people require accessibility support.
- jenadine 3y agoDesktop solutions don't use wasm/canvas for their primary use. Although you can wasm to compile it for web demo, they are primarily meant to be used as native apps outside of a browser. I know Slint and egui have accessibility support.
- eviks 3y ago
- vbezhenar 3y agoI wonder if WebGPU could help with app GUI. I tried to understand how does it work but it seems it's all about triangles, so it's not really clear if it has any benefit over plain Canvas for standard UI approaches.
- Cloudef 3y agoPlease don't use canvas or webgpu for GUI unless it's a game or other interactive experiment. Webgpu will drop compatibility with hardware and no accessibility, you would have to build everything up from ground again that web browsers already offer with DOM like flutter does by having "overlay DOM" on top of canvas to provide accessibility, and it's kinda janky. Now that's out of the way, sure you can do GUI with webgpu, see for example IMGUI or NanoGUI (NanoVG based).
- fulafel 3y agoIt would be interesting to get complete apps running there. Wasm-on-GPU seems a reasonable match since there's no OS APIs in Wasm.
- eviks 3y agoIs there a good detailed table with features filter for various frameworks? For example, maybe you feel that VDOM is pure overhead and want to hide all frameworks that use it. It's a bit disorienting to read many rather shallow lists with all the various frameworks without a proper convenient way to compare them
- preommr 3y agoThe biggest problem is that there is no dominant solution. Right now having a rust-based app is a luxury when there are easier albeit 'dirtier' solutions. I don't have to build something in rust and I am dreadfully afraid that I'll spend hundreds of hours building something only for an altenrative to be the emergent solution forcing an expensive rewrite.
- TobyTheDog123 3y agoThis may not be the message of the article but as a side-rant: I really don't understand the use-case for a Rust-based GUI. Rust's syntax, manual memory management, and compile times makes it seem like it's really not meant for this kind of workload, but instead for things like compilers, embedded systems, that kind of thing. I understand that not every UI needs to be a cross-platform blah blah blah written in TypeJavaReactScriptJS, or a pixel-painted canvas written in Flutter. I also understand there's a use-case for one-off UIs that may not target a browser. Let's compare it to something like Golang. Fast compile times, similar libraries, garbage collection -- it seems like something more suited for UIs where there are usually a lot more iterations. Worse performance for sure, but Rust also seems more-than-overkill in that regard for the UI use-case.
- winstonewert 3y agoFrom a Rustacean's perspective: Golang is a no go because it lacks enum types, sensible error handling, generics (I think it has some version of this now), non-nullable types, or macros. Once you've gotten used to using these kinds of features in Rust, it is really annoying to go back and work in a language that lacks them. Basically, golang takes such an opposite design approach to Rust, that if you like Rust you'll probably hate golang. We also find that once you get used to the borrow checker, we mostly don't miss garbage collection. And garbage collection isn't a panacea either, as almost any large project still ends up with memory leaks caused by stray references. So, basically, we like Rust and think its a well designed language. It is quite frankly better, as a language, than any of the alternatives that we could be writing in. As such, it'd be nice if we could develop GUI applications in it.
- crispinb 3y agoI doubt Rust is going to become used for (the GUI layer of) GUI apps far outside of Rust enthusiast circles. To build a widely attractive ecosystem it needs a dominant framework to which enough of the many widget and theming and distribution libraries and tools necessary for broad adoption attach. Rust's culture in this respect is far more Clojure (bolt together your own from a thousand options) than Elixir (just use Phoenix). I have no doubt Rust will be used as part of many GUI apps via Tauri and others. 1Password shows how successful it can be as the real core of an app that has a separate web-tech GUI layer. There's enough energy in the Rust ecosystem that I'm sure niche adoption will continue. But all-Rust apps beyond HN/Github-browsing/System76 circles? My guess is it's unlikely.
- bsaul 3y agoMy guess is Rust is going to experience its first test in the next two years, where the general people will see what it's really good for, and what's it not, because it won't be the "new hot thing" anymore. Only then we will know if it has chance of really becoming widely used as a general purpose PL.
- crispinb 3y agoIf by 'general purpose PL' you mean one used to write mainstream GUI apps, I nearly agree though I'd bet against Rust on that score. If however you mean one used across a wide variety of industries, software types, and hardware, I think its future is already assured there. My own guess is that Rust will become quite ubiquitous for the performant and stable core of many software systems, with the interactive levels handled by other languages.
- Liberonostrud 3y agoI am betting on Vlang instead. Rust is too complicated for an average person - like me. It's basically the Haskell of system programming. V is basically Go made right.
- Tozen 3y agoPeople should be allowed to have a difference of opinion and like other programming languages, without a swarm or mob of evangelists going on a downvoting party. If others like Rust or Go, that's their preference, but it's not necessary to bully other programmers. Lots of people like Vlang, so better to accept that. Not everybody is going to prefer or think the same in regards to programming languages.
- TobyTheDog123 3y agoI remember looking into V last year, it seems most of the discussion surrounding it was that it was vaporware. Is that not the case? It certainly looks nice, but is it ready for use?
- Tozen 3y ago[flagged]
- brabel 3y agoThe main issue was that V promised automatic memory management like Rust, but without the "trouble" caused by the borrow checker, which is something anyone who knows about the problem more deeply would laugh at.... last I checked, they were still at the same stage as a few years ago with that: "it will be working soon". It will almost certainly always stay there.
- Tozen 3y agoAutofree already works (to a significant extent) and has been demonstrated[1], for years now. Vlang's Vinix OS[2] uses autofree. The situation (as I understand it) is unlike using a GC, autofree requires the user to have knowledge of memory management and how to use it properly. One of the objectives of Vlang is to be easy (easier) to use. Using a GC as the default, proved to perform very well with the language, and presented less complications for users. It appears the strategy of the Vlang developers (as stated on their website and documentation) is to go with flexible memory management. That is the GC can be turned off whenever the user wants (-gc none), and other memory management options can be used such as autofree (-autofree) or their arena allocator (-prealloc). This flexible memory management strategy would be somewhat similar to what Nim did, and interestingly, I don't see people crying as much about it. Furthermore, there is more to Vlang as a programming language than just autofree, as if its the only thing that counts. People use it for many other reasons. 1. https://www.youtube.com/watch?v=gmB8ea8uLsM https://www.youtube.com/watch?v=gmB8ea8uLsM (Autofree demo) 2. https://www.youtube.com/watch?v=mJG4Zg6Ekfw https://www.youtube.com/watch?v=mJG4Zg6Ekfw (Vinix OS)
- Liberonostrud 3y agoWhat's wrong with TypeScript? Last time I checked all WASM stuff was slower and much heavier than TS/JS.
- andyp-kw 3y agoMy understanding that WASM has a heavier load time, however actual benchmarks after the initial load are more impressive.
- SnowProblem 3y agoIt’s not WASMs fault. Rust produces large binaries for whatever reason and people like to write their WASM in Rust. I’ve ported Rust to equivalent C and it was 25% of the size and similarly for loading times.
- brabel 3y agoExactly, WASM was designed to be very very lightweight... you can put a lot of logic into a very small amount of WASM, but you need a good compiler to do that, or write WASM by hand to really feel the benefit. If you just compile Go to WASM, with its GC, runtime and stdlib included in the binary, yeah it's going to be pretty heavy... Rust doesn't have a runtime but as you said, for some reason, produces relatively large binaries (not the case only in WASM by the way). Probably, the best ways to create small WASM binaries is to compile from C or from a WASM-native language like AssemblySCript (https://www.assemblyscript.org https://www.assemblyscript.org).
- josephg 3y agoRust doesn't have to output more code than a C compiler. But it tends to because most rust programs are stuffed full of bounds checks. And bounds checks aren't small. As well as the conditional itself, every bounds check also includes: - A custom panic message (so you know which line of code crashed) - Some monomorphized formatting code to output that message - The infrastructure to generate a stack trace after a panic - Logic to free all the allocated objects all the way up the stack If you compile this 1 line function: pub fn read_arr(arr: &[usize], i: usize) -> usize { arr[i] // (equivalent to 'return arr[i];') } ... You produce 20 hairy lines of assembler: https://rust.godbolt.org/z/dhz34KEvj https://rust.godbolt.org/z/dhz34KEvj In contrast, the equivalent C function is this rust code: pub fn read_arr_unchecked(arr: &[usize], i: usize) -> usize { unsafe { *arr.get_unchecked(i) } } And predictably, the result is this gem - identical to what the C compiler outputs: example::read_arr_unchecked: mov rax, qword ptr [rdi + 8*rdx] ret But nobody writes rust code like that (for good reason). You can get a lot of the way there by leaning heavily using rust's iterator types and such. But its really difficult to learn what patterns will make the rust compiler lose its mind. There's no feedback on this at compile time, at all.
- klabb3 3y agoI am glad that there are people looking at GUI from the perspective of Rust. Many Rust idioms and patterns, like ownership and immutability, are very promising for GUI development. However, this article also confirms an issue I have observed with the Rust ecosystem, which is fragmentation. It would have made me much more excited to see convergence behind one project than 15 different ones. I think Rust enthusiasts, bless their hearts, are often so excited about the puzzle of the language representations, that the output often ends up being more of a POC than a well-maintained library for users. It seems more-than-usual amount of projects are abandoned when the intellectually stimulating honeymoon phase is over. As a prospective user, this is probably fine for small leaf-dependencies, but it’s a major show-stopper for something like GUI. I’ve never expressed it like this before, but I think there’s a moderately serious issue when a language seduces you away from the domain problem and towards the language itself, even if that is subjectively enjoyable. (In other languages like perhaps Java or C++, the language quirks are at least so dreadful that only masochists are spending more time than necessary on it)
- crispinb 3y ago> an issue I have observed with the Rust ecosystem, which is fragmentation. Absolutely. The fragmentation doesn't matter with all library types, because they don't all need the vast array of associated libraries, tools, common practices etc which mainstream GUI apps lean on. Wide GUI framework/library adoption needs a head of steam (far more than it needs architectural elegance). Right now I don't foresee this happening with Rust. Not everything is foreseeable, of course.
- low_tech_punk 3y agoI have my popcorn ready for the battle of WebGPU toolkit implementation. That can be a true differentiator between Rust and other languages.
- satvikpendem 3y agoI've been using Flutter with flutter_rust_bridge pretty successfully, seems like a few other people I've talked to are as well, would want to see it covered in this article as well.
- FL33TW00D 3y agoThe creator of egui has founded a pretty cool company, and their flagship application is built entirely using egui: https://github.com/rerun-io/rerun https://github.com/rerun-io/rerun
- plaguepilled 3y agoAll very exciting to see, but when is crablang going to support this? That's the real meat and potatoes in the memory safe space!
- ljsb 3y agoI hope it's OK to add a shameless plug for my Rust WASM framework, Silkenweb [0]. It's similar to Leptos and Sycamore in that it's signals based, but I've put a lot of effort into making it ergonomic without resorting to a macro DSL. It supports all the usual things like SSR and hydration, along with a few nice extras like scoped CSS. [0] https://github.com/silkenweb/silkenweb https://github.com/silkenweb/silkenweb
- 7znwjshsus 3y agoI love how simple your cargo toml is. A big turnoff of leptos for me was the incredibly messy cargo toml of the examples. I could barely touch it without bricking the project.
- Firfi 3y agoAuthor here! I've added it to my TODO list and will update the article at some point coming week or two. Love how the library looks like - thank you for the link!
- davidatbu 3y agoWhile I'm usually a no-macros kinda guy, but (I believe) leptos and dioxus provide tooling to hot-reload markup-only changes without (incremental) recompilation. Do you think that would be possible withour macros?
- ljsb 3y agoI can't think of any practical way to do that without macros, unfortunately. I've found incremental compilation to be pretty speedy for small markup changes so far though. I do tend to put the presentation code in it's own crate for larger projects, which might make a difference. Maybe as my projects get bigger I'll start to run into problems. Some other ideas: - Temporarily stopping the rust-analyser server to avoid lock contention on the build dir. - Using cranelift codegen backend (not sure of it's current status).
- davidatbu 3y ago
- fmeyer 3y agoWho remembers GWT? I understand the requirements of having a dedicated canvas and a decent UI running on it for things like games, CAD, 3D modeling and image manipulation apps. At the same time I don’t want my web bank using it. And unfortunately that’s usually what comes out from this.
- vrglvrglvrgl 3y ago[dead]
- Aerbil313 3y agoGive it enough time, and anything will happen. JS to Rust compiler with DOM bindings. Pure canvas Rust UI frameworks with even better accessibility than Web DOM. Whatever. People are so eager to claim X won’t be able to do that, etc.
- doodlesdev 3y agohttps://archive.ph/MLUeZ https://archive.ph/MLUeZ