Why the Minecraft community picking YAML as the standard configuration file format was a mistake.

December 8, 2012 at 8:13 PMPhonicUK

This is a mixture of opinion and rant about why YAML is not well suited for the way the Minecraft community uses it, and how bad plugin developers are making the problem worse.

YAML (Yet Another Markup Language) is a relatively new markup language. It's goal is to be human friendly way to serialize data. With YAML you can represent a piece of data that can be understood easily by a piece of software and also easily readable by a human. As something for humans to write however, it's not so great.

Compare the following three snippets:


    interests: [video games, movies]
    full name: Joe Bloggs
    age: 25


       - 'video games'
       - 'movies'
    'full name': 'Joe Bloggs'
    age: 25


  "Joe": {
    "interests": [
      "video games", 
    "age": 25, 
    "full name": "Joe Bloggs"

So right away there are a number of problems:

  • All three of them represent exactly the same data, yet they look very different. A YAML parser will give the exact same result for all 3 of them.
  • You can't tell just by looking at it whether or not I used tabs or spaces unless you're using a text editor which specifically highlights the difference.
  • You can't mix-and-match certain styles in the same document, even though they may look very similar.
The keen eyed among you will notice that #3 is also valid JSON as well as YAML. Also note that in example #2, you can increase the amount of indentation for Joe's interests to any amount you like, and it's absolutely fine as long as they are both the same. The single quotes are also entirely optional, you could have 'video games' with quotes and movies without quotes and it'd be perfectly valid.
The problem is that with so much variation and style, writing proper YAML can get tricky very quickly, especially for larger documents. With something like XML it's harder to go wrong as the format is much more rigid.
Largely the community as a whole has settled on the 2nd style shown, and you'd think that'd be the end of it.
The remaining problems are not so much down to YAML, but the behaviour of Minecraft plugin developers.
A number of plugins, instead of using a full YAML parser - instead have their own parser that only works with a very specific style. They are no longer using YAML but merely a extremely restricted subset.
The following are the kind of bad behaviours exhibited by some plugins:
  • Mandating certain levels of indentation (2/4 spaces) even though the YAML spec doesn't care as long as it's consistent within the document.
  • Failing for lists if they either do or don't have enclosing single quotes (even though it's valid regardless)
  • Not supporting the square bracket syntax for lists (as seen in example #1)
  • Insisting that strings either don't or do have single quotes around them, despite the spec allowing either (or even for you to mix freely, as you may need to quote integer values that are meant to be strings, but not something that is definitely a string)
  • Requiring that elements are in a certain order (swapping around the age and full name for example causing the plugin to crash)
YAML is a very flexible format, deliberately so because it's made for humans. Yet some plugin developers feel the need to completely throw that out the window.
If a more rigid format like XML was used then it seems less likely that developers would be trying to write poor implementations based on the subset of YAML they happen to like.

Posted in: Minecraft | Servers


Comments are closed