mayu-live / framework

Mayu is a live updating server-side component-based VDOM rendering framework written in Ruby
https://mayu.live
GNU Affero General Public License v3.0
130 stars 4 forks source link

Comparison with StimulusReflex #66

Closed Tails closed 9 months ago

Tails commented 9 months ago

Hi,

Mayu looks great and I love that is more bound with HAML than ERB because HAML is great.

Is there a comparative analysis between Mayu and StimulusReflex?

aalin commented 9 months ago

Hi, and thanks!

There isn't. I don't have any experience with Stimulus Reflex so I don't think I could write one.

Mayu is closer in design to React/Preact, but it uses Haml instead of JSX. Event handlers are bound directly to methods in a component (%button(onclick=handle_click) would call the instance method handle_click).

I think Stimulus Reflex has a different model where you render HTML and then it uses morphdom in the browser to morph the HTML into the rendered HTML.

With Mayu you have a tree of components, and whenever a component re-renders, Mayu will diff the old tree with the new tree and emit patches to update the changed nodes so that the DOM will match the Virtual DOM tree.

Stimulus Reflex works with Rails while Mayu is standalone.

There's also no way to use JavaScript with Mayu (I haven't found the need for it, but it will probably support custom elements at some point).

I'm currently working on a complete rewrite of Mayu, not sure when it will be done, but it's taking shape :)

Tails commented 9 months ago

Thanks for the write-up! I am somewhat turned away by the complexity in the SR docs so I'll try Mayu first :)

aalin commented 9 months ago

@Tails Be aware that Mayu is far from production ready, there are some rough edges! Please play around with it though! It's pretty fun to use :)

If you want something that is production ready, Stimulus Reflex would be a better choice for now