Where is MVU? Tired of using old and unnecessarily verbose XAML #12820
Replies: 13 comments 69 replies
-
To me there are different patterns for different purposes. For most general "line-of-business" apps, there just isn't that much complexity to the UI and the well-defined and well-separated structure of XAML and MVVM is perfect. If you are dealing with certain more complex UIs for such things as building maps, complex shapes, animations, 3D interfaces, and the like, then you might feel tempted to reach for pure C#. And that is fair, although databinding and XAML are pretty powerful and can handle a surprising amount of these cases too. It isn't really a question of how nice C# becomes to use, because this division will remain true under any circumstance. XAML can be thought of as a Domain-Specific Language (DSL). It is perfect for doing what it does. Just like HTML or regex or SQL or JSONPath or XSLT or whatever. Intermixing presentation layer concerns and business layer concerns is what MVVM is trying to prevent, and UIs as code make that intermixing too tempting. Also markup languages give a much better sense at a glance what the visual output will be, and allow for more specialization and division of labor in team environments. Microsoft's Blend tool was amazing for constructing XAML with advanced animations and such, and if you had graphics people using Blend and devs using VS or VSCode then you have a perfect division of labor. |
Beta Was this translation helpful? Give feedback.
-
I agree that Flutter way of writing UI is very nice and easy to pickup and I would like to see MVU in Maui. |
Beta Was this translation helpful? Give feedback.
-
MVVM is a pattern, if you don't want to use it, you can assign events from XAML to Code Behind like we all did in the past. XAML can be written in C# with or without Markup Extensions, you are free to choose which is the best choice for you. I have 10+ years using XAML, since Silverlight R.I.P, and for me, it's easy to learn and the productivity is great, since you are able to let your UX work on design in XAML and Styles (very similar CSS) and let your "backend" team work on ViewModels to bring functionalities to View. The patterns are the best choices to separate responsabilities and avoid coupling. I had an experience with a person that came from Delphi and doesn't live XAML and MVVM, because almost the same reasons that you describe, and I was able to show him that you can improve the development using XAML and let the code more testable using MVVM, in two weeks he learn the basics about the XAML and MVVM and loves it. I hope that you love it too, because it's great, have a great day. |
Beta Was this translation helpful? Give feedback.
-
Actually, my real question was Where is MVU? Why there are no efforts now on MVU? @drasticactions can you provide some info on that? |
Beta Was this translation helpful? Give feedback.
-
I would like to introduce two amazing thirdparty projects.
This project is forked from MobileBalzorBindings.
This project is a MVU framework like flutter or React. 20 years ago XAML might have been advanced and made sense. |
Beta Was this translation helpful? Give feedback.
-
Rather than waiting forever for microsoft to do it, maybe we should do it ourselves, some people is going to do some hard work to glue XAML and C# together, but once the job is done you can use C# entirely. The problem is who is going to pay for it. I don't really want to use flutter or pay but come on microsoft |
Beta Was this translation helpful? Give feedback.
-
What do you think about following idea on the ASP.NET repos ? Once this idea is officially followed up by Microsoft, MVU style will be officially supported. There are XAML fans, but there are people who tired of XAML. I'm a big fan of C#/.NET. (Or does Microsoft think AIs like ChatGPT will be writing code in the future,so there will be no need for UI frameworks that everyone finds simple and human-friendly...? ) |
Beta Was this translation helpful? Give feedback.
-
You were right @ziaulhasanhamim and still right near end of 2023. |
Beta Was this translation helpful? Give feedback.
-
The perfect solution: |
Beta Was this translation helpful? Give feedback.
-
I have no idea why anyone uses xaml unless maybe you don't know how to code c#. C# allows you to design all your custom objects, classes behaviors, etc. and then hook them up with perfect precision. If something isn't doing what you want you can write a new function to manage it and hook it up immediately. I think xaml only makes sense if you are not good with code. And if you are doing a big project, probably you should try to improve your code skills rather than use xaml. C# is a great language. Very similar to C++ but without all the pointer and reference stuff which can get confusing. I don't know what benefit there would be in anything else. |
Beta Was this translation helpful? Give feedback.
-
The customers are always right in the matters of taste MAUI.Blazor is so different from MAUI, it's as if you have a golang scripting engine along with JS engine in google chrome, you get to run code out of the browser and manipulate it the experience is worth checking out you get web UI Declaritive framework builds trust based on the type names, while Xamarin technologies has a track record of breaking that trust by having bugs which when you expect a component to work, it doesn't |
Beta Was this translation helpful? Give feedback.
-
ugh I'm late to the party and probably wrong , but I was here when I hear about mvc and immediately thought about game engine for some reason , anyway I've ditched learning xamarin , maui forever , while I like blazormaui syntax and I think it lacks community support , I found fuseopen to be counter intuitive since I want to use blazor for js interoperability I found fuse much more compatible , additionally for web development I prefer using svelte and sveltekit ( while I still consider asp .net core for backed I think node is much more simpler for rapid prototyping ) perhaps using both at some point ? I'm integrating prisma to my stack as it's much simpler solution for working with dbs than something like entity framework |
Beta Was this translation helpful? Give feedback.
-
When the talks about MAUI started, it was heard that it would have good support for C# UI or MVU. But now there are almost zero efforts on MVU. Yeah, there is a comet. But it's not at all usable for a real application and it's not actively worked on.
I think XAML is just a waste of C# skills. You can write great UIs with exponentially less code in C#. XAML is so much verbose and very restricted. It requires a heavy setup. We can do so much more in C#. In 2023 I don't think XAML got its place in modern UI development.
XAML is unnecessarily complicated and verbose. If you want to use a type from a namespace first add xmlns. If you want to negate a boolean you have to write a whole converter class to do that. Oh, you want to get data, you have to create a view model implementing INotifyPropertyChanged, create a field for that data, then create a property, then call other notifying methods on that property, then Bind it to an element with a weird syntax, and still it would be a lot slower because it will use reflection. If you want a button click handler, you have to create a method, then create ICommand using that method, then bind it. It's just the tip of the iceberg about the verbosity of XAML. It's a nightmare to extend features in XAML whereas you can do it easily in C#. XAML feels much like magic which will harm you instead of helping you. For each view in XAML, you really need 3 files at least. Again for writing XAML you will need a visual studio. It doesn't work on vs code and doesn't work well in rider. XAML is really so much less accessible compared to C#.
As a beginner, it is so hard to learn XAML. Bindings, ViewModels, Code Behind, the weird syntax of XAML, converters, resource dictionary, etc. Whereas UIs written in code are very easy to understand and fast to work on. The best example is obviously flutter. No one even knew about dart. But flutter was so easy that most beginners preferred it. Despite of being written in a language that is rarely used, flutter is one of the most popular frameworks for Mobile development. The biggest reason for flutter's success is its ease of use. You learn the dart language you can learn to write UIs in a flutter. But if you are an expert in C# still you will need to learn a lot of things before writing apps in MAUI. Writing UIs in code is really charming. Once you use code UI XAML looks like crap. But C# still doesn't have a good framework for writing UI in code. I think most developers would prefer code UI on any day over XAML after using that.
Anyone would prefer this over that weird XAML
After all of that MVVM and XAML are slow. You can always write more performant apps with code UI because you are using a full programming language. Bindings can be very slow and even with compiled bindings they have overheads.
As C# is being more easy and simple to use every next version, XAML and MVVM will feel more old and verbose in the future.
There are many efforts for simplifying MVVM like the community toolkit. But these are really steps in the wrong direction. Attention should be given to writing UI in C#. I know many people will recommend I take a look into C# markup but it's mostly a workaround. For proper C# UI, there should be controls written for that instead of using old XAML components.
The web part of C# has improved a lot since 2015-2016 with ASP.NET CORE. Writing web apps and APIs has become a charm in C#. But I can't say the same with the UI part. UI frameworks are just ported to the new cross-platform .NET. Still writing UI is a hazard. Why can't it be simplified?
The only way to attract beginners to MAUI is C# UI instead of XAML. Because anyone who just starting with mobile development would hate to write XAML. It's hard to learn and hard to teach.
Beta Was this translation helpful? Give feedback.
All reactions