Hacker News new | ask | show | jobs
by T-R 5550 days ago
She says we shouldn't blame the language, but how much of this is because CSS eschews Composition for (incomplete) Multiple Inheritance? And how much of the extra code is an effort to avoid bugs because layout properties are non-orthogonal?

At what point do we decide that it's not that "you're doing it wrong", but that there were actually some design choices that, in retrospect, maybe weren't such a good idea? I'd say that when we have other languages that compile into the language just to overcome these issues (CoffeeScript,Less,SASS,etc.), we've about reached that point.

2 comments

"much of this is because CSS eschews Composition for (incomplete) Multiple Inheritance?"

Pretty much all of it. I remember being a bit surprised when they first released CSS at just how impotent it was. Over a decade later, I now realize my younger self would have gotten himself stuck in a morass of Turing completeness, but CSS goes too far the other direction.

Decoupling styles (which may contain several rules) from matchers, then allowing a match to apply multiple styles, and permitting simple variables (which I would be OK with restricting to simply "either a single variable or a single string" and not permitting concatenation or anything complicated) would have not significantly increased the complexity, avoids the Turing Tarpit [1], and would have been powerful enough that while the other languages would still have inevitably have emerged eventually they wouldn't have been necessary.

HTML had enough pragmatism in it from day one to survive being academicked. CSS is a classic example of how a beautiful theory can back you into a corner and everyone's too busy chanting the beautiful theory's mantra to notice they're doing it in a terrible way.

("You Must Decouple Content From Presentation." "That's a great idea, but don't you think that we should have something like a variable that represents a color?" "You Question The Value Of Decoupling Content From Presentation." "No, it's just that anybody with a couple of years of experience programming knows that you shouldn't hard-code constants into your files, let alone do it fifty times in a single file." "This Is Declaration, Not Code." "There's no difference; spend some time with Lisp." "You Will Burn For Doubting The Decoupling Of Content From Presentation, Heretic. A Thousand Curses On Your Websites." I've had this conversation a few times, though mercifully it has been a long time now.)

(Oh, and if you want to blow someone's mind, ask them why it's so important to decouple content from presentation. I'm sure some people here can at least articulate a reason but in general people can't, it's just a mantra. Then the mantra answer became "Semantic Web", but then try to get a definition of Semantic Web out of them... and if you get that far, ask where the semantics come from. There's been a staggering amount of what is nearly religion surrounding CSS and it shows in the engineering. Oh, and don't suggest that as long as your content is stored cleanly somewhere, it's OK to apply styles in another layer on the server... if it's not CSS, it's not Semantic and it's not Decoupled. Regardless of the actual architecture behind it.)

[1]: http://en.wikipedia.org/wiki/Turing_tarpit

CSS3+HTML apparently is Turing complete: http://lambda-the-ultimate.org/node/4222
Yeah, but not in the way I meant. The way I meant is that you have actual coding abilities in the CSS, because "more power is better". I now understand how that is not true, how it is generally better to be parsimonious with the power in your language (just enough to get the job done), and if you can avoid (convenient) Turing Completeness it's usually a good idea in a declarative UI language. But you can still do forward-declaration non-code replacements without opening the door to Turing-chaos.
It might be the language's fault, but that doesn't make the least bit of difference. CSS is here to stay for the foreseeable future, and she's saying we have learn how to use the tools we're stuck with the best we can.
That is the sad, sad truth of it. At least with CSS compilers and libraries like jQuery, it's getting easier to compensate for CSS' deficiencies. I do, though, still hold onto some hope that someday we'll be able to leave it behind.