-
Notifications
You must be signed in to change notification settings - Fork 294
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
Episode #3 Question: Advantages of your approach over a virtual-DOM approach? #3
Comments
Glad you enjoyed! @mbrandonw's on a flight somewhere over the ocean right now and may have his own thoughts, but I figured I could answer some of this for now.
Virtual DOM ("virtual view hierarchy"? 🤔) and general Elm/incremental stuff has been on our radar for awhile now, but unfortunately fell out of the scope of this episode. We wanted to focus on showing plain old function composition in a practical "you can do this in your code today" kind of way (assuming you're allowed to introduce an operator to your code base—more on that in a future ep).
Mainly:
Trade-offs! We'll be diving a bit deeper into composable view styling in an upcoming ep, and we'll definitely continue to explore wilder territory in the future!
Your example above is interesting and made me curious as to what it would look like with protocol composition! The final tagless approach might be fun to explore here and would allow us to avoid those downsides of inheritance or "object composition" using a protocol View { … }
protocol Button: View { … } Then we could have an interpreter for producing a |
I should note that @bkase and @chriseidhof have been exploring this stuff a lot lately! Brandon Kase gave the view hierarchy example in his talk at dotSwift, and they've shown other examples of final tagless on Swift Talk. I'm looking forward to the community continuing to explore! |
This is one of those examples that makes me wonder what it'd be like to live in a language like Elm that uses structural typing. 🤔 |
First off: I enjoyed episode 3. I really like how you compare different possible approaches to highlight the advantages of function composition.
But watching it, the next thing I would want to try would be to define something like a virtual DOM. (Is there a better term for that concept outside of the JavaScript world?)
This would be a monoid, so you'd retain the same composition with your functions.
There are a few drawbacks to this:
var view: ViewStyle
property)But it also has some potential advantages:
So I'm curious:
The text was updated successfully, but these errors were encountered: