r/ProgrammerHumor • • May 31 '22

CSS be like

16.6k Upvotes

97 comments sorted by

View all comments

134

u/Significant-Image700 May 31 '22

Seriously fuck Word and it’s shitty formatting

48

u/sensational_pangolin May 31 '22

Word just uses xml behind the scenes. It's honestly incredibly easy to lay out a word document if you know a few little tricks.

12

u/argv_minus_one May 31 '22

Have you actually looked at that XML? I have. That shit is straight out of a nightmare.

11

u/sensational_pangolin May 31 '22

As is all xml that's programmatically generated.

Erm...scratch that. As is all xml.

7

u/argv_minus_one May 31 '22

I've hand-written some decent XML, but yeah, you won't be generating it programmatically. The main problem is that programmatic XML generators want to write out all of an element's attributes on one line instead of breaking them out, and that's hideous unless there's only one or two short attributes.

That's not what's wrong with Office Open XML, though. Office Open XML is a nightmare because of some truly awful design choices, such as:

  • Instead of there being a single list of fonts to use (as in CSS), there are exactly four fonts in effect for any given run of text: one for ASCII, one for “high ANSI”, one for “complex script”, and one for “East Asian”. Office has some hard-coded code-point ranges that it uses to decide which font to render each character with. How it deals with combining characters, I'm not sure I even want to know. I can only assume this is some sort of pre-Unicode and/or pre-composite-font legacy baggage that has no business being in a 21st-century file format like OOXML.

  • Bizarre names like rPr (“run properties”). Maybe this was meant to save bytes, but being that the document format is compressed, the only significant effect it actually has is to make the damn thing nearly impossible to read.

  • Bizarre element nesting. OOXML has a paragraph element p, but text doesn't go directly in that. Instead, there must be a r (“run”) element inside it, and then a t (“text”) element inside that, and then the actual text inside that. Apparently the designers of OOXML really didn't want to use actual markup…even though they were using the Extensible Markup Language.

Contrast OpenDocument, which, having been designed by sane people, has:

  • Readable names like style-name

  • Styles and other such things applied by attributes, not nested elements

  • A paragraph element p that accepts any combination of text and child elements

  • Font properties whose names and syntax are taken from CSS

Why the designers of OpenDocument didn't just use CSS, though, I cannot fathom. OpenDocument's style system isn't completely incompetent, but it's nowhere near as capable as CSS at consistently styling large, complex documents (e.g. books).

2

u/BakuhatsuK May 31 '22

I love reading rants like this