-
Notifications
You must be signed in to change notification settings - Fork 1
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
A simple framework that I think it is similar to Imba! #1
Comments
Simi looks really great! I'll archive this in favor of Simi. I haven't had enough time to look through all the code, so take this with a grain of salt, but the main differences I see that you could consider are:
|
It's very great if we can collaborate! If you want, I suggest you may want to play with Simi a little bit to see how you feel about it before any decision. Because Simi is already there (although still a WIP) and have some similarities with your ideas. Feel free to ask any question if I did not document (good) enough.
Simi does not support keyed list yet. But I am sure I will have a look at
After the first render, Simi try to directly update the current-only-virtual-DOM rather than rendering a new virtual DOM. Therefore, I think pump allocation is not suitable for Simi. But maybe it is suitable for keyed-list? |
I have done some experimentation in the zerosize branch, and came up with something that takes a quite different approach from Simi. Basically using zero-sized types and macro_rules instead of proc-macros. It is a little messy, and I'll see about cleaning up the code, but what do you think? |
It's very interesting to see the very first steps of a new project (especially, building by a more experienced dev). Your work is far more Rusty than mine. No thing from Imba, no bump allocation for now? Any plan to introduce/implement them? But from my understanding, currently you go with traditional virtual DOM (rerender the vDOM on every update then diff and patch), it make "The main distinguishing ideas are that we reconcile while building the virtual DOM" (quoted from README) impossible!? I think you want to allow multiple I used to sprinkle arbitrary code inside a renderer. It's not a problem for a small app. But in a big app, I tend to lost in my own code. Therefore, Simi don't allow Rust code appear in its renderer (a renderer should focus on rendering, hence I never have to dive in the renderer to find codes that do non-render stuff). How do you think about this? For example, how to move this and/or this out of |
Thanks for taking a look!
Yes, it works differently from the draft in the README. But it is still incremental DOM like Simi/Imba. The difference from traditional virtual DOM (thinking seed, doduo, etc) is that building the VDOM is zero cost. That is because the
into
You could have multiple
I am fine with it as long as it doesn't mutate any state. That said, for stuff like callbacks I think messages are the way to go, like how they are implemented in Simi. It's just that I think that it's out of scope for this small virtual DOM library. |
Do you mean "(thinking seed, dodrio, etc)" :D?
Wow, that's like magic! But I do not have enough knowledge (especially in Rust) to figure out! I can't wait to see a benchmark (and hope it goes well)! :D
It was not there when I learnt about React. I moved away from React for awhile. It's definitely on my to-read list (to try to understand what you want to do with
Yeah, in the case that this happens, your crate may be a greate alternative, I may consider switching to it from Simi. How about checking mismatched tags at compile time like this (you may want to paste the code into Rust playground to see how it works): macro_rules! match_tag {
// Unfortunately, this approach requires you to define a rule for each tag
// So, for html tags, this requires more than 100 rules. How many are svg tags?
(@match div div) => {};
(@match span span) => {};
(@match $open:ident $close:ident) => {
compile_error!("Mismatched tags. See next error to find out where the mismatch occurs");
// The next line forces error at the mitmatched close tag
match_tag!($close);
}
}
macro_rules! html {
(<$open_tag:ident> $($tt:tt)*) => {
html! { @tag $open_tag $($tt)* };
};
(@tag $open_tag:ident </$close_tag:ident>) => {
match_tag!(@match $open_tag $close_tag);
};
}
fn main() {
html! { <div></span> };
} |
Nice catch! Should probably come up with a new name since doduo no longer fits.
That would probably be a next step! I reckon it's not very fast at the moment, since it always has to walk the DOM tree, as DOM nodes aren't stored, but the Web IDL Bindings Proposal should reduce the overhead for free. Upcoming Rust features, such as specialization; const generics; and custom allocators, should also help.
Don't say that yet - we haven't seen any proofs of performance. ;)
That's a good idea. I looked at const functions to do that in a less hacky manner, but that functionality was not ready yet - unlike your solution. |
Hi, I create an issue here because I don't have a reddit account and because you say that Doduo inspires by Imba. I implement a simple framework called Simi (inspired by Yew), and later I find out that it's similar to Imba (read my comment here). Some similarities I found between your ideas for Doduo and Simi:
if (let)
,match
,for
(Simi already implemented these, I don't have plan to implementwhile
).But the way Simi generate code is different to your envision. If you want to see the code generated by Simi, you may try its simplest
examples/counter
and uncomment the//@debug
(line 31) to see it.I may read your ideas more careful later and come back to correct any misunderstand (my empty stomach make my eyes weary now 😩 )
The text was updated successfully, but these errors were encountered: