Replies: 1 comment 1 reply
-
Thanks for your thoughts!
You are right in that there are lots of possible design choices that can be made. But there doesn't seem to be much consensus in the Rust community about what the idiomatic approach to UIs is. There are a lot of different crates that take different approaches. Raph Levien has a cool blog post that, among other things, summarizes some of the existing architectures. Your
But Dioxus has taken a different path – it is based on React functional components. And this architecture I believe makes great developer experience (which React is famous for). It's really easy to write, read and maintain once you get used to it. Of course, it has drawbacks as well. Levien writes:
I agree that interior mutability is "not great" as it bypasses Rust's amazing compile-time borrow checker, leading to possible panics at runtime. Though in practice, this hasn't been an issue for me. And I have mixed feelings about hooks. They are very much unlike anything else in the Rust ecosystem. And they have "weird" rules that I wish could be enforced at compile time. Even in React they were not without controversy. But they are really easy to use, and compose nicely.
It sounds like you are underestimating the complexity that goes into a UI framework a little bit :) State management is hard. Layout is hard. Event handling is hard. Exposing an ergonomic API is hard. Though you're welcome to try making your own framework if you don't believe me (been there. done that. failed 3 times lol). Anyway. I encourage you to try out writing the same interface in various frameworks and see which one you like best. I can suggest Dioxus, Egui, and Iced – they each have their own strengths! Though Dioxus is my favorite at the moment. It's really pleasant to work with, and practical. And it renders to HTML, which means you get all the good stuff of the web (complex layouts, any kind of text (e.g. RTL), CSS, SVG, responsiveness, transitions, accessibility, cross-platform rendering, etc.). I hate HTML but it has evolved to contain basically anything you would need for a "normal" UI. (disclaimer: i am not a maintainer; these are my personal opinions) |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm just starting reading through dioxus documentation and I'm thinking that some things could be designed in a different, more rust idiomatic way.
what I've understood so far is that you have props (that are structs with derive Props) and you have components which are functions that accept
cx: Scope<Props>
. Props are the data used by component and each component uses only one Propsidk, but for me it looks a lot like
possible considerations are
don't judge hard, I am sleepy and don't know what I'm talking about.
Beta Was this translation helpful? Give feedback.
All reactions