Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm hoping this question fits within the scope of Programmers SE and that it's not too open ended.

I've always hated GUI design. I don't mean to offend anyone, but I've hated CSS/HTML, I've hated Java Swing, I can't stand any type of GUI editor, and in general I don't have any skill making anything look nice.

But then the Android platform came around, and I've been in love with it ever since. GUI design isn't a problem anymore, because the abstraction of the design in XML files (which combine both structure and style) out of the code (Java files). It was clean, easy to use, and very extensible. Making themes was incredibly easy, and it followed the same structure as the concept of overriding in computer science.

This brings me to my question. The Android platform was released in 2007. It's been 5 years as of the posting of this question. And yet I haven't seen this idea of XML for GUI design pop up anywhere other than for Android. (For reference on how android design works, here's an official hello world tutorial)

Are there any cons that would make using XML for GUI design a bad choice for either web or desktop development? Are there any other reasons why this type of model would be hard to make or use or simply any reason preventing it from becoming widespread?

As for a little context, this question popped into my head as I was recently struggling with a GridBagLayout in Java.

share|improve this question

closed as not constructive by Thomas Owens Jan 7 '13 at 13:00

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

3  
In the Windows world, WPF, Silverlight, Windows Phone and Windows 8 Metro apps all use XAML - which is an XML definition of a GUI similar to what you seem to be describing here. –  Carson63000 Jan 7 '13 at 2:10
    
@Carson63000 Are WPF and Silverlight desktop technologies? It's interesting that Windows 8 is using it since it seems to be a table/desktop blend. –  gsingh2011 Jan 7 '13 at 2:17
    
Also, Plasma (KDE) supports it (e.g. Google Gadgets) in the Linux world. –  Tim Post Jan 7 '13 at 2:19
    
GTK+ uses gladexml for layout as well –  Karthik T Jan 7 '13 at 2:58
    
Flex has been using it since the beginning as well. –  Devdatta Tengshe Jan 7 '13 at 3:28
show 10 more comments

2 Answers

XML has caught on in GUI design mainly because of the advantages it offers in maintainability and GUI separation. Depending on the language and implementation XML GUI design could expose the following flaws if the XML is being loaded dynamically:

  • Performance issues while parsing the XML at runtime
  • Security implications of transferring and reading the XML (XML is a text based format)


If one considers the example of C#, the default compilation process (compiled XAML), compiles the XML (or XAML) into a compact form called BAML which is then embedded in the assembly with the code behind class. In this case you loose the advantage of dynamically changing the GUI, but the issues mentioned earlier are alleviated.


More information

share|improve this answer
add comment

And yet I haven't seen this idea of XML for GUI design pop up anywhere other than for Android.

As the comments have pointed out, there are a number of technologies using the application GUI + GUI or XAML approach.

  • WPF | Silverlight | Windows Phone | Windows 8
  • Plasma (KDE) / Google Gadgets
  • GTK+ with gladexml
  • Flex

Are there any cons that would make using XML for GUI design a bad choice for either web or desktop development? Are there any other reasons why this type of model would be hard to make or use or simply any reason preventing it from becoming widespread?

One of my biggest complaints with a XAML approach is that it still requires code-behind. Code-behind is an additional source code file that backs the XML application / GUI file. There are a number of programming constructs required at the GUI layer that XML simply can't support.

  • event handlers
  • type conversion (aka WPF and Silverlight converters)
  • looping constructs
  • method calls

I dislike code-behind because it's an additional source of information about the GUI, and I constantly have to toggle between the UI and code portions as I'm working through an issue at that layer. It's just more work on my part, so I dislike code-behind.

There are approaches that can be taken to minimize the amount of code-behind and make it more workable. However, it's still a detractor to the approach.

I wouldn't go so far as to say it's a "bad" approach. It's viable and it has benefits over previous approaches. There's still room for improvement though.

share|improve this answer
    
I would contest whether programming constructs that you suggest are really required in XML. The entire idea to separate the GUI from the logic or code behind and allowing GUI specialists to work independently would be compromised. –  Devendra D. Chavan Jan 7 '13 at 12:18
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.