GithubHelp home page GithubHelp logo

Comments (3)

stephencelis avatar stephencelis commented on August 22, 2024 2

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.

Was this on your radar when you made the episode?

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).

Do you think the approach you outlined has other advantages over this?

Mainly:

  • That lack of friction: with a single function composition operation you're good-to-go.
  • Avoiding the cost of distancing yourself too far from UIKit. It's probably easier to convince a team to use function composition with UIKit than jump ship for an entirely different model, where you maintain the interpreter or tie yourself to another third party.
  • Although we love the testable benefits of the virtual DOM approach (you can get really great, low-cost snapshot test coverage of the hierarchical state of an entire screen by passing a "current state" to the DOM-producing function), what's nice about testing with actual view objects is you can get high-fidelity screenshot test coverage, and you can build playgrounds that act as living style guides!

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!

Do you have any general thoughts on it?

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 view property. E.g.:

protocol View {  }
protocol Button: View {}

Then we could have an interpreter for producing a UIKit hierarchy, and a separate interpreter for testing the hierarchy alone.

from episode-code-samples.

stephencelis avatar stephencelis commented on August 22, 2024

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!

from episode-code-samples.

mdiep avatar mdiep commented on August 22, 2024

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 view property

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. 🤔

from episode-code-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.