4 ms·
It drives me nuts how much work we put into making CSS something that it is not. Why are we trying to do scripting with CSS? I can really appreciate the approac
by iLoch 12y ago
It drives me nuts how much work we put into making CSS something that it is not. Why are we trying to do scripting with CSS? I can really appreciate the approach taken by React to move style definitions into Javascript, and more specifically into the file of the module whose styles they define.
I'm really just repeating what was said by a Facebook developer (I've forgotten his name at this moment) - but I think it is worth being said: CSS is more a separation of technology, than a separation of concerns. It makes much more sense to have all your code (styles, scripts, markup) in one file for a specific module. Any repeated styles/scripts/markup can be imported as a module.
In hindsight, it makes me wonder what the hell I've been thinking all this time.
- heydon 12y agoCSS is a different technology for a different complementary purpose to, say, markup or business logic. That's why we have the separation of concerns principle. If business logic is doing CSS's work, design changes MESS with the business logic, which is undesirable for obvious reasons. By saying "CSS is more a separation of technology, than a separation of concerns" you are saying "CSS is more a separation of concerns, than a separation of concerns" or possibly "CSS is more a separation of technology, than a separation of technology". As for the modularity concept, that doesn't have to flout or adhere to "separation of concerns". That's just a different thing.
- Kiro 12y agoSo what's your thoughts on React?
- heydon 12y agoI'm not familiar with React. I tried reading a primer on it and got really bored. Couldn't imagine how it would change my work. Then again, I'm mostly a UX designer who works with code rather than an "engineer" focused on abstraction and performance.
- olla 12y agoMaybe the amount of such css trickery hints us that css is becoming outdated and is actually not exactly what we would like it to be. I might argue in this case that the result that is obtained is very much in the visuals and styling scope and has less to do with functionality (scripts). Though, the method how it is obtained, I agree, goes against good readability and is a bit hacky in concept.
- timepiece 12y agoActually CSS is a special purpose scripting language for manipulating stylesheets of structured documents such as HTML & XML. It's also rumored to be Turing complete and the W3C's CSS working group is the one that's slowing down the progress of CSS into a full blown scripting language for performance reasons (Fast vs Full debate) However, this doesn't mean that you can't reinterpret "Separation of Concerns" or subscribe to this notion of "Separation of Technologies" and that modules should be self-sufficient. You can say and do whatever you want but I'm sticking with placing all my style info in CSS files and exploring exhaustively all the possibilities this quirky language provides to manipulate the layout/formatting/styling aspects of my web apps/pages.
- thesz 12y agoIt is not trickery, it is constraints declarations. If you want to go with scripting you will end with your own ad-hoc incomplete bug-ridden slow implementation of half of CSS engine, to paraphrase famous law. Bugs will be prevasive, because your "solver script" will be good in most cases except some where it will be glitching or unstable. You can take a look at QOCA layout constraint solving engine to get a feeling how much code you will write in the end.
- iLoch 12y agoI should have been more clear: I'm not suggesting replacing CSS. I do think however that CSS doesn't need to be siloed. We have a great scripting language (JS), why not just incorporate that with a way to modify styles (CSS) without the need to do all these fancy hacks for calculations. Even the calc function in CSS feels like a hack.