-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Seed without VDOM? #492
Comments
dominator is a rust web framework without VDOM like svelte, yew is also currently looking into that yewstack/yew#758 |
Yeah, they are on that list already. @pickfire What's the motivation for the question? Do you haven any problems with Seed VDOM? |
No, I was just wondering why everyone targets VDOM when there are frameworks like svelte that targets DOM which gives it performance boost, I wonder if it is possible to not have VDOM. Like GC, it may seemed to be needed at first but then it was removed in Rust. |
Everything has trade-offs. And there are different trade-offs for JS and Rust frameworks. Seed uses VDOM because:
It's possible we'll find reasons (and time) to remove VDOM, but neither deeper investigation nor removing is planned in the near future. |
In my experience VDOM diffing doesn't seem to be the slowest part of the render process in seed. Indeed even though it isn't really optimised at all at the moment it's still really quick. With some optimisations it can be made even quicker. I think a move to svelte style direct dom patching would possibly require a lot of re-engineering but at the same time potentially constraining other apects of Seed. |
Despite what I said, I just couldn't help myself. Svelte/SolidJS/ImbaJS/Valerie-rs style direct DOM patching without V-DOM works just fine in Seed. I'm sorry I promise I will stop now and write some documentation for normal hooks and do a style integration plan :). POC: pub fn view(_model: &Model) -> Node<Msg> {
let name = use_state(|| "rebo".to_string);
div![
p![
name.el_class(),
name.inner_text(),
],
button![
"Click Me",
name().on_click(|n| *n = "bob".to_string())
]
]
} This sets the paragraph text and class directly to
Anyway enough of this silliness, time to do something productive! |
@rebo Interesting
Maybe we could try benchmarking the simple demo you did with dom and without (I don't know how)? Or maybe do it on a more advanced example. I wish it makes stuff faster but it would be good if it can be used only for server and not on browser for SSR.
After your experimentation, do you think that is still true? |
I have mixed thoughts, vdom-less infrastructure seems to require accurate change detection, basically the system needs to understand when a specific value has been changed and then propagate that effect to directly modify the browser dom. It's not a trivial problem. For specific values like strings or attribute classes (as in the example above) this is not too complex however it might not be the same for more complex changes such as changing an entire UI tree. And for all of this effort what is gained? Some speed. Sure, maybe even a large speed boost. But is Seed that slow in the first place? It's not that bad to be honest - I can already render tables backed by 100,000 rows at 200+fps. Not sure where I need more performance than that. What might be nice is to have these tools available as an optional optimisation for those situations that really need do it. |
The place where Svelte and similar frameworks shine is on low powered devices. They have real world examples of people using Svelte purely because all other options were too slow for their use cases. |
@awulkan Could you post links to some of those examples? I would like to know what apps they build and what hardware they use. |
One example is https://www.stone.co for their handheld devices. I remember reading somewhere that they use Svelte because of the performance. You can also find their logo on Svelte's website. |
@MartinKavik Off-topic, I am wondering if seed will ever look into not using virtual DOM?
Originally posted by @pickfire in connorskees/grass#4 (comment)
I/we understand VDOM as a big implementation detail. We'll focus on it once Seed API is stable (you can read guides on seed-rs.org with notes about future improvements).
So yes, it's one of the possible options. See the list in #385 - there are some interesting links and ideas related to VDOM or alternatives.
The text was updated successfully, but these errors were encountered: