7 ms·
JS is far more predictable than CSS.
by zaidf 10y ago
JS is far more predictable than CSS.
- drinchev 10y agoCSS ( properly written ) is easier to debug than JS.
- thecopy 10y agoIs CSS ( properly written ) is easier to debug than JS ( properly written )?
- bennettfeely 10y agoI write a lot of CSS and I would probably disagree. CSS has no console.log() for debugging, CSS often fails silently, and the demos in the link are more or less (albeit pretty neat) hacks, but don't use CSS features in the way the specifications intended.
- afarrell 10y agoAlso no unit tests and a program model that is hard to make into a coherent mental model.
- atmin 10y ago- CSS can be tested, e.g. [1] - use simplified program model and enforce it, [2] [1] https://github.com/jamesshore/quixote https://github.com/jamesshore/quixote [2] https://github.com/unframework/airtight-css-lint https://github.com/unframework/airtight-css-lint
- drinchev 10y agoMy reasoning is that CSS is not a language, it's just a configuration file. It doesn't have a console.log, but it has `background: red`. JS as a language and as such ( especially it's callback / event-driven nature ) makes it harder to debug.
- TimJYoung 10y agoYes, but with the browser debugger you can step through the JS code and visualize what it is doing. How can you visualize what is happening with CSS, short of debugging the internal browser code ?
- RodericDay 10y agoselect an element and see which rules are active on it?
- iamtyce 10y agoHuh? Linting and compilation pull up just about every problem in the writing of CSS. The rest are browser bugs / quirks.
- kyriakos 10y agoEasier to find the bug harder to fix I think. The problem is CSS has a global scope - you change one thing and breaks the whole site's layout. With javascript usually code affects more specific areas of the site/web app.
- malydok 10y agoIf you properly modularize your CSS the global scope no longer remains a concern.
- kyriakos 10y agothe thing is that we don't always start working on sites from scratch. more often I have to clean up someone else's mess or my own that I made months or years ago. in that case I'd rather debug javascript than css.
- lloyd-christmas 10y agoYeah, I think it's a lot easier to fix shitty JS than it is to fix shitty CSS. Every job I've had, I've fixed more than I build. If it's a 5 person startup, I'm iteratively fixing my own shit as the product pivots. If it's 30 people, I'm fixing code from that one idiot that interviewed well and turned out to be impressively terrible. If it's a 10,000 person company, I'm fixing shit from that entire division that wasn't properly managed.
- erlehmann_ 10y agoOn the contrary, I think it is a lot easier to fix shitty CSS than shitty JS, because CSS is not run, but specifies attributes. This makes analysis static for the most part; race conditions and similar bugs usually do not occur.
- kyriakos 10y agomy entire career in 2 lines
- 10y ago