this post was submitted on 08 Sep 2024
1210 points (98.2% liked)

Programmer Humor

32031 readers
1280 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 173 points 1 week ago (8 children)

Some data formats are easy for humans to read but difficult for computers to efficiently parse. Others, like packed binary data, are dead simple for computers to parse but borderline impossible for a human to read.

XML bucks this trend and bravely proves that data formats do not have to be one or the other by somehow managing to be bad at both.

[–] [email protected] 49 points 1 week ago (1 children)

The thing is, it was never really intended as a storage format for plain data. It's a markup language, so you're supposed to use it for describing complex documents, like it's used in HTML for example. It was just readily available as a library in many programming languages when not much else was, so it got abused for data storage a lot.

load more comments (1 replies)
[–] [email protected] 25 points 1 week ago (2 children)

Strong competition from yaml and json on this point however

[–] [email protected] 42 points 1 week ago (4 children)

JSON not supporting comments is a human rights violation

[–] [email protected] 13 points 1 week ago (1 children)

IIRC, the original reason was to avoid people making custom parsing directives using comments. Then people did shit like "foo": "[!-- number=5 --]" instead.

load more comments (1 replies)
load more comments (3 replies)
[–] [email protected] 32 points 1 week ago (14 children)

Alright, the YAML spec is a dang mess, that I'll grant you, but it seems pretty easy for my human eyes to read and write. As for JSON -- seriously? That's probably the easiest to parse human-readable structured data format there is!

[–] [email protected] 9 points 1 week ago (2 children)

it is anything but easy to read if your entire file does not fit on a single screen.

load more comments (2 replies)
load more comments (13 replies)
load more comments (6 replies)
[–] [email protected] 143 points 1 week ago (2 children)
[–] [email protected] 18 points 1 week ago (2 children)

Disagree. I prefer XML for config files where the efficiency of disk size doesn't matter at all. Layers of XML are much easier to read than layers of Json. Json is generally better where efficiency matters.

[–] [email protected] 17 points 1 week ago (1 children)
load more comments (1 replies)
load more comments (1 replies)
load more comments (1 replies)
[–] [email protected] 90 points 1 week ago (1 children)

Wow, that's a very passive aggressive reaction. I enjoyed a lot.

[–] [email protected] 46 points 1 week ago (2 children)

This is what happens when stack overflow is used for training.

[–] [email protected] 21 points 1 week ago (1 children)

Not long before AI just tells me to google it, or read the manual.

load more comments (1 replies)
load more comments (1 replies)
[–] [email protected] 73 points 1 week ago (7 children)

Don't drink the JSON coolaid. XML is fine. Better, in many cases, because XML files actually support comments.

In the modern programming world, XML is just JSON before JSON was cool. There was a whole hype about XML for a few years, which is why old programming tools are full of XML.

It's funny but sad to see the JSON ecosystem scramble to invent all of the features that XML already had. Even ActivityPub runs on "external entities but stored as general purpose strings", and don't get me started on the incompatible, incomplete standards for describing a JSON schema.

It's not just XML either, now there's cap'n proto and protobuf and bson which are all just ASN.1 but "cool".

[–] [email protected] 26 points 1 week ago (6 children)

IMHO: XML is a file format, JSON is a data transfer format. Reinventing things like RSS or SVG to use JSON wouldn't be helpful, but using XML to communicate between your app's frontend and backend wouldn't be either.

[–] [email protected] 21 points 1 week ago (6 children)

Most web frameworks contain code to exchange JSON over XMLHttpRequest for a reason. XML is and always has been a data transfer format as well as a file format. JSON is, too. The amount of config.jsons I've had to mess with...

but using XML to communicate between your app’s frontend and backend wouldn’t be either

I don't see why not? The entrypoint of web frontends is sent as HTML already. I guess that's based on SGML, XML's weird and broken cousin. Outputting XML is just a matter of configuring whatever model serialiser from JSON to XML.

There are a few good arguments against XML, but those also work against JSON.

load more comments (6 replies)
load more comments (5 replies)
[–] [email protected] 25 points 1 week ago (5 children)

That's my biggest peev about JSON actually. No comments!! WTH!

[–] [email protected] 15 points 1 week ago* (last edited 1 week ago) (3 children)

On one hand I agree, on the other hand I just know that some people would immediately abuse it and put relevant data into comments.

[–] [email protected] 9 points 1 week ago (1 children)

do they do that in xml? never seen that

load more comments (1 replies)
load more comments (2 replies)
load more comments (4 replies)
[–] [email protected] 13 points 1 week ago* (last edited 1 week ago) (2 children)
{ "key": "six",
  "value": 6,
  "comment": "6 is a bad number. Use five." }
[–] [email protected] 28 points 1 week ago (1 children)

That's not a comment, that's a field. There's a reason var comment = "Increments i by 1" isn't how you comment in any programs.

load more comments (1 replies)
[–] [email protected] 17 points 1 week ago

Please don't. If you need something like json but with comments, then use YAML or TOML. Those formats are designed to be human-readable by default, json is better suited for interchanging information between different pieces of software. And if you really need comments inside JSON, then find a parser that supports // or /* */ syntax.

[–] [email protected] 11 points 1 week ago (2 children)

And there are some truly magic tools.

XSDs are far from perfect, but waaay more powerful than json schema.

XSLT has its problems, but completely transforming a document to a completely different structure with just a bit of text is awesome. I had to rewrite a relatively simple XSLT in Java and it was something like 10 times more lines.

load more comments (2 replies)
load more comments (3 replies)
[–] [email protected] 71 points 1 week ago (2 children)
[–] [email protected] 15 points 1 week ago

Except for obvious typos

load more comments (1 replies)
[–] [email protected] 70 points 1 week ago

a wate of time

[–] [email protected] 59 points 1 week ago (1 children)
[–] [email protected] 62 points 1 week ago* (last edited 1 week ago) (2 children)
[–] [email protected] 27 points 1 week ago (5 children)

Lots or file formats are just zipped XML.

I was ~~reverse engineering~~ fucking around with the LBX file format for our Brother label printer's software at work, because I wanted to generate labels programmatically, and they're zipped XML too. Terrible format, LBX, really annoying to work with. The parser in Brother P-Touch Editor is really picky too. A string is 1 character longer or shorter than the length you defined in an attribute earlier in the XML? "I've never seen this file format in my life," says P-Touch Editor.

load more comments (5 replies)
load more comments (1 replies)
[–] [email protected] 44 points 1 week ago (3 children)

I hate writing xml with a passion

[–] [email protected] 31 points 1 week ago (1 children)

If you are writing it then you are doing it wrong.

load more comments (1 replies)
load more comments (2 replies)
[–] [email protected] 38 points 1 week ago* (last edited 1 week ago) (1 children)

It’s not a waste of time… it’s a waste of space. But it does allow you to “enforce” some schema. Which, very few people use that way and so, as a data store using JSON works better.

Or… we could go back to old school records where you store structs with certain defined lengths in a file.

You know what? XML isn’t looking so bad now.

If you want to break the AI ask instead what regex you should use to parse HTML.

[–] [email protected] 10 points 1 week ago (2 children)

Had to work with a fixed string format years ago. Absolute hell.

Something like 200 variables, all encoded in fixed length strings concatenated together. The output was the same.

...and some genius before me used + instead of stringbuilders or anything dignified, so it ran about as good as lt. Dan.

load more comments (2 replies)
[–] [email protected] 32 points 1 week ago
[–] [email protected] 30 points 1 week ago

I'm starting to like this AI thing...

[–] [email protected] 26 points 1 week ago (2 children)

I'm sorry which LLM is this? What are its settings? How'd you get that out of it?

And how did it give sources?

[–] [email protected] 60 points 1 week ago (1 children)

I’m sorry which LLM is this?

It's perplexity.ai. I like it because it doesn't require an account and because it can search the internet. It's like microsoft's bing but slightly less cringe.

How’d you get that out of it?

The screenshot is fake. I used Inspect Element.

[–] [email protected] 18 points 1 week ago (2 children)

perplexity.ai

Like DuckDuckGo's AI's, but with sources? Sounds cool, thanks!

fake

Ah... Too bad (:

load more comments (2 replies)
load more comments (1 replies)
[–] [email protected] 19 points 1 week ago (2 children)

XML is good for markup. The problem is that people too often confuse "markup" and "serialization".

load more comments (2 replies)
[–] [email protected] 16 points 1 week ago

RSS/ATOM has to be the best thing to come out of XML

[–] [email protected] 16 points 1 week ago (1 children)

BASED. What is the name of this AI? I want to use this.

load more comments (1 replies)
[–] [email protected] 14 points 1 week ago

Listen we all know deep down the solution is to try to parse it with regex

[–] [email protected] 13 points 1 week ago (1 children)

stuff like this is how reddit found out their users comments were being used 😂

[–] [email protected] 11 points 1 week ago (11 children)

It is very cool, specifically as a human readable mark down / data format.

The fact that you can make anything a tag and it's going to be valid and you can nest stuff, is amazing.

But with a niche use case.

Clearly the tags waste space if you're actually saving them all the time.

Good format to compress though...

[–] [email protected] 18 points 1 week ago (1 children)

I disagree, with a passion.

It is soooo cluttered, so much useless redundant tags everywhere. Just give JSON or YAML or anything really but XML...

But to each their own i guess.

load more comments (1 replies)
load more comments (10 replies)
load more comments
view more: next ›