Live data from Hacker News

CSS now has an if() conditional function

caniuse.com

161–170 of 245 posts

Re: CSS now has an if() conditional function

#161
post #150

Earlier quoted context omitted.

You make bad comments because I can't understand the point you're trying to make. I'm am engineer, I make choices based on informed tradeoffs, anything else would be sub-standard. Not sure why you think I only consider advantages, but I'm afraid asking you for clarification will just lead to more ramblings.

The disadvantages are in the post I linked to.

Alright, I guess I'll reply to that with another comment you can go and read then: https://news.ycombinator.com/item?id=38373081

Fun way of having a conversation.

Re: CSS now has an if() conditional function

#162

Earlier quoted context omitted.

What is a fixed with, that is not a has not a fix value?

I mean elements with a width set in pixels, ems or some other unit. Setting width to 'fit-content' would override the width you set and then the element may overlap others to the right of it

Then you just do width: em; ? I thought you didn't want to specify a width.

Re: CSS now has an if() conditional function

#163
post #158

Earlier quoted context omitted.

Because modern UI toolkits like Flutter proved that UI should just be code, not separated into three different languages. In this case, adding conditionals can remove the need for js in some cases, which is good.

Considering how this is seems to be designed... I don't think that's the reason? I mean looking at the mdn docs it's just a replacement for regular other syntax https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/V... So instead of having a css for x which defines e.g. dark mode and light mode separately, you can now define it via a single css rule. Where previously the "tree" forked at the beginning and attri…

I should have read the docs for it then. Thanks.

Re: CSS now has an if() conditional function

#165

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.

Re: CSS now has an if() conditional function

#166

Earlier quoted context omitted.

> Just because one of the most widely used declarative languages start adding conditionals doesn't mean the whole world is turning upside down. The question still is: why is CSS becoming a programming language? And who decides on this, anyway?

The web should always have been a programming language, with all the usual constructs available in both the display and markup layers. But instead of a single unified standard library for the industry we got a sprawling, ludicrous mess of multiple poorly thought-out semi-compatible technologies, with an associated sub-industry of half-baked fixes and add-ons.

> with all the usual constructs available in both the display and markup layers.

I'm glad the transition to mobile web accelerated on more battery efficient GPUs was possible due to the model instead of Alan Kay's idea that websites should render themselves, where each website would have needed to be upgraded for GPU support for compositing.

Re: CSS now has an if() conditional function

#167
post #127

Earlier quoted context omitted.

Terraform has modules which are an elaborate method of doing function calls. HCL 2 has loops and conditionals. It is most definitely imperative. This is not necessarily a problem except that they had to live in the original HCL v1 landscape which makes them awkward syntactically.

> Terraform has modules which are an elaborate method of doing function calls ... What? How is modules a function call? It's just a hierarchy, everything about/with modules is still declarative. > HCL 2 has loops and conditionals. It is most definitely imperative. So what? Just because there is loops and conditionals doesn't mean it's suddenly imperative. How exactly you do loops in HCL? Last time I used it, you stil…

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 declarative and imperative.

Re: CSS now has an if() conditional function

#169
post #167

Earlier quoted context omitted.

> Terraform has modules which are an elaborate method of doing function calls ... What? How is modules a function call? It's just a hierarchy, everything about/with modules is still declarative. > HCL 2 has loops and conditionals. It is most definitely imperative. So what? Just because there is loops and conditionals doesn't mean it's suddenly imperative. How exactly you do loops in HCL? Last time I used it, you stil…

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.

Re: CSS now has an if() conditional function

#170

Earlier quoted context omitted.

> Just because one of the most widely used declarative languages start adding conditionals doesn't mean the whole world is turning upside down. The question still is: why is CSS becoming a programming language? And who decides on this, anyway?

Because modern UI toolkits like Flutter proved that UI should just be code, not separated into three different languages. In this case, adding conditionals can remove the need for js in some cases, which is good.

Please provide evidence for that proof.
Post reply on HN