News for hackers. Stuff that matters.
Re:XML is better than YAML by nielsbot on Wednesday September 20, 2023 @02:19PM (#37587811)
XML is well structured, typed and general purpose, but it's a pain for humans to edit. I think the editing pain is one of the main reasons people look for XML alternatives. Personally I wish XML was written a lot more like HAML.
Re:XML is better than YAML by thechao on Wednesday September 20, 2023 @02:42PM (#37588189)
HAML reminds me of a "whitespace sensitive" ML we used that's 1:1 with XML:

    node @attr="bob saget"
      subnode @foo="john"
      subnode @ham="bar baz"
      html:h1
        p $"this is literal text"
It's ok.
Re:XML is better than YAML by MathMonkeyMan on Thursday September 21, 2023 @12:48AM (#37593338)
Put some parentheses in there and you're good to go :)
Re:XML is better than YAML by thechao on Saturday September 23, 2023 @02:00PM (#37625676)
It's from a language called BOOT which is parenthesis-free Lisp!
Re:XML is better than YAML by tremon on Wednesday September 20, 2023 @02:40PM (#37588145)
I would rather say that XML is untyped (an XML document only contains text of various flavours), and that is why the only concrete example given works in XML but would fail in YAML or JSON:

  “test this against Go 1.20”
  > It interprets that as Go 1.2. 
Well, understand your data format before complaining. YAML, like JSON, understands data types. If you were to write { value: 1.20 } in JSON, it would similarly be interpreted as the numeric value 6/5. The only reason this works "magically" in XML is because XML itself doesn't have data types, it only has text, and the interpretation is left to the user rather than done by the parser.
Re:XML is better than YAML by kaba0 on Wednesday September 20, 2023 @02:45PM (#37588238)
XML schema definitely has types.
Re:XML is better than YAML by tremon on Wednesday September 20, 2023 @03:05PM (#37588562)
Nice, I wasn't aware of that. But it doesn't change the argument much: the XML document still only contains text data, and it's the schema validation phase that's responsible for converting the data into the correct format. Validating an XML document is an optional step, and I'm not aware of many tools that use XML as their config that perform full schema validation.

To add, the XML specification on decimal data types [0] explicitly says: Precision is not reflected in this value space; the number 2.0 is not distinct from the number 2.00 -- so a decimal data type in an XML document would have the exact same problem as the YAML example in TFA; the only difference is that with XML, the authors of the tool would have to actively shoot themselves in the foot by annotating that element as a decimal type rather than text.

[0] https://www.w3.org/TR/xmlschema11-2/#decimal

Re:XML is better than YAML by ImPostingOnHN on Wednesday September 20, 2023 @08:18PM (#37591763)
> the XML document still only contains text data

this is like saying Java is untyped because the source files are just text

Re:XML is better than YAML by tremon on Thursday September 21, 2023 @09:47AM (#37597564)
Only if you cut off the sentence like you did.

My full sentence is more like saying Java is untyped if it were possible to run Java source files from the AST while skipping the type validation step, which seems pretty much a truism to me.

Re:XML is better than YAML by kaba0 on Thursday September 21, 2023 @11:40AM (#37599321)
Is there anything that is type safe without a type validation step? That doesn’t really make sense.
Re:XML is better than YAML by atmavatar on Wednesday September 20, 2023 @08:29PM (#37591824)
The problem isn't that XML's decimal type doesn't distinguish between 1.2 and 1.20 - it's that versions aren't decimals in the first place.

The fact that versions often contain numbers separated by decimal points or that often times, versions only have two components or that minor versions may rarely exceed 9 for a particular product are merely coincidences.

Re:XML is better than YAML by nickm12 on Friday September 22, 2023 @02:47AM (#37608712)
I don't understand why you are being downvoted. You're absolutely right, though I'd nitpick and say not say "untyped" but that the only types that XML gives you are dom nodes and strings.

Contrast that with JSON, which provides booleans, numbers, and the list and object composite types. (side rant: as a standard JSON does not define whether it's numbers are integers, floats, or decimals! a conforming implementation can use whatever type it wants).

Yes, XML has (multiple) schema definition languages that can be used to enforce that the strings can be coerced into specific types, but XML itself conveys no type information in-band about the values. I think this is one of the reasons it is difficult read and write by hand.

Re:XML is better than YAML by smarx007 on Wednesday September 20, 2023 @02:31PM (#37587990)
XML is a data format for correct exchange of information between computer systems. Human-friendly editing was never the no 1 goal for its designers. And with good tools like IntelliJ IDEA, I have easier time editing pom.xml configurations than k8s YAML files, to be honest.
Re:XML is better than YAML by PaulHoule on Wednesday September 20, 2023 @02:40PM (#37588146)
Structured editors have been around since the beginning of XML but they have been slow to catch on generally and have never been that popular because people don’t feel in control.
Re:XML is better than YAML by NBJack on Wednesday September 20, 2023 @07:41PM (#37591527)
Ah, kinda. Yes, they existed, but they frequently didn't have many of the more standard features like autocomplete (particularly on both sides of a new tag) and on-the-fly structure parsing that makes much of the painful parts easier to work with. I think we take for granted how good our modern approaches to IDE assistance can be.

Ever use the earliest IDE incarnations of Eclipse on a PC still measured in hundreds of Mhz, or when RAM was still in the dozens of MB? That was the world XML found itself in during its inception.

Re:XML is better than YAML by fiddlerwoaroof on Wednesday September 20, 2023 @07:44PM (#37591545)
Electric tags in emacs make it mostly not a problem, and most editors have some equivalent: ‘it’ and ‘at’ motions in vim as well as vim-surround and emmet.

But, I agree that this is one of the worst parts of XML

Re:XML is better than YAML by marcosdumay on Wednesday September 20, 2023 @10:17PM (#37592537)
> And with good tools like IntelliJ IDEA

Nah, I have an easier time editing XML in a dumb text editor than YAML with the best tooling I've ever found for it.

In fact, I have an easier time with any of its competitors people post around than with YAML. What is distressing, because the language has clearly the goal of being easy to write.

Re:XML is better than YAML by matsemann on Wednesday September 20, 2023 @02:24PM (#37587880)
At least I've never had production errors because of malformed xml. Yaml, though.. A misplaced dash and your list of a single item is suddenly two distinct items instead.
Re:XML is better than YAML by gilcot on Wednesday September 20, 2023 @02:42PM (#37588197)
You're one of those few lucky whose malformed xml cause no issue.
Re:XML is better than YAML by Groxx on Wednesday September 20, 2023 @02:31PM (#37587989)
Whole I definitely agree yaml is pointlessly prone to this ("NO" lol), I've had plenty of xml issues. Bad manual attribute encoding, duplicate attributes (pretty easy when there are lots) that vary in behavior depending on your xml reader, using text content instead of attributes, using lists of text nodes as a map that then gets deduplicated inconsistently instead of attributes (to work around needing to manually encode complex or multi-line text into an attribute)...

Humans can screw up anything. And more text often allows it to hide for longer.

Re:XML is better than YAML by kaba0 on Wednesday September 20, 2023 @02:46PM (#37588266)
But one of them has schema descriptions to prevent these errors as soon as possible.
Re:XML is better than YAML by Groxx on Wednesday September 20, 2023 @03:27PM (#37588840)
Sure, if you define and use it. Same as yaml schemas (they exist!).

XML has them sorta built in (basically all (notable) libraries support them), but it's not like it's required or somehow innately protected because of that. It's just a bit easier to adopt.

Re:XML is better than YAML by matsemann on Wednesday September 20, 2023 @04:51PM (#37590002)
But my case was with a yaml validated to a schema. A kube ingress file with a list of rules. My additional dash made it a new entry, in practice allowing everything. With xml it would have been very explicit that I now accidentally had made two rules.
Re:XML is better than YAML by throwawaymaths on Wednesday September 20, 2023 @07:20PM (#37591344)
> But one of them has schema descriptions

JSONSchema? It's pretty standardized and well accepted.

Re:XML is better than YAML by NBJack on Wednesday September 20, 2023 @07:50PM (#37591590)
I believe XML has it baked directly into the official spec. JSONSchema is great, but I wouldn't call it a standard yet, and anecdotally I haven't seen it as often as I'd like in use (i.e. I either need to run kubectl --dry-run or use a separate third party solution to validate my changed yaml).
Re:XML is better than YAML by meepmorp on Wednesday September 20, 2023 @08:20PM (#37591777)
XML schema is a separate spec.
Re:XML is better than YAML by kaba0 on Thursday September 21, 2023 @01:42AM (#37593613)
Read the title - just because YAML is a superset of JSON, doesn’t mean you can check every YAML file with JSOnSchema.
Re:XML is better than YAML by EddTheSDET on Wednesday September 20, 2023 @02:37PM (#37588104)
I once had an issue where something failed in prod but not in test, it was because a MAC address was dynamic and in prod only consisted of numbers so whatever tool we used parsed the Yaml value as a sexagesimal number and threw a type error. Yaml can be interesting…
Re:XML is better than YAML by dragonwriter on Wednesday September 20, 2023 @07:29PM (#37591434)
Note that the behavior you describe (like the “NO” problem) was part of the YAML 1.1 excessive-effort-at-DWIM insanity (in this case, intended to make time entry “just work”) that was removed in YAML 1.2.
Re:XML is better than YAML by nikanj on Wednesday September 20, 2023 @02:29PM (#37587961)
Malformed xml sneaks through the kitchen window and poisons you in your sleep. Someone puts naively escaped umlauts (ä -> ä ) into the surname field and your entire xml parser borks with unknown entity errors
Re:XML is better than YAML by kstrauser on Wednesday September 20, 2023 @02:44PM (#37588230)
Pro tip: remember that all JSON is valid YAML. You can put JSON in a .yaml file and be just fine. I find that handy when the explicitness makes it easier to read the file.
Re:XML is better than YAML by marcosdumay on Wednesday September 20, 2023 @10:19PM (#37592547)
As long as you remove all the indenting.

All JSON evaluates to some value in YAML. But it's not always the value you want it to.

Re:XML is better than YAML by throw__away7391 on Wednesday September 20, 2023 @10:59PM (#37592744)
I have. A ton of vendors and APIs generate XML with interpolation or some other form of hand-rolled code that’s incorrectly escaped, which compliant parsers can’t parse and they can’t fix.
Re:XML is better than YAML by KronisLV on Thursday September 21, 2023 @04:49AM (#37594934)
> At least I've never had production errors because of malformed xml.

Oh hey, I had some while making https://hn-blogs.kronis.dev/

I wrote more about it on my blog: https://blog.kronis.dev/articles/ever-wanted-to-read-thousan... but the gist of it is that I had to parse thousands of blog feeds and some article from 2009 included a SOH control sequence inside of otherwise valid XML and this broke everything, until I added additional error handling.

Re:XML is better than YAML by d-lisp on Wednesday September 20, 2023 @02:43PM (#37588198)
XML -> human editable format -> XML

I am searching for this, any clue ?

Re:XML is better than YAML by kaba0 on Wednesday September 20, 2023 @02:45PM (#37588250)
XML -> a not-piece-of-shit IDE/text editor -> XML
Re:XML is better than YAML by d-lisp on Thursday September 21, 2023 @04:54AM (#37594968)
This is fine for me, but I cannot force others to do the same, I use emacs, have good eyes and ability to parse XML; now most of people I work with use less than ideal IDEs.
Re:XML is better than YAML by emmelaich on Wednesday September 20, 2023 @07:53PM (#37591607)
Augeas. And other data formats.

However, before you start, there were bugs that I found, and Augeas is a bit hard to work with.

Re:XML is better than YAML by speed_spread on Thursday September 21, 2023 @01:07AM (#37593425)
Checkout KDL
Re:XML is better than YAML by raydev on Wednesday September 20, 2023 @05:19PM (#37590331)
If a majority of programming nerds weren't so averse to building UI to facilitate more complex actions with better guardrails, we'd probably be better off in many ways. Our desire to not standardize anything beyond "human readable ASCII-like" has held us back, imo.

Xcode's plist editing ability is a mild improvement over manipulating XML text directly, but could use more obvious shortcuts/hotkeys. Even writing XML in an IDE like IntelliJ isn't great, autocomplete should do a lot more.

Re:XML is better than YAML by eviks on Thursday September 21, 2023 @04:20AM (#37594719)
Why would you need text-like XML if you get a good tool that converts to a more useful data entry format? Wouldn't you just use more efficient binary encoding for storage/interchange, while converting to something user-UI-friendly?
Re:XML is better than YAML by raydev on Friday September 22, 2023 @04:45PM (#37617540)
Yeah, I agree, doesn't necessarily have to be XML. But adding a highly productive UI layer on top of existing standards would be a great start.