microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.36k stars 678 forks source link

Discussion: WinUI vs SwiftUI vs UIKit #5140

Closed HppZ closed 1 year ago

HppZ commented 3 years ago

on their 'Design philosophy'

HppZ commented 3 years ago

XAML is not flexible & powerful & clean as UIKit.

saint4eva commented 3 years ago

Comet - C# UI MVU

HppZ commented 3 years ago

Comet - C# UI MVU

what is that?

hez2010 commented 3 years ago

This is what you need: https://github.com/dotnet/comet

However, I didn't see any advantage of using those "flutter-like" patterns for UI development, which extremely couple the UI layout and code behind and make it hard for long-term maintenance as well as automatically UI tests. It benefits nothing except shortening the period of prototyping a demo app IMO.

mdtauk commented 3 years ago

Xaml is more flexible than the others, due to every control being built from a template that are built from primitive elements, and the visuals are entirely controlled by the framework.

SwiftUI tightly controls the appearance of every UI element it supports. Beyond the elements/properties you can adjust, it takes extra effort to customise things. But it is easier to declare and build your UI in chunks that move around.

Kotlin Jetpack is kind of the equivalent of WinUI by implementing new controls, and handling back compat outside of the system.

MAUI will support C# Markup. From my limited understanding, this is an MVU pattern, and seems like the C# equivalent to SwiftUI https://docs.microsoft.com/en-us/xamarin/community-toolkit/markup

This is what you need: https://github.com/dotnet/comet

However, I didn't see any advantage of using those "flutter-like" patterns for UI development, which extremely couple the UI layout and code behind and make it hard for long-term maintenance as well as automatically UI tests. It benefits nothing except shortening the period of prototyping a demo app IMO.

Is C# Markup and Comet the same thing?

saint4eva commented 3 years ago

Comet - C# UI MVU

what is that?

https://github.com/dotnet/comet

saint4eva commented 3 years ago

This is what you need: https://github.com/dotnet/comet

However, I didn't see any advantage of using those "flutter-like" patterns for UI development, which extremely couple the UI layout and code behind and make it hard for long-term maintenance as well as automatically UI tests. It benefits nothing except shortening the period of prototyping a demo app IMO.

You can separate the UI code from the business logic - that is what partial classes can do for you. And Comet leans towards SwiftUI the more. You can develop large apps using MVU app model. Xaml is even hard to read talk of maintaining.

saint4eva commented 3 years ago

Is C# Markup and Comet the same thing?

No, they are not the same thing - but the authors talk to each other about their ideas.

C# Markup is more of mvvm app model oriented. While Comet is more of MVU app model oriented.

See example of Comet - C# UI MVU below

MVU-Pattern-in- NET-MAUI

idexus commented 1 year ago

@HppZ @saint4eva For me XAML is also not flexible, efficient and clean.

I've created a library that creates a UI in WinUI 3 using fluent methods in C#. I based it on my earlier project which I created for MAUI. Unfortunately, the MAUI library is too slow for desktop projects, and has many gaps. This made me decide to create a version directly for WinUI 3. The whole thing was much, much faster than using MAUI and no need for XAML too. I made it for my projects, but decided to make it publicly available. Most code is generated using source generators. It covers all dependency properties and event handlers. If you have time to test it, I'm waiting for your feedback.

https://github.com/idexus/CodeMarkup-WinUI

Example ```cs public partial class HomePage : Page { int count = 0; public HomePage() { this.Resources = new() { new ThemeValue { Key = "HeaderColor", Light = Colors.Navy, Dark = Colors.Aqua } }; this.VerticalAlignment = VerticalAlignment.Center; Content = new StackPanel { new TextBlock() .FontSize(45) .Text("Code Markup for WinUI") .TextAlignment(TextAlignment.Center) .Foreground(e => e.ResourceKey("HeaderColor").Source(this)), new TextBlock() .FontSize(20) .Text("Welcome to the Quick Samples Gallery") .TextAlignment(TextAlignment.Center), new Button() .Content("Click me") .Margin(0,35,0,15) .FontSize(20) .HorizontalAlignment(HorizontalAlignment.Center) .OnClick(button => { count++; button.Content = $"Clicked {count} "; button.Content += count == 1 ? "time" : "times"; }) }; } } ```
saint4eva commented 1 year ago

This is amazing. Any quality attempt such as this to remove xaml is a welcome idea. I will check your repo. Thanks.