[Info-vax] XML, JSON and YAML, was: Re: Security, support and VMS, was: Re: A new VMS?
Arne Vajhøj
arne at vajhoej.dk
Wed May 5 10:36:45 EDT 2021
On 5/5/2021 8:43 AM, Simon Clubley wrote:
> On 2021-05-04, Arne Vajhøj <arne at vajhoej.dk> wrote:
>> On 5/4/2021 4:45 PM, Simon Clubley wrote:
>>> On 2021-05-04, Arne Vajhøj <arne at vajhoej.dk> wrote:
>>>> Which of the below are most readable?
>>>
>>> JSON, especially if it is formatted in Whitesmiths style.
>>
>> Really?
>>
>> The curly brackets and the double quotes make it more readable.
>
> Was there a question mark at the end of that sentence ?
Yep.
> If so, yes.
> They give it nice visible structure without going over the top as XML does.
I doubt it. Maybe try apply it to English.
=>
{ "I" doubt it } { Maybe try apply it to "English" }
:-)
>>> This is horrible and does not have enough structure to be robust
>>> against editing errors when being manually edited.
>>>
>>> Errors in both XML and JSON can be detected much more reliably
>>> by a parser than errors in the above YAML example.
>>
>> You do not write much Python do you?
>
> I write quite a bit of Python. I also dislike how whitespace is used
> in Python as well.
>> Using indentation for structure may seem weird for
>> those familiar with begin end and { }, but that does
>> not necessarily make it more error prone.
>
> I am familiar with Wirth style block structure, C style block structure
> and whitespace style block structure and the whitespace style block
> structure is horrible compared to the first two.
Everyone is entitled to like or not like a certain style.
But it is an observable fact that millions of people are able
to use indentation for structure.
>> And even if an indentation is wrong then it will typical
>> result in an error (rather similar to JSON - XML can
>> be validated against a schema, which does a better
>> check).
>>
>> Sometimes it is easier with an example.
>> $ type good1.yaml
>> ab:
>> a: 1
>> b: 2
>> c: 3
>> $ java -cp ..:snakeyaml-1_12.jar "yaml.Demo1" good1.yaml
>> 1 2 3
>>
>> all good, but let us see what happens if the indentation of
>> the YAML gets messed up.
>>
>> $ type bad1.yaml
>> ab:
>> a: 1
>> b: 2
>> c: 3
>> $ java -cp ..:snakeyaml-1_12.jar "yaml.Demo1" bad1.yaml
>> java.lang.NullPointerException
>> at yaml.Demo1.main(Demo1.java:20)
>
> A NullPointerException error is _really_ bad here. Ideally, the
> syntax should allow some type of a syntax error exception or error
> along with the suspected line number causing the error.
>
> Failing that, even raising an exception saying that you could not find
> an expected element (and including the missing element name)
> would be vastly better than just throwing a NullPointerException.
The point is that YAML is no different than JSON or a VMS logical
or most else.
If something is not configured the info is missing.
If the code explicit test for whether it is present then it can
give a user friendly error message.
If the code does not check then something bad happens.
The only format I can think of that detect that type of problem
without explicit application code is XML with schema and a validating
parser.
And XML schema does not exactly improve readability.
Arne
More information about the Info-vax
mailing list