Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It really is a whole alien domain to itself. The syntax being so foreign to most developers doesn't help. But it's so powerful, incredibly powerful, and in most browsers, extremely efficient.

The extremely vast majority of web app developers don't need 99% of what CSS can offer. But it's neat to know it's there.



  whole alien domain
  so foreign to most developers
  doesn't help.
  it's so powerful, incredibly powerful,
  most browsers, extremely efficient.
That is because CSS is a different Chomsky Grammar than HTML and EMCA - intentionally not Turing complete, nor-self referential - why the "has(" puedo property was so problematic.

That also relates to sibling comments about the awkwardness of the pairing to Javscript, which is of a higher grammar, and Turing Complete*.

It also relates to the "awesomeness" of the "fire-and-forget" nature of CSS - unless very specifically hooked, it can be hardware-accelerated nearly care-free because it isn't per frame to the DOM, which Javascript is (meaning HTML, it's own Chomsky Grammar!)

It is what it is, the epitome of an optimized amalgamation of technical debt we call the modern web specification.


> That is because CSS is a different Chomsky Grammar than HTML and EMCA - intentionally not Turing complete, nor-self referential - why the "has(" puedo property was so problematic.

It will be a nitpicky comment, and I’m sure you mean it this way, but it wasn’t clear to me: a language’s syntax being in one type of grammar class is irrelevant to its execution semantics corresponding to a recognizing automaton. So you can have a language with a regular syntax that is Turing complete just fine.

In fact, most languages’ syntaxes are context-free (sometimes with some escape hatches), but are semantically Turing-complete.


  nitpicky comment,
I even put an asterisk! Oh wait, not the usual "unlimited tape finite universe"

I was unclear. It is intentionally not Turing Complete, by way of avoiding self-references, as self-references would make it a higher-order grammar, and Turing-complete because it then it can innately loop, making it impossible to flatten to a lower, Labeled Push down automaton.

Although they are mutually exclusive, I implied causality.

Its the implicit loop and requirement of a heap/stack of variables self-referencing requires that is Turing-Complete itself.


> That is because CSS is a different Chomsky Grammar than HTML and EMCA - intentionally not Turing complete

CSS has been Turing complete for many years.

You can simulate Turing machines with pure HTML+CSS, e.g. https://github.com/yrd/tm2css

"Rule 110" which implies Turing-completeness has also been implemented in CSS, e.g. http://eli.fox-epste.in/rule110/


CSS has been very, very, very close.

I would had had, had - "has" not been had, expected sooner, but atlas.

But the aforementioned ":has": : The :has() pseudo-class cannot be nested within another :has(). This is because many pseudo-elements exist conditionally based on the styling of their ancestors and allowing these to be queried by :has() can introduce cyclic querying.

  Pseudo-elements are also not valid selectors within :has() and pseudo-elements are not valid anchors for :has().
Note the two limits, "cyclic querying" and self-referential parameters.

The former is required for a basic computational model, the latter for one that supports recursive-ness and thus some optimizations .

  "Rule 110"
This is just lambada calculus and has no tape movement - requires checkin boxes, still, and thinking about whether or not to halt - which actually kinda is its own asterisk (not the usual 'infinite tape' kind). Turing Machines would halt on some input; your calculator goes until the actual computer, you, halts, or stops actually checking(computing) the state for a HALT/desired state.

You'd think someone woulda parasol'd the checkboxes and at least attempted to use :onHover with grid to require minimal mouse movement to trigger input instead.

Or, a bounding box input state driven hack - like when your cursor is "in between" elements, changing every frame.

  pure HTML+CSS, e.g. https://github.com/yrd/tm2css
seems cool, actually. SASS repeats CSS exhaustively through HTML-encoded steps until a valid one is painted - that valid one being the HALT/output. You do have to specify the number of steps, though. You would have to know whether or not it halts, the answer, and how many steps it took to compute to functionally (heavy-lifting in this context) use it - or else it would have to reference itself....which would make it a higher grammar.

But it can't: https://www.w3.org/TR/css-variables/#cycles

  This can create cyclic dependencies where a custom property uses a var() referring to itself, or two or more custom properties each attempt to refer to each other....If there is a cycle in the dependency graph, all the custom properties in the cycle are invalid at computed-value time.
Very close. But you must beg the question (ie. know the answer) in both step count and thus the answer, else you'd have an infinite HTML page. Which is fine in math (HTML is a Type 2, can be infinite, no self-reference, no self-children, nor orphans), but not really much of a simulation/emulation though - if it can only produce valid machines at (essentially) compile time.


You could just call it syntax, you know.


Everyone reading this speaks multiple computer languages, and knows what a "syntax" is.

The disambiguation between levels (grammars) of syntax is what the above poster was both lamenting and heralding - possibly unaware of it's technical and mathematical necessity.

https://en.wikipedia.org/wiki/Ambiguous_grammar#Trivial_lang...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: