-1

When you look at products like the Razor view engine, there's a clear reason why Microsoft decided to subset another existing standard (HTML) with their own special sauce thrown in.

But I cannot find any concrete examples why Microsoft decided to subset XML and go with a completely identical standard: XAML. It seems like pure marketing to me. I have not been able to find any example of XAML that is not valid XML. Even data binding is perfectly valid XML - that just being a specially formatted string value.

The only thing I could possibly think of is that they invented their own subset of XML so in the future they could reserve the right to add features to it. But we're pretty far into XAML's lifetime and this has not come to be yet.

So what gives? Are there any concrete examples of genuine differences between XAML and XML that justify the creation of a whole new product? Or is this just a case of Microsoft trying to feel special?

12
  • 4
    XAML is a DSL for declaring UI. XML is a general purpose markup language. How can unlimited XML define UI? Commented Mar 16, 2024 at 18:48
  • 4
    XAML provides meaning to certain XML elements. In that sense, it's completely different from XML which is a ultra-generic specification for encoding any data. Commented Mar 16, 2024 at 18:48
  • 3
    @AlgoRythm The only difference between XAML and Android's XML layout format is that XAML has a name and Android's layouts don't. But they're both XML-based languages to describe app layout. Commented Mar 16, 2024 at 19:40
  • 2
    @AlgoRythm: I am under the impression you had a pretty huge misunderstanding what XML is, and your respond to Basilevs shows me you insist on your misunderstanding. Sorry, but when you ask a question here, you better expect to learn from it that some of your assumptions might be wrong. Commented Mar 17, 2024 at 14:52
  • 1
    From Wikipedia: "Hundreds of document formats using XML syntax have been developed,..." (I would be astonished if it were not actually thousands today, not counting any company-internal XML formats). XAML ist just one of many XML-based document formats. Commented Mar 17, 2024 at 21:04

2 Answers 2

11

XAML isn't a subset of XML or a rival to it. XAML is an XML-based language for declaratively building UI. See this from Microsoft's page on XAML (emphasis mine):

When represented as text, XAML files are XML files that generally have the .xaml extension. The files can be encoded by any XML encoding, but encoding as UTF-8 is typical.

So XAML is a language that is represented as XML, which is precisely what XML was designed to be - an eXtensible Markup Language that has no semantic meaning in itself, it simply defines a set of rules for describing and encoding documents, but it doesn't specify anything about the meaning of those documents - XAML does.

You can compare it with Android's XML-based layout language, which is exactly like XAML - a semantic layer (indicated by the XML namespace) built on top of XML's structure. When Android layouts specify this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" ...>

While XAML defines this:

<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
    >

They're both laying down a semantic schema on top of the basic XML structure.

2

When XAML was developed, XML was still very much in vogue as a general purpose format for storing and exchanging structured data (probably because of the influence of HTML, and the growing popularity of the web in the years preceding).

XAML is not different from XML - XAML is an application of XML to shell design and configuration.

The supposed benefits of XML is that parsers are widely available, there is a transformation language available in the form of XSLT, and it's possible to intermingle data from multiple applications into one XML document.

I suspect XAML was actually developed mainly for the internal needs of Microsoft as one of the largest software developers and vendors on the globe, and pawned off to the market only as a secondary consideration.

One of the thing to note about Microsoft is that it has whole teams (or whole departments) who design the UI separate from those who design and implement the detailed underlying program logic, and it has considerable localisation, accessibility, and automatic testing needs too. I assume Microsoft has a large amount of in-house tooling (and expertise) specifically dedicated to handling XAML.

The prior existing alternatives to XAML were often bound to a particular language or development environment (such as Winforms), or were ancient (such as the "resources" approach, which I think is as old as Windows itself).

A great many of Microsoft's developer community however do not have the complicated needs to which XAML is potentially most suited, nor the division of labour. I imagine the majority of developers who use Microsoft tooling, are so-called full-stack developers who handle an entire application end-to-end.

Also, fervour regarding the general usefulness of XML has abated in the years since (nowadays, JSON seems to be king as the go-to structured data storage format).

I imagine XAML continues to fulfil its function at Microsoft, but if it didn't already exist, I doubt it would emerge into the market in the same form today.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.