6 ms·
I think it's because of the combinatorics of it and it's compounded by the specificity system, the size of the vocabulary, and no built-in compiler. The combin
by shaftway 6y ago
I think it's because of the combinatorics of it and it's compounded by the specificity system, the size of the vocabulary, and no built-in compiler.
The combinatorics are tough for our lizard brains to reason out. If you don't have a strict set of rules for your CSS then you end up with a mixture of element rules, class rules, and id rules, and the combinations of these can get hard to hold in your head. Having compound styles doesn't help at all because it's easy to not realize you're setting a style accidentally.
Then what happens when there's a collision? The specificity system is supposed to sort that out, but without learning the rules there's just no way to intuit them. When I'm struggling with getting something just right and some library CSS is overriding my local CSS it's always the specificity rules that are at fault.
The vocabulary size is enormous. It's unclear exactly how many properties there actually are, but the most authoritative answer I could find was 522. That's a crazy number. And yes, that treats `margin` and `margin-left` as two separate properties, but they're still in there. By comparison there are 53 reserved words in Java and only 33 in Javascript. It's possible for a mere mortal to memorize these.
And finally there's no built-in compiler. Yes, I know about Sass, but that's not much more than a macro system; a useful macro system, but still just a macro system. A lot of us use compilers as our grammar and vocabulary checkers. If I do mis-spell a word in Java the compiler usually errors out and I'm forced to fix it. But if you mis-spell a property in CSS it's happy to just ignore it and you spend several minutes trying to figure out why your change did nothing.
- animationwill 6y ago> By comparison there are 53 reserved words in Java and only 33 in Javascript. Where did you find these numbers? I'm trying to find them but I can only find the Ecmascript and the number appears way higher
- fanf2 6y ago39 listed here https://tc39.es/ecma262/2020/#sec-keywords-and-reserved-words https://tc39.es/ecma262/2020/#sec-keywords-and-reserved-word... 51 listed here https://docs.oracle.com/javase/specs/jls/se15/html/jls-3.html#jls-3.9 https://docs.oracle.com/javase/specs/jls/se15/html/jls-3.htm... with a bunch of non keywords listed below, of which true false and null are also reserved
- shaftway 6y agoFor Java I used https://www.thoughtco.com/reserved-words-in-java-2034200 https://www.thoughtco.com/reserved-words-in-java-2034200 but Wikipedia lists 51. I'm too lazy to actually diff it. For Javascript I used https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... and fudged the numbers a bit. There are future reserved words, but I didn't iinclude them because there's no point in memorizing them. Now that I look in detail that list also doesn't include "true", "false", and "null".