Jeremy D. Miller -- The Shade Tree Developer

Sponsors

The Lounge

Syndication

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Can we declare programming in Xml to be dead yet?

I'm writing a brief article today as a brief teaser on my StructureMap lessons learned talk for NDC 2009.  One of the 3 main themes of this talk is just about how our aesthetic expectations of a framework have changed and increased over the last 5 years.  As an example, StructureMap circa 2004 could only be used with copious amounts of verbose Xml and/or StructureMap attributes scattered all over the code.  Personally, I would find the StructureMap of 2004 to be completely unusable and fall far short of the expectations for framework usability I have today in 2009. 

I think the single biggest improvements in StructureMap usage for me personally is using the Registry DSL with Intellisense and type safety to do the configuration as opposed to copious Xml with lots of strings.  The same thing applies to Fluent NHibernate's DSL compared to the old error prone hbm.xml files. 

I did quite a bit of work in server side Java in 2007 and the only thing I remember is how much I hated all the freaking Xml cruft.  I don't have anything against Xml in general, or at least for the things Xml was actually meant for in the first place, but I'm completely done with coding in Xml. 

So my question to you is can we declare the mid-2000's fling with programming by Xml files to be a dead or dying trend?  Is there anyone out there that still believes in "just make it an Xml file so we can change things without compiling?"  Microsoft is still churning out tools that have quite a bit of Xml heft behind them (what's up with their love affair with Xaml?), but do you think that trend is at least waning?


Posted Sat, Mar 14 2009 6:30 PM by Jeremy D. Miller

[Advertisement]

Comments

Brian Yarger wrote re: Can we declare programming in Xml to be dead yet?
on Sat, Mar 14 2009 9:18 PM

While I certainly think XML is dying as the only configuration mechanism of a framework, I still think it's a valuable option, especially for doing overriding configuration details at deployment time.

Jim Greco wrote re: Can we declare programming in Xml to be dead yet?
on Sat, Mar 14 2009 9:32 PM

Completely agree and it's the most liberating thing ever.  All of my configuratiion, even my connectionStrings, are hard-coded.  The advantages of easy testability, refactoring capability, and intellisense blows away any argument for XML.

"especially for doing overriding configuration details at deployment time."

You can do this with a configuration interface and an IoC.

Jeremy D. Miller wrote re: Can we declare programming in Xml to be dead yet?
on Sat, Mar 14 2009 9:38 PM

@Jim Greco,

You're going a little bit farther than I would.  We still keep NHibernate properties, connection strings, and file paths in config files.  It's the StructureMap.config file though.

Victor Kornov wrote re: Can we declare programming in Xml to be dead yet?
on Sat, Mar 14 2009 9:49 PM

You need to make a distinction between admin & developer configuration. They go to different places.

Admin conf in xml or whatever is a good & necessary thing.

matt wrote re: Can we declare programming in Xml to be dead yet?
on Sun, Mar 15 2009 1:55 AM

How much of the pain is due to the amount of crap that has to go into XML that makes the hand coding painful at best (namespaces, angle brackets, closing tags, etc)?

If you had perfect intellisense around a more compact syntax (JSON) and an easy way to know valid vs invalid,  would it be interesting to express your intent in a non-code text file? (you could  argue that you've already got this in C# initialization syntax, but is there benefit in storing this in something other than a compiled assembly?)

How would one build tooling on top of the fluent nhibernate dsl or the structure map registry dsl?  (I ask because I'm not familiar with either (two more todo's added to the queue)).  The nice thing about xaml / xml, etc is that tooling can operate on that pretty easily, as opposed to using codegen  style transformation between the tooling representation and a c# seriialization format.

Jon wrote re: Can we declare programming in Xml to be dead yet?
on Sun, Mar 15 2009 4:48 AM

How do you change configuration for different environments with code over xml? Do you alter code as part of a pre-build event?

Can we declare programming in Xml to be dead yet? - Jeremy D … wrote Can we declare programming in Xml to be dead yet? - Jeremy D …
on Sun, Mar 15 2009 6:52 AM

Pingback from  Can we declare programming in Xml to be dead yet? - Jeremy D …

Can we declare programming in Xml to be dead yet? - Jeremy D … - How To Get Rich wrote Can we declare programming in Xml to be dead yet? - Jeremy D … - How To Get Rich
on Sun, Mar 15 2009 7:37 AM

Pingback from  Can we declare programming in Xml to be dead yet? - Jeremy D … - How To Get Rich

Can we declare programming in Xml to be dead yet? - Jeremy D … - How To Get Rich wrote Can we declare programming in Xml to be dead yet? - Jeremy D … - How To Get Rich
on Sun, Mar 15 2009 7:37 AM

Pingback from  Can we declare programming in Xml to be dead yet? - Jeremy D … - How To Get Rich

Can we declare programming in Xml to be dead yet? - Jeremy D … - How To Get Rich wrote Can we declare programming in Xml to be dead yet? - Jeremy D … - How To Get Rich
on Sun, Mar 15 2009 7:37 AM

Pingback from  Can we declare programming in Xml to be dead yet? - Jeremy D … - How To Get Rich

Can we declare programming in Xml to be dead yet? - Jeremy D … - How To Get Rich wrote Can we declare programming in Xml to be dead yet? - Jeremy D … - How To Get Rich
on Sun, Mar 15 2009 7:37 AM

Pingback from  Can we declare programming in Xml to be dead yet? - Jeremy D … - How To Get Rich

Can we declare programming in Xml to be dead yet? - Jeremy D … - How To Get Rich wrote Can we declare programming in Xml to be dead yet? - Jeremy D … - How To Get Rich
on Sun, Mar 15 2009 7:37 AM

Pingback from  Can we declare programming in Xml to be dead yet? - Jeremy D … - How To Get Rich

Matt Hinze wrote re: Can we declare programming in Xml to be dead yet?
on Sun, Mar 15 2009 10:05 AM

The pendulum is definitely swinging away from XML, and for good reason.  Will it swing too far, and is that possible?  That's the interesting question.

Steve Bohlen wrote re: Can we declare programming in Xml to be dead yet?
on Sun, Mar 15 2009 11:44 AM

I wonder how much of this (movement away from XML towards fluent-config stuff in code) is driven by important software design goals and how much is simply driven by the (relatively) poor tooling support for XML provided by many popular IDEs.

For example, let's assume for a moment that invoking RENAME of a class in the IDE cascaded the rename down into the XML that referenced it...would we *still* find XML config to be unacceptable--?

This reminds me of the legions of (.NET) developers who similarly 'hated and despised' javascript largely due to the poor tooling support for it in Visual Studio rather than as the result of an actual software design decision about the value of javascript in improving their solutions.

I wonder how much of the move away from XML towards config-in-code is really based on tooling limitations vs. design / requirements needs...

Jeremy D. Miller wrote re: Can we declare programming in Xml to be dead yet?
on Sun, Mar 15 2009 12:21 PM

@Steve,

Think readability and expressiveness too.  Plus, even if the tooling got better to give you class, property, and method level intellisense in Xml editing like you'd need to make hbm xml files efficient, think how ugly that ends up looking.

Mike Christiansen wrote re: Can we declare programming in Xml to be dead yet?
on Sun, Mar 15 2009 2:51 PM

Your offhand dis of XAML put me in a defensive mode at first, but when I thought about it I realized it's WPF I'm really a fan of, not XAML per se. I found XAML less cumbersome than traditional WinForms development, but it is cumbersome for the same reasons other forms of XML is cumbersome (although I'd say it's level of Intellisense support is better than most).

I didn't miss the boat on some cool alternative to WPF did I? Or a cool alternative to using XAML with WPF? Bypassing XAML is certainly possible, but I'm not sure how easy it would be to make it concise enough to be readable.

Jeremy D. Miller wrote re: Can we declare programming in Xml to be dead yet?
on Sun, Mar 15 2009 4:19 PM

@Mike,

The problem with Xml is the crazy ways we've used it far and beyond its original intention.  

Personally, I run very hot and cold on WPF.  I love the underlying technology, but I'm iffy on Xaml and I think using WPF programatically is a near nightmare.

I've had some luck using C# DSL's on top of WPF and I still think the WPF + IronRuby combo could be killer.  The raw "push button" API for WPF sucks hard because it's optimized for Xaml rather than developer usability.

Mike Christiansen wrote re: Can we declare programming in Xml to be dead yet?
on Sun, Mar 15 2009 4:46 PM

I was thinking about it a little more and I wonder if it's fair to go after XAML without going after HTML too. Do you perceive a fundamental difference between the idea of laying out the UI in XAML for a client app vs laying it out in HTML for a web app?

Jeremy D. Miller wrote re: Can we declare programming in Xml to be dead yet?
on Sun, Mar 15 2009 4:53 PM

@Mike,

Not really, and I vastly prefer the markup approach or WPF Xaml or Html/CSS versus the WinForms way.  I do wish they'd made WPF's Xaml more of a markup DSL instead of taking the serialization format shortcut.  I think the way they implemented WPF's XAML sacrifices some usability.  I'm also willing to concede that maybe I've just never gotten completely used to Xaml in WPF.

Rob wrote re: Can we declare programming in Xml to be dead yet?
on Sun, Mar 15 2009 9:44 PM

Fluent all the way for me.

We had too much pain with oversized Windsor xml config files. Now they're all fluently loaded in one small class. Much more manageable. Plus it's all strongly typed, so no more runtime errors due to something missing from the xml config. If anything changes we get a compile time error which is much more preferable.

Fluent NHibernate is the next thing we're looking at to make our mapping files a little more robust.

Xml has it's place, but in terms of IoC and NHibernate I don't know why you'd want to be able to change the config once deployed. May as well just have it compiled to start with.

Community Blogs wrote A picture is worth a thousand words: is XML dying?
on Sun, Mar 15 2009 10:43 PM

(does that answer Jeremy's question too ?) Read full article

Jim Greco wrote re: Can we declare programming in Xml to be dead yet?
on Sun, Mar 15 2009 11:31 PM

"How do you change configuration for different environments with code over xml? Do you alter code as part of a pre-build event?"

Never.

It's a simple interface ("IConfig") with different implementations for each environment (each developer has one like "GrecoConfig" for their environments, "QAConfig", "StageConfig", "ProductionConfig", etc.) .    

StructureMap injects the right implementation at run-time.  A system variable controls which one to inject.  One-time setup and you never worry about it again.

Now everything is refactorable;

Testable;

Properties can be complex (i.e., I can have NumDays be an integer instead of a string that is parsed into an integer, I can have a ConnectionStrings object vs. just a string, etc.);

Inheritance (qa, stage, and production use the same sql box, why repeat that 3 times?);

Settings won't allow for compilation if they aren't there (what happens when you forget that new key/value pair that you added to the development xml config but not the production xml config)

I see no reason any of this has to be in XML.  If your deployment system sucks, work on it so deploying a stable build to any environment is a snap.

Frank Quednau wrote re: Can we declare programming in Xml to be dead yet?
on Mon, Mar 16 2009 6:52 AM

This should be expressed as a T-Shirt: "Say NO to XML programming" or something like that. I think I might get some interested...any takers over here?

Jonas Follesø wrote re: Can we declare programming in Xml to be dead yet?
on Mon, Mar 16 2009 7:37 AM

Interesting post Jeremy, and I'm looking forward to meeting you at the NDC this summer. I'm presenting on the MVVM pattern + Silverlight 3 business applications. So as you probably can guess by my choice of topics I'm a big XAML fan.

But you got some interesting points, and I largely agree with you. I always prefer fluent DSL's for config (IoC, Hibernate) over the error prone XML alternative. However, for UI I think the declarative nature of XAML works well – both from a tooling perspective and it’s also a good format for people with a web background. But I think your point about the WPF API being build for XAML, and not for developer friendliness is spot on. I often find my self struggling on how to achieve something using procedural code over XAML, and the code tends to be big, verbose and hard to follow with lots of untyped strings and object casting.

It will be interesting to see if we (as the community) can come up with some other cool alternative approaches to WPF using some UI DSL + the new XAML/BAML Reader and Writer being introduced in WPF 4.0.

Cheers,

Jonas Follesø

rf wrote re: Can we declare programming in Xml to be dead yet?
on Mon, Mar 16 2009 7:50 AM

I find the use of XML in so called build scripts to be a source of particular frustration. XML should only be used for declarative data - in other words, configuration. Referring to an XML file as a "script" indicates a major problem. Only the most trivial builds can be described using declarative syntax alone. Builds of any complexity cause the configuration to quickly become horribly difficult to maintain, and you end up doing much of it in code anyway.

Bryce Fischer wrote re: Can we declare programming in Xml to be dead yet?
on Mon, Mar 16 2009 4:36 PM

I think XML has its use. Like you, I'm skeptical of using it as a configuration file, as it can be quite verbose.

It is quite useful for providing common format for interchange of data. But I think the days of it being considered a "human readable" format are over. With schemas, namespaces, etc... anything but the most simple XML file is far from readable without a good XML editor.

o.s. wrote re: Can we declare programming in Xml to be dead yet?
on Tue, Mar 17 2009 12:23 PM

@Jim Greco

Your design seems much too complicated and it stems from not using XML for what it is meant for which is a portable format for the interchange of data and  *not* code.  So XML is perfectly fine for storing data such as connection strings but a disaster waiting to happen for coding.

Jim Greco wrote re: Can we declare programming in Xml to be dead yet?
on Tue, Mar 17 2009 6:02 PM

An interface and an multiple implementation is too complicated?   Do you find unit testing hard too?  

Jim Greco wrote re: Can we declare programming in Xml to be dead yet?
on Tue, Mar 17 2009 6:05 PM

and an multiple = with multiple

Brian wrote re: Can we declare programming in Xml to be dead yet?
on Tue, Mar 17 2009 10:19 PM

5 years ago when I said all this XML config crap is for the birds I was nailed too the wall....

Anyway though, I'm glad to see this post, it helps me feel vindicated for times in the past where this opinion was very very unpopular in certain circles.

james.kovacs wrote re: Can we declare programming in Xml to be dead yet?
on Tue, Mar 17 2009 11:53 PM

I would argue that programming in XML is alive and well - whether we like it or not. Look at XAML, WF, MsBuild/NAnt, and many other technologies. You might get a pretty design surface over them (which is often more pain in anything beyond demoware), but you're still programming in XML. The fluent APIs in Windsor, StructureMap, Fluent NH, and others are much better than their XML counterparts. Hopefully they continue to draw interest. At the heart of it, XML is a reasonable data format (not perfect, but reasonable), but XML for programming is a PITA. One of my big worries for the next five years... Are DSLs the next XML? A well-crafted DSL can be amazingly productive, but equally so is a well-crafted XML data document. Are we going to throw DSLs at every problem like we did XML and wind up in a similar conundrum in five years time, except with us bemoaning the inappropriate use of DSLs?

AndyB wrote re: Can we declare programming in Xml to be dead yet?
on Wed, Mar 18 2009 4:36 AM

Jeremy / James

A very pleasing and topical post for me. The problems I had with Spring configuration in my last project were unbelieveable and its the major lesson learned. The fluent terminology is new on me (with the exception of Fluent NHibernate) but one that I'm looking out for more and more now that I understand the major drive for it.  

Instinctively, I looked at the other tools that I produce a lot of XML files for and NAnt is the one that jumps out at me.  I've used 2 completely unrelated editor tools in the past. These help me with XML syntax, but not with testability, etc.  Excuse the ignorance, but does anyone know of any fluent NAnt movement?

WOMBAT wrote Has xml programming had its day?
on Wed, Mar 18 2009 7:15 AM

Has xml programming had its day?

WOMBAT wrote Has Xml programming had its day?
on Thu, Mar 19 2009 11:25 AM

Has Xml programming had its day?

igorbrejc.net » Fresh Catch For March 20th wrote igorbrejc.net » Fresh Catch For March 20th
on Fri, Mar 20 2009 1:00 PM

Pingback from  igorbrejc.net » Fresh Catch For March 20th

o.s. wrote re: Can we declare programming in Xml to be dead yet?
on Fri, Mar 20 2009 3:14 PM

@Jim Greco

To answer both your questions. No and no. My *point* is that based on what you were trying to accomplish your code could be simplified to a much simpler design. You have greatly overcomplicated a simple task.

AndrewLV wrote re: Can we declare programming in Xml to be dead yet?
on Fri, Mar 20 2009 5:06 PM

o.s, isn't it really just a different way to look at the same problem?  Where I previously worked we had config files 100s of lines long, considering we had one for each stage of development (at least one dev, QA, Stage, Production), that's a lot of code sitting in XML that is difficult to verify.

Using Jim's method, he has the same number of files, but due to them implementing an Interface, his code won't compile if a setting is missing.  You can't say the same for Xml Configuration Files.

Xml Config Files do let you easily change things on the fly, but I'm not sure that's necessarily a good thing.  Granted, using Castle Windsor, I'm sure you could do the same thing with Jim's method as well.

Done right, I think an IConfig method isn't that complicated at all.

Per Erik Stendahl wrote re: Can we declare programming in Xml to be dead yet?
on Mon, Mar 23 2009 12:00 PM

"Can we declare programming in Xml to be dead yet?"

According to the SharePoint team at Microsoft: HELL NO!

buy wow gold wrote re: Can we declare programming in Xml to be dead yet?
on Wed, Mar 25 2009 4:30 AM

It will depend with the persons or company who'll be using it.

Artie Gold wrote re: Can we declare programming in Xml to be dead yet?
on Fri, Apr 3 2009 4:43 PM

XML provides a syntax that can be easily parsed and easily manipulated -- that is its great strength (think in terms of decorated s-expressions). Using it as a common interchange format makes perfect sense. At the same time, exactly because of its syntactic regularity, placing a syntactic skin on top of it is pretty easy to do -- and you really don't want to be looking at reams of "code in XML" (or anything else, for that matter) in its native form.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?