From 5bc33a038af959738acf7d8a0eb98f5b411a4ec6 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Thu, 13 Oct 2022 16:23:44 -0400 Subject: [PATCH] Update README.md --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index 35d282850..82424c718 100644 --- a/README.md +++ b/README.md @@ -60,3 +60,34 @@ Here are some resources for learning more about Leptos: - [Examples](https://github.com/gbj/leptos/tree/main/examples) - [API Documentation](https://docs.rs/leptos/latest/leptos/) (in progress) - Leptos Guide (in progress) + +## FAQs + +### How is this different from Yew? +On the surface level, these two libraries may seem similar. Yew is, of course, the most mature Rust library for web UI development and has a huge ecosystem. Here are some conceptual differences: +- **VDOM vs. fine-grained:** Yew is built on the virtual DOM (VDOM) model: state changes cause components to re-render, generating a new virtual DOM tree. Yew diffs this against the previous VDOM, and applies those patches to the actual DOM. Component functions rerun whenever state changes. Leptos takes an entirely different approach. Components run once, creating (and returning) actual DOM nodes and setting up a reactive system to update those DOM nodes. +- **Performance:** This has huge performance implications: Leptos is simply *much* faster at both creating and updating the UI than Yew is. +- **Mental model:** Adopting fine-grained reactivity also tends to simplify the mental model. There are no surprising components re-renders because there are no re-renders. Your app can be divided into components based on what makes sense for your app, because they have no performance implications. + +### How is this different from Sycamore? +Conceptually, these two frameworks are very similar: because both are built on fine-grained reactivity, most apps will end up looking very similar between the two, and Sycamore or Leptos apps will both look a lot like SolidJS apps, in the same way that Yew or Dioxus can look a lot like React. + +There are some practical differences that make a significant difference: +- **Maturity:** Sycamore is obviously a much more mature and stable library with a larger ecosystem. +- **Templating:** Leptos uses a JSX-like template format (built on [syn-rsx](https://github.com/stoically/syn-rsx)) for its `view` macro. Sycamore offers the choice of its own templating DSL or a builder syntax. +- **Template node cloning:** Leptos's `view` macro compiles to a static HTML string and a set of instructions of how to assign its reactive values. This means that at runtime, Leptos can clone a `