Thursday, February 03, 2022

Don't give up on XAML yet.

Some people aren't fans of XAML. That's ok.

Some people use it because they have to.

A very small number of people think deeply about XAML. 

I include myself in the third group.

some random XAML in an editor

There's a popular trend at the moment to dismiss XAML because of its limitations. 

The argument goes that you should use C# (or equivalent--hello VB fans) to define the whole of the application, rather than use a separate tool (XAML) to define the user interface. This is seen as a way to simplify a codebase and avoid some of the limitations of XAML.


C# is a general-purpose language. You can use it for everything but that doesn't mean you should. XAML, while not a full programming language is designed specifically for defining user interfaces and has appropriate tooling available.

XAML is not a "proper" (Turing-complete) language but it doesn't need to be. It can still do useful and powerful things.

Most of the arguments I'm hearing for just using C# come down to the idea that the tooling for defining UI's in C# should be made better so that people can use that instead of having to use XAML.

I have concerns about this approach:

  • It ignores the possibility of improving the XAML experience, which is the ultimate source of the issue.
  • It means the need for more work in supporting (developing & maintaining) the ability to create UIs with XAML and C#.
  • It indicates that there is no plan, desire, or intention to improve the XAML tooling and experience. Should people, therefore, infer that XAML is in a fixed state and will never be touched again. The consequence of such an idea is that people should stop using XAML. What then for all the existing XAML code that exists? There's an implication that this should probably end up being rewritten in C#. This means that we don't have to jump very far to get from some people being disappointed with XAML to everyone having to rewrite their code so they don't use it.
  • It can be harder to visualize a UI from just the C# code. (I recognize that this is just my current opinion though.)
  • Separation of concern boundaries are much more easily broken when everything is in one language.
  • Just because XAML isn't a "proper" or full (turning-complete) language is not a reason not to use it. Making changes to a general-purpose language (C#) to make it easier to use for a specific scenario seems equally flawed. In fact, when XAML is treated like a "proper" language it becomes much easier to write, read, and maintain that code. (More on this in a future post.)

I will, of course, admit that creating UIs in C# can (& does) make some things easier to read and understand. However, I don't think that should automatically mean we do away with everything that isn't C#. Also, I'm yet to see very complex UIs defined in C# but have seen many complex scenarios implemented in XAML. 

This isn't to say that complex UIs can't be created in C# as well as XAML, it's more to highlight that the situation is complex. It's very easy to reduce this discussion based on personal experiences but the reality is that XAML and C# are used by a very large number of people to build massively varied types of software with vastly differing specifications, requirements, and uses. There are a minuscule number of absolutes that can be relied upon when discussing the options and what's "best" for everyone.


Where we're at now, things are improving for UIs defined in C#.

But, why not also improve them for XAML too?


Yes, XAML has been stagnant for many years and the plans for a XAML Standard ultimately came to very little. 

Rather than complain about the limitations of XAML (& current tooling) instead let's look at how things could be better.

As you might expect I'm doing some tinkering myself with regards to Visual Studio extensions that can be useful, but the XAML-related capabilities are almost entirely without the ability to customize or extend them.

I know it's not reasonable to expect big changes to be made quickly but I don't think it's unreasonable to ask Microsoft to consider improving the tooling that's currently available. So, I'm starting with a very basic suggestion: Add support for compiler directives in XAML. VS/WPF request, WinUI request, .NET MAUI request. (Yes it's sad that there isn't a single place to do this.)

It'd be great to see some more people add thoughts to those proposals. <hint /> 😉




Saturday, January 29, 2022

3 reasons I'm learning about CSS

  1. To get ideas for things that can be improved in XAML. Seeing some of the cool things that can be done in CSS makes me wish we had equivalents when working with XAML. (No more details here yet, but I have a list of ideas...😉) 
  2. So I'm better able to make the switch to "web developer". I know some people effortlessly switch between XAML and web technologies--but that's not me. I, of course, also know that it's possible to create websites using XAML. It's many years since I did any serious web development and I know a lot has changed in that time. I'm also aware that there are a lot more employment opportunities in "regular" web development and I can't live on my savings forever and XAML work is hard to come by. I'm hedging my bets by learning something that may help me now or in the future.
  3. So I can learn from smart people. Regardless of the technologies, there is often much that can be learned by watching smart people doing their work and solving problems. Watching how experts in another language think about and solve problems can be insightful and help me think about things in new ways too.

updated Feb 3rd, 2022

Friday, January 28, 2022

Windows Template Studio - reborn!

It was only a few weeks ago that I publicly announced that I'd given up on Microsoft taking the Windows Template Studio forward and so I was going to do it myself.

Now, things are changing again.

  • The official Microsoft project has been reborn as just Template Studio. (Yes, that's the name I was going to use too.)
  • I'll be bringing the work I've done on my own back to Microsoft's repository and the Windows-related apps that can be generated with it will all come from Microsoft.
  • I'll continue contributing as a "community member".
  • The extensions I've already released as previews (for UWP, & WPF) will stay as previews and be removed once official Microsoft equivalent versions become available.
  • I'm reserving the right to build my own extensions that can be used for things other than Windows apps.
  • There's more on the official roadmap.

As expected, the most common question right now is about the timeline.

The answer is that it's likely to take a few more weeks.

This is because:

  • I can't take my work "as is" and copy it all over. There are things I can't, don't want to, and shouldn't share from my code.
  • What's required in the official repo is different from my personal requirements.
  • There's functionality my version has removed that I need to find ways to reinstate for the official/public version.
  • There are still [regression] issues in my version (the previews) that I need to fix.


How can you help?

  • Try out the preview versions I've released. (There are some things that behave differently in the release builds and so need testing widely--which I can't do in testing.)
  • Raise any bugs or issues for things you find. (Are there things I've missed? If no one reports the things that I think are regressions, maybe they don't need fixing...)
  • Consider becoming a sponsor. You'll be credited in the previews and elsewhere, but I obviously can't include such images in the official Microsoft version. :(
Sponsor images shown in the wizard

Any other questions? You know where I am. ;) 

Wednesday, January 12, 2022

Reasons to ask a question

I've been thinking a lot about communication (I know--fun, right?!) and especially about questions. This is because asking and responding to questions (not just answering them) is a large part of communication.

So, 12(+) reasons to ask a question:

  1. To get an answer.
  2. To force others to think about the question's topic.
  3. To encourage someone to think about how they'd answer (even if they don't.)
  4. To get attention. 
  5. To get a response (that isn't a direct answer.)
  6. To show (admit?) that you don't know (everything.)
  7. To show a willingness to learn.
  8. To show that asking questions is good/ok/acceptable/encouraged.
  9. To show an example of questions that can be asked.
  10. To show that you've thought about (or researched) the subject enough to be able to ask smart, informed, appropriate questions.
  11. So others can hear the/their answer.
  12. Never for no reason. 
  13. Other?

I know the above is a generalization, and it won't apply to all scenarios but is a helpful summary of the things to consider.


Thursday, January 06, 2022

Template Studio for WPF

Following on from UWP, I've now released a preview of Template Studio for WPF.

Why WPF? - Because it has a similar position within WinTS as UWP. That is, it is (I suspect) less likely to have a future in WinTS which is likely to (again--I suspect) continue to be increasingly focused on WinUI.

WPF also has an opportunity for a longer life than UWP. Because of this, I plan to extend the provided options and add the ability to create WPF apps that are based on .NET 6.

More importantly, to do this I've got the codebase to a place where it can produce multiple different extensions that build for different platforms and happily work side-by-side. This opens the door for lots of exciting new things going forward. (hint hint)

Anyway, give it a try and let me know any feedback.