Skip to content

Instantly share code, notes, and snippets.

@jaredhirsch
Last active August 29, 2015 14:09
Show Gist options
  • Save jaredhirsch/59185f63f146c66c3d96 to your computer and use it in GitHub Desktop.
Save jaredhirsch/59185f63f146c66c3d96 to your computer and use it in GitHub Desktop.
HOW 2 CSS
  1. declarative programming sucks horribly
  • because you have to, in your brain, understand every fact in the system and how they interact
  • this is not how human brains work, we think in narratives, in linear flows
  • this is why it's impossible to debug CSS (or Puppet, or XML...)
  1. there is a fix
  • instead of a huge graph of possible interacting facts,
  • just eliminate the cascade as much as humanly possible
  1. there are two ways
  • one is to overspecify every property of every node. this is how less/sass work.
  • two is to use lots of generic classes, like how css frameworks work (oocss, etc).
  1. you don't need a css preprocessor
  • yes, really. just don't be sloppy and put lots of styles on lots of nodes.
  • keep your styles in one place and keep them as orthogonal as possible.

side note: CSS sucks for the same basic reason that GOTO is considered harmful, which is also why global variables suck, and, also, why side effects are carefully managed in functional programs:

  • if you can't reason about any part of a system without reasoning about the whole thing,
  • and the whole thing is too big to fit in your head,
  • then you're gonna have a bad time.
@jaredhirsch
Copy link
Author

better answer: don't focus on all this junk. just use flexbox.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment