-
Notifications
You must be signed in to change notification settings - Fork 145
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
Comparison with React (or any virtual-DOM based library) #113
Comments
@saurabhnanda Really what it comes down to is whether you prefer one semantics over the other. React-like libraries are based around a pure function from model to DOM, with a pre-set way of flowing events back up to modify the model. This has two main implications. First, since the entire DOM is potentially regenerated whenever the model changes, it needs to be very clever about using virtual DOM to avoid actually re-rendering things all the time. Second, it doesn't have first-class Reflex, on the other hand, is based around a builder that is explicitly run only once, but that supports using Since Reflex deals with change explicitly, and since And, of course, one huge advantage of Reflex is that it puts the full power of Haskell in your hands - something few other web frameworks can do. For me, the main motivation behind FRP was that I knew pure functional programming, especially with Haskell in particular, was way more productive for me than old fashioned imperative programming. However, I didn't have a pure functional approach to GUI programming, so writing GUIs in Haskell felt like a step backwards compared with all my other Haskell programming. Reflex has made it possible for me to write GUIs in a way that feels "right" for Haskell, and gains all the benefits that I've come to expect from pure functional programming. |
I'm taking the liberty of rebutting (bordering on nitpicking) some assertions and statements, with the intended purpose of making the motivation for Reflex-FRP absolutely clear.
Yes, this is an engineering challenge, but has already been solved fairly well by other virtual DOM diffing libraries. Do you feel that the solution is subpar, or a big giant hack, or prone to breakage? IIUC it's a tree diffing algorithm, which I'm assuming is a well-studied subject.
Would it be possible to explain the concept of Secondly, any example of a "different flow"? What exactly are we talking about here?
I'm assuming this statement means that other dom-diffing libraries do not model change explicitly. Is that really true? Doesn't React conceptually have this flow:
Where event is what is explicitly triggering the change. How exactly is this not giving us "full control"?
Again, request you to please provide an example of "custom event flows" |
I've had a few problems with React's virtual DOM implementation. I've had to sprinkle a lot of Otherwise I am actually pretty happy with React's virtual DOM. I just think Reflex's approach is nice too because you can be fairly certain that the only thing being updated is exactly what is touched by some changing
I think
I think "different flow" means not using React's fairly strict props/state system. Reflex is flexible because you can imitate that exact system if you want fairly easily; props are
Basically, React forces you to use their
You're conflating React and Redux here. I actually really like Redux, but again you can adopt an architecture like this in Reflex as well (top-level global state in a store that is only changed with Events). I think @ryantrinkle was actually saying that's a good model, and Reflex can do it well. However, that is not built into React.
Those are two extremes, but we can do anything in between. Again, since we are using simple functions and Haskell, composability is king, and we aren't restricted to fitting our components into a Class API (React) or the Redux reducer system. Again, I really like React and Redux. I just think Reflex and FRP are superior methods of organizing interactive programs. I think that one huge advantage of the React/Redux combo is the top-level architecture of your app is laid out plainly both with conventions and APIs; everyone has a very similar architecture when using those two libraries together. You can jump on a new project and get productive very quickly. With a more flexible approach like Reflex's, the chance of that happening is much lower. |
Over at https://github.com/vacationlabs/haskell-webapps we're almost through with our POC of Reflex-DOM. We're about to start our POC of the same app with either Pux or Thermite
While we will be in a position to juxtapose Reflex with React-like libraries at the end of this exercise, we'd like to know your opinion on this matter. What does Reflex-DOM solve that React-like libraries don't? What does Reflex-DOM solve more elegantly/efficiently than React-like libraries?
The text was updated successfully, but these errors were encountered: