←back to thread

451 points todsacerdoti | 6 comments | | HN request time: 0.279s | source | bottom
1. mannyv ◴[] No.45059180[source]
Ugh, the syntax for CSS is just so crappy.

I know like 10-15 different languages, and CSS is by far the hardest to read and understand. It's easier to understand x86 assembly than CSS. CSS is basically pre-tokenized input that drives a renderer, but they sort of went halfway and didn't really make it real tokens or really human-writable.

I'd say that it should take the place of ASN.1 in the RFCs as an example of "what not to do."

replies(5): >>45059270 #>>45059328 #>>45061781 #>>45062327 #>>45067645 #
2. icedchai ◴[] No.45059270[source]
I feel the same way. I find it the worst part of the HTML / CSS / JS trio.
3. ZYbCRq22HbJ2y7 ◴[] No.45059328[source]
> I know like 10-15 different languages, and CSS is by far the hardest to read and understand.

CSS is hard to know, even if you know 15 languages.

I can understand many programming languages and write in a subset of many of their features, but I wouldn't claim to know them. That would require a monumental amount of day to day effort, in my opinion (see https://en.wikipedia.org/wiki/Illusion_of_explanatory_depth).

To me, the best way to understand CSS is to evaluate it after rendering, and I have been writing it for decades.

4. jy14898 ◴[] No.45061781[source]
What do you mean by "CSS is basically pre-tokenized input"? Can you give an example of what you have trouble with?
5. lionelw ◴[] No.45062327[source]
How many of those languages are declarative, or domain specific?

There's no use comparing CSS and assembly. It betrays a shallow understanding of CSS. Points to ponder:

- Assembly is superlatively imperative while CSS is the opposite. The difference can be jarring for some. It's commonly felt in day-to-day frontend work that switching to CSS (declarative) from almost anything else (imperative) -- JavaScript, PHP, etc. -- requires a significant mental shift, though it does get easier with experience.

- Lot of the vocabulary and concepts used in CSS come from outside the computing world, namely design and publishing. It's somehow a rarely shared factoid, but it's a hint at how too far away from Kansas we are to be making fair comparisons.

- A pervasive mistake that coders make (and unfortunately a lot of CSS teaching material out there too) is to approach CSS as a set of explicit, atomic instructions -- a fair coder-y assumption, but a bad mental model that leads to frustration. Understand that these instructions can affect one another; some switch entire layout algorithms[0] in a given scope, changing how other instructions behave (predictably).

[0] https://www.joshwcomeau.com/css/understanding-layout-algorit...

6. leptons ◴[] No.45067645[source]
How is "font-size: 12px" not human readable? I haven't found anything about CSS difficult to read or understand at all. It's really quite simple.