DEV Community

Discussion on: Is CSS objectively bad?

Collapse
ymiyugy profile image
YmiYugy

It’s not about imperativeness.
As far as I know CSS isn’t even Turing complete nor is it isomorphic to a lambda calculus.
But technicalities aside, CSS is incredibly bad at being a declarative language.
Look at the expressiveness functional languages like Elm or Haskell provide and compare that to how incredibly awkward it is to express even simple things in CSS.
In short it’s designed as a markup language not a PL.

Yes internally Flutter uses a box model that is very similar to CSS, but you rarely interact with it directly.
Instead you usually use typed widgets, e.g. a Padding widgets applies padding and an Alignment widget aligns it’s child.
In CSS on the other hand every property can be set on every selector.
For me that’s quite overwhelming.

Thread Thread
stereobooster profile image
stereobooster Author • Edited on

As far as I know CSS isn’t even Turing complete nor is it isomorphic to a lambda calculus.

You make it sound as if Turing completeness has something to do with language being programming or not. I don't think this is the case. Typed lambda calculus is not Turing complete. Brainfuck is Turing complete, yet I don't think this is example of good programming language. Actor model can go beyond of what Turing machine can do. There is nothing specific in Turing completeness in terms of modern development (yet this is very important discovery for computer science and logic systems, the same way as Godel incompleteness)

But technicalities aside, CSS is incredibly bad at being a declarative language

The problem here is that term declarative is overloaded and not clearly defined. Where is I mean declarative is when you describe what you want, rather how to achieve it. You refer to pure functional languages as declarative, because in pure declarative languages order of evaluation doesn't matter. Which is fair point, there is no clear definition of this term.

I meant "Descriptive declarative programming" according to this classification.

Thread Thread
ymiyugy profile image
YmiYugy

I feel like our discussion has drifted a bit too much into discussing definitions.

Set aside by what definition CSS is a PL or isn't I want to get back to strengthen my argument that CSS is a bad language in a different way.
Rather than looking at the language in isolation I want to look at how it's used and what that tells use about flaws in its design.
In recent years CSS in JavaScript has gained lots of traction despite its obvious drawbacks.
I think the fact that many people choose to rather write CSS generators than CSS is a strong indication that the language is not expressive enough.