News for hackers. Stuff that matters.
Re:Why the fuck are we templating YAML? (2019) by mcculley on Tuesday January 23, 2024 @07:00AM (#39102276)
Indeed. I get a lot of value out of my strongly typed XML documents. I generally have code that validates them during writing and after reading. Those who don’t understand XML end up learning why it is verbose when they eventually add all of the features they need to whatever half-baked format they are using.
Re:Why the fuck are we templating YAML? (2019) by delta_p_delta_x on Tuesday January 23, 2024 @07:18AM (#39102397)
The 'XML is verbose' argument is exactly analogous to the 'static typing is verbose' argument. JSON is decent, but it quickly breaks down if you want to have any sort of static sanitisation on input data, and the weird `"$schema"` attribute is quite strange. YAML makes no sense whatsoever to me.

XML is by far the most bulletproof human-readable serialisation-deserialisation language there is.

Re:Why the fuck are we templating YAML? (2019) by acdha on Tuesday January 23, 2024 @07:49AM (#39102673)
> The 'XML is verbose' argument is exactly analogous to the 'static typing is verbose' argument.

It’s two things: the static typing analog is definitely there but I’d extend the comparison to something like the J2EE framework fetish & user-hostile tools, too. There were so many cases where understanding an XML document required understanding a dozen semi-documented “standards” and since few of the tools actually had competent implementations you were often forced to write long-form namespace references in things like selectors or repeat the same code.

I worked with multiple people who were pretty gung ho about static typing everything but the constant friction of that self-inflicted toil wore over time. I sometimes wonder whether something more in the Rust spirit where the tools are smart enough not to waste your time might be more successful.

Re:Why the fuck are we templating YAML? (2019) by smaudet on Tuesday January 23, 2024 @11:48AM (#39105875)
I agree. Here in 2024, I hope everyone agrees that types are great.

Static types, aren't just verbose, they're clunky. They only work in a perfect world - dynamic types provide the functionality to actually thrive.

> I sometimes wonder whether something more in the Rust spirit where the tools are smart enough not to waste your time might be more successful.

That could help, the problem being XML. You mention the J2EE framework and semi-documented "standards" - the world is rife with bad xml implementations, buggy xml implementations, and bad programmers reading 1 GB xml documents into memory (or programs needing to be re-worked to support a SAX parser).

There's too much baggage at the feet of XML, and the tools that maybe could have helped were always difficult to use/locked behind (absurdly expensive) proprietary paywalls.

JSON started to achieve popularity because as a format, it was relatively un-encumbered. Its biggest tie was to Javascript - if certain tools hadn't been brain-dead about rejecting JSON that wasn't strictly just JSON, it might have achieved same level of type safety as schema-validated XML, without much of the cruft. But that's not what the tools did, and so JSON became a (sort-of) human-readable data-interchange format, with no validation.

So in 2024 we have no good data-x-change formats, just random tools in little niches that make life better in your chosen poison format. We await a rust - a good format with speed, reliability, interoperability, extensibility, and easy-to-use tools/libraries built in.

Re:Why the fuck are we templating YAML? (2019) by mcdonje on Tuesday January 23, 2024 @08:15AM (#39102903)
I think PDML hits a sweet spot. The author didn't set out to recreate XML in a less verbose, more human readable syntax, but pretty much ended up doing so. I'd like to see it mature and gain more widespread adoption.
Re:Why the fuck are we templating YAML? (2019) by robertlagrant on Tuesday January 23, 2024 @07:12AM (#39102363)
Agreed. XML is clunky, no doubt, but it's partly that the tools were just clunky.

Having said that, I do like that you can flip between YAML and JSON. If we could do that with XML (attributes vs sub-elements a problem here) it would be much more useful I think.

Re:Why the fuck are we templating YAML? (2019) by incrudible on Tuesday January 23, 2024 @09:56AM (#39104125)
An XML document without a schema is strictly worse than JSON without a schema. JSON with a schema is strictly better than XML with a schema. XML structure does not map neatly into the data types you actually want to use. You do not want to use a tree of things with string attributes, all over your code. If you do have a schema, the first thing you will want to do is turn your data into native language data types. After that point, the serialization method does not matter anymore, and XML would have just be slower. Designing a schema for XML is also more tedious than for JSON.
Re:Why the fuck are we templating YAML? (2019) by bayindirh on Tuesday January 23, 2024 @10:23AM (#39104570)
> XML structure does not map neatly into the data types you actually want to use.

> After that point, the serialization method does not matter anymore, and XML would have just be slower.

Considering I have mapped 3D objects to (a lot of) C++ objects containing thousands of facets under 12ms incl. parsing, sanity checking, object creation, initialization and cross linking of said objects on last decade's hardware, I disagree with that sentiment.

Regarding your first point, even without a schema, an XML shows its structure and what it expects. So JSON feels its hacked together when compared to XML in terms of structure and expressiveness.

It's fine for serializing dark data where people won't see, but if eyes need to inspect it XML is way way more expressive by nature.

Heck, you even need to hack JSON for comments. C'mon :)

Re:Why the fuck are we templating YAML? (2019) by mcculley on Tuesday January 23, 2024 @10:02AM (#39104199)
I enjoy JSON for internal stuff and where it does not matter that JSON is not very expressive. JSON Schema is a poor substitute for a proper schema. For anything where I am interfacing with another person or team, I send them a DTD or XSD, which documents the attributes and does not have nonsense like confusing integers and floating point values.

For quick and dirty, I agree about JSON. For serious data interchange, I use XML.

Re:Why the fuck are we templating YAML? (2019) by mcculley on Tuesday January 23, 2024 @10:48AM (#39104938)
> JSON with a schema is strictly better than XML with a schema.

I am baffled by this assertion. XML Schema (XSD) is much more expressive than JSON Schema.

Re:Why the fuck are we templating YAML? (2019) by incrudible on Friday January 26, 2024 @12:55PM (#39145530)
That is a bug, not a feature.
Re:Why the fuck are we templating YAML? (2019) by mcculley on Friday January 26, 2024 @01:36PM (#39146178)
Not to me. I have lots of data exchanging going on where the format is expressed well in XSD and in JSON Schema it is expressed through documentation, code, and a history of angry emails.
Re:Why the fuck are we templating YAML? (2019) by incrudible on Saturday January 27, 2024 @03:42PM (#39159631)
If it can't be expressed as a JSON schema, it's a bad idea. If it can be expressed by a JSON schema, it may be a good idea.
Re:Why the fuck are we templating YAML? (2019) by mcculley on Sunday January 28, 2024 @08:50AM (#39165709)
This does not match my experience.

Can you provide some clear explanation or examples of why having less power to express a schema is desirable?

Re:Why the fuck are we templating YAML? (2019) by incrudible on Tuesday January 30, 2024 @05:05PM (#39196520)
Paralysis of choice.
Re:Why the fuck are we templating YAML? (2019) by mcculley on Thursday February 01, 2024 @08:30AM (#39215702)
This remains an unconvincing argument.
Re:Why the fuck are we templating YAML? (2019) by incrudible on Friday February 02, 2024 @06:31AM (#39227499)
Not everybody needs convincing. JSON already won.
Re:Why the fuck are we templating YAML? (2019) by mcculley on Friday February 02, 2024 @07:19PM (#39236316)
It won in places where one does not need to express an integer larger than 2^53. Lots of us have harder requirements.