Is NEON a Better YAML?

Short answer: NO. If you know what I mean.

It seems that YAML's drawbacks have created a niche for alternative better YAMLs. NEON is developed as a part of the Nette Framework and also gained some popularity as a format for PHPStan configs. But is it a better YAML?

Well, YAML's Norway Problem...

country_names:
    DK: Denmark
    NO: Norway  # this works ok
    SE: Sweden
scandinavia:
    - DK
    - NO        # but this is still false
    - SE

... check.

Weird but valid PHP specific syntax:

# this hash&array mixture is common in PHP world but meaningless in other languages
# also it's impossible in yaml
php_array:
    - 1
    - 2
    - 3
    four: 4
    five: 5
    six: 6

becomes

{
    "php_array": {
        "0": 1,
        "1": 2,
        "2": 3,
        "four": 4,
        "five": 5,
        "six": 6
    }
}

... check.

Okay, maybe its weird killer feature, entities, is useful for somebody but the rest of the language looks like a worse YAML to me.

Update (2020-06-15):

Weirdly significant whitespace:

# compare to the example above
# this will work exactly like yaml and produce exactly what's expected
php_array:
- 1
- 2
- 3
four: 4
five: 5
six: 6

becomes

{
    "php_array": [
        1,
        2,
        3
    ],
    "four": 4,
    "five": 5,
    "six": 6
}

... WTF? I mean, this is fine and logical but it makes the previous example even worse.

Comments

Comments powered by Disqus