| ▲ | afavour 7 hours ago |
| Because JavaScript requires… a lot. A virtual machine, script parsing, etc. Making that a requirement before you even display any content on the page would be a regression. |
|
| ▲ | dlcarrier 7 hours ago | parent | next [-] |
| If CSS is Turing complete, that means it has a virtual machine with parsing and so forth. That means that difference between it and JavaScript is just syntax. (Same for any Turing complete language) |
| |
|
| ▲ | lioeters 7 hours ago | parent | prev | next [-] |
| I can see that, but CSS already requires a lot, no? Especially as they keep adding new features to it. To me it feels like "programming in YAML", the way a declarative language/format acquires more and more features until you're writing functions in an awkward syntax that was never designed for it. |
| |
| ▲ | afavour 7 hours ago | parent | next [-] | | It requires a lot… but a lot less than JS. The awkward declarative nature of it is a side effect of wanting it to parseable at speed. At an initial look I agree with you that the functions look very awkward. But I thought the same about CSS variables until I started using them and now I think they’re great so I’ll keep an open mind. I almost wonder if they would have been better off calling them “templates”, or something. “Functions” is going to make people think it’s just like JS. | | |
| ▲ | lioeters 6 hours ago | parent | next [-] | | Yeah OK, I see what you mean, I may change my mind once I start using them. And having worked on interpreters and compilers, I can understand the need to keep internals simple and fast - like everything must be parsable in one pass - so the surface ugliness of syntax isn't as important in the long term. Perhaps I should also be sympathetic to the spec authors, since they're working under tight constraints of language design. Things might look a lot more elegant if HTML/CSS/JS were designed from scratch as a coherent whole. | |
| ▲ | SadErn 7 hours ago | parent | prev [-] | | [dead] |
| |
| ▲ | agstudio 6 hours ago | parent | prev [-] | | Strongly agree. While I am a huge fan of the capabilities of native CSS and the fact that it keeps getting more capable as time passes, I have come to the conclusion that it is unfortunately a programming language trapped in an “obsolete stylesheet syntax” body, especially after the addition of calc(), variables, functions and multiple ways of conditional logic. The worse part of working with CSS is that there is no standard static type checking tool (stylelint comes close though). A lot of programming errors should/could be caught at build time. Sometimes wondering if a completely alternative syntax+tooling is possible that would leverage all the existing capabilities, while using a different language paradigm. | | |
| ▲ | chuckadams 5 hours ago | parent [-] | | The ironic thing is that the old-school ancestor to CSS already was a programming language: DSSSL was a dialect of scheme. | | |
| ▲ | lioeters 4 hours ago | parent [-] | | That DSSSL syntax looks a lot better subjectively. (element doc
(make paragraph
font-size: 20pt
line-spacing: 20pt
font-weight: 'bold
color: color-purple
(process-children)))
In an alternate universe timeline, we could have had a single web language for hypertext, styles, and scripting. |
|
|
|
|
| ▲ | geocar 6 hours ago | parent | prev [-] |
| We had that. It was called XSLT. Google said they weren't smart enough to implement it, or pay anyone to fix the one they forked a decade ago. |