Live data from Hacker News

CSS now has an if() conditional function

caniuse.com

121–130 of 245 posts

Re: CSS now has an if() conditional function

#121
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…

>> Just because one of the most widely used declarative languages start adding conditionals doesn't mean the whole world is turning upside down.

You need to look at a large terraform project.

Re: CSS now has an if() conditional function

#122

Earlier quoted context omitted.

There's this really cool site where you can see how well supported a feature is: https://caniuse.com/?search=if If Google controls everything, why is if() only supported on 59% traffic? Do you think any serious company will let their site break on 40% of clients? Do you think Apple's opinion is unimportant?

Did you look at detailed usage stats? More specifically at things that do not count towards that 59%: older versions of Chrome add another 20%, various Chromium forks add a few percent more, so the rest of the internet accounts for less than 20%. I'd say this is pretty monopolistic for one company to control the means of more than 80% of traffic of doing its 'trafficking'.

If you've ever ran a serious website you'd know most of those Chrome uses are poor third worlders that aren't worth much as users.

Re: CSS now has an if() conditional function

#123
post #121

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…

>> Just because one of the most widely used declarative languages start adding conditionals doesn't mean the whole world is turning upside down. You need to look at a large terraform project.

I spent more time than I'm willing to on large Terraform projects. How exactly is this relevant to declarative vs imperative or even my comment at all? I don't see what the "gotcha" is supposed to be here.

Re: CSS now has an if() conditional function

#124

Can it already vertically and horizontally center unknown-beforehand-length multi-line text in a single html element, just like non-CSS table cells could already in 1995?

width: fit-content; margin: auto;

That changes the width, I guess I should have specified fixed width

Re: CSS now has an if() conditional function

#126

I'm not really sure I understand this. How is the new if() conditional function different from using @media (width ...) when adapting layouts to browser width?

If I'm reading it right, the if condition/predicate can check more things than @media() can.

Re: CSS now has an if() conditional function

#127
post #61

Earlier quoted context omitted.

This is so true, I have seen it happen with so many projects. It always starts with a cute declarative DSL, and inevitably imperative / flow control structures emerge, at which point you wonder why they didn't use a real programming language in the first place and save you the hassle or learning a half baked imperative DSL. - Puppet - CMake - Terraform - ... All these started with pure declarative DSL then incrementa…

> All these started with pure declarative DSL then incrementally created a nightmarish imperative monstrosity. "Huh?" I asked myself when you mentioned that Terraform is now imperative somehow. Took a look at the website again, and seems to still be HCL, and still be declarative. Am I missing something? How exactly is Terraform today a "imperative monstrosity"?

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.

Re: CSS now has an if() conditional function

#128
post #81

Can it already vertically and horizontally center unknown-beforehand-length multi-line text in a single html element, just like non-CSS table cells could already in 1995?

align-content: center; (supported on block elements since sometime last year)

Thanks, seems to work at first sight in combination with text-align for the horizontal alignment!

That means I may finally not need line-height or multi-element tricks for this anymore

Interesting that this is finally there since a year!

I wonder what made them decide to support it finally, since CSS's creation in 1996.

A button never looks professional if the text in it isn't centered, this was a really needed feature and I still can't understand why it took that long

Edit: it does seem worrying that for me this property vertically centers but not horizontally while the description of it doesn't say vertical but is: "The items are packed flush to each other in the center of the alignment container along the cross axis."

Re: CSS now has an if() conditional function

#130
post #9

If we could do it over, knowing that we'd eventually get to this point, would https://en.wikipedia.org/wiki/JavaScript_Style_Sheets have been the better path?

Knowing what we know, we would probably have stepped out of our time machine to make sure that Brendan Eich kept the Scheme-based syntax and added semantic HTML enrichment for styling, sparing untold grief over the last generation...
Post reply on HN