r/fsharp • • 12d ago

WinUI.Elmish Project

Hi everyone, please checkout my new project:

https://github.com/afshin29/WinUI.Elmish

14 Upvotes

2 comments sorted by

2

u/EmergencyNice1989 11d ago

That's interesting. I don't use C#, only F#, but I migrated all my Avalonia XAML/MVVM apps to Avalonia.FuncUI Elmish, and it was a big gain. I now use XAML only for styling and a few resources. The code is much simpler, reuse is easy, the UI is more flexible, and there's less context switching.

The one drawback is the diffing. The whole view is rebuilt on every update and compared with the previous one, and the differ doesn't always notice what changed.

MVU fits functional languages naturally (immutable records, with updates, pattern matching on messages), so I don't know how well it translates to C#.

1

u/afpr29 11d ago

WinUI.Elmish uses some smart diffing algorithms. Collection diffing uses the LIS algorithm to find the cheapest way to update the collection (written by Claude), and layout diffing (written by me) requires users not to reorder their nodes (all explained in the doc) which makes it very simple and fast. Other than that, there is memoization feature that if used correctly, can speed up the diff process.