Live data from Hacker News

CSS now has an if() conditional function

caniuse.com

171–180 of 245 posts

Re: CSS now has an if() conditional function

#171
post #167

Earlier quoted context omitted.

You "call" a module with arguments. You can call them multiple times. In every way that matters they are just like a function call. I don't understand why there is a distinction between for each in a standard language vs for_each in HCL2. They are both do something by iterating over something else at runtime. The syntax isn't what matters here. I think maybe you are mistaken in your own distinction between declarativ…

Imperative: Tell the computer how to do something, by instructing it what to do. Declarative: Tell the computer what you want the result to be like, and the computer figures out how to do it. for_each in Terraform is very much declarative, just like modules. Compare how you'd do the same thing with JS or any other (imperative) language you know, and I think it must be clear what the difference between the two is.

Those boundaries are pretty fuzzy. The complexity of the logic with conditionals and loops in a module means that you have pretty much stopped describing what it should like and instead described how to make it look the way you want it.

I have read terraform modules where I had to execute the logic to know what got produced which moves it from your imperative description to the declarative description as far as I'm concerned.

Re: CSS now has an if() conditional function

#172
post #74
post #57

Earlier quoted context omitted.

You can blame whoever invented the word "if", as soon as you can branch based on data you can just write an interpreter that turns data into instructions, no matter the architecture.

You need more than if for Turing completeness though.

You need conditionals and loops. Recursion counts as looping.

Re: CSS now has an if() conditional function

#173

As long as css remains "so fast it's free" then I'm mostly happy with that - I use css without thinking about optimisations, and I like it like that!

Well, you can actually write slow css if you make real deep nested flex container. And it's not even too rare. You can actually find such example in yhe wild. The spec of flex layout requires it to layout its child elements several times to compute actual layout. Make it deep and nested without proper constrains will results in n*n*n*n… layout computations and bring down the browser on resize.

It’s not even that hard. Use flex for layout and you can instantly see how slow reflow becomes when resizing the window.

Re: CSS now has an if() conditional function

#175

With the inclusion of branches, is it possible to say that CSS is now even more Turing-Complete? Now we just need to find ways to do recursion/targeted jumps so that it is finally recursive-enumerable

Don’t apply programming language mental models onto CSS features.

CSS if() probably just merges one of two single-property RuleSets onto the parent RuleSet depending on the condition, which has nothing to do with branching, as there is no execution flow to branch.

Re: CSS now has an if() conditional function

#176
post #64

Earlier quoted context omitted.

We can blame von Neumann (et al) and his infernal architecture, where memory stores both instructions and data.

von Neumann did not invent the von Neumann architecture. Not even a little bit. If you want to reason that the hardware is at fault, you should be blaming the Eckert-Mauchley architecture.

[deleted]

Re: CSS now has an if() conditional function

#177
post #42

Give it enough time, every declarative language becomes a programming language. This is happening with all config files, markup languages, data formats. The distinction between code, config and data is being erased. Everything is a soup now. Data is application, configuration is code. Code is an intermediate, volatile thing that is generated on the fly and executed in the temporary lambda containers.

> every declarative language becomes a programming language. Overly pessimistic, lots of non-programming languages remain non-programming languages. Just because one of the most widely used declarative languages start adding conditionals doesn't mean the whole world is turning upside down... > The distinction between code, config and data is being erased. As as lisp programmer, I love it. Get rid of treating things d…

If only Lisp had better presense in modern code editors. Emacs is not enough, especially on Windows where it is super slow. I think this is what actually stops newcomers to start with Lisp and not Python

Re: CSS now has an if() conditional function

#178
post #51

Earlier quoted context omitted.

Probably not. There is a lot of optimizations browsers do to make the stylesheets super fast[1], and I think quite a few of those rely on CSS not being Turing complete. 1: https://hacks.mozilla.org/2017/08/inside-a-super-fast-css-en...

CSS is Turing complete :-) You can find pure-CSS implementations of Game of Life, for instance.

I don’t think that’s true, unless you count hardcoding the state evolution into CSS variables, one var per cell per step.

Re: CSS now has an if() conditional function

#179

Earlier quoted context omitted.

> every declarative language becomes a programming language. Overly pessimistic, lots of non-programming languages remain non-programming languages. Just because one of the most widely used declarative languages start adding conditionals doesn't mean the whole world is turning upside down... > The distinction between code, config and data is being erased. As as lisp programmer, I love it. Get rid of treating things d…

If only Lisp had better presense in modern code editors. Emacs is not enough, especially on Windows where it is super slow. I think this is what actually stops newcomers to start with Lisp and not Python

> I think this is what actually stops newcomers to start with Lisp and not Python

What stops newcomers is knee-jerk reactions about the (lack of) syntax, it's scary to see something that doesn't look like Algol, because everyone who does mainstream programming uses Algol-like languages.

Introduce lisp to anyone who knows programming since earlier, and 99% of them will have a adverse reaction to s-expressions, before they understand what's going on. Once they understand, it makes a lot of sense obviously, but not everyone even has that kind of open mindset where they could understand if they wanted to.

Re: CSS now has an if() conditional function

#180

Earlier quoted context omitted.

> every declarative language becomes a programming language. Overly pessimistic, lots of non-programming languages remain non-programming languages. Just because one of the most widely used declarative languages start adding conditionals doesn't mean the whole world is turning upside down... > The distinction between code, config and data is being erased. As as lisp programmer, I love it. Get rid of treating things d…

If only Lisp had better presense in modern code editors. Emacs is not enough, especially on Windows where it is super slow. I think this is what actually stops newcomers to start with Lisp and not Python

I find lisp to be a very non ergonomic language and am happy that python is the default.
Post reply on HN