this post was submitted on 15 Nov 2024
285 points (92.8% liked)
Programmer Humor
32692 readers
275 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Why not? It’s a perfectly human readable representation of that duration, just as intended by ISO.
Just as an example, we use that format to communicate durations between the frontend and backend.
Well, because I'm of a very different opinion about its readability. If you know the format, then sure, you can mostly read it as expected. But our logs are often something that customers or sysadmins will want to read. If it says
Retrying in PT5S...
in there, they'll think that's a bug, rather than a duration.And yeah, I almost figured it was for de-/serialization. I guess, that's something where I disagree with the designers of Java.
In my opinion, you don't ever want to rely on the implicit behavior of the language for your serialization needs, but rather want to explicitly write down how you're serializing. You want to make a conscious decision and document that it's the ISO 8601 format, so that if you need to hook up another language, you have a chance to use the same format. Or, if you need to change the format, so that you can change the one serialization function, rather than having to find all the places where a
.toString()
happens.Admittedly, the Java devs were between a rock and a hard place, due to them having to implement
.toString()
and the meaning of.toString()
being kind of undefined, i.e. it's never stated whether this is a format for serialization, for debugging or for displaying to the user. And then I guess, because it didn't explicitly say "for debugging" on there, they felt it was important to go with a standard format.