Live data from Hacker News

CSS now has an if() conditional function

caniuse.com

101–110 of 245 posts

Re: CSS now has an if() conditional function

#101
post #4

It's a great way to make conditional styles without having to use JavaScript; however, having used JS for years to make theme color and icon sets that rely on CSS properties, I'm not sure I particularly like this method. I feel like you have to smear a lot of logic across your CSS whereas with JS you can reduce your theme to a data structure and just have a simple function to setup all the CSS variables based on that…

You're pulling the old man card on CSS-in-JS? Putting your style logic in CSS is what CSS is for , CSS-in-JS is an annoying hack to make React work. What this is replacing is SCSS.

Well, historically, styles were first in JS (JS StyleSheets in Netscape 4.0) and were pulled out into CSS. – This is an old man card! ;-)

Re: CSS now has an if() conditional function

#102
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.

You have to give it to CSS, it's held out for a lot longer than most.

not as much as you would think, the if statements don't really affect the css crimes scene because pretty much everything was already possible before

Re: CSS now has an if() conditional function

#103
post #6

Far from being ready when only one major browser supports it. If you want this, you should vote for it to be focused on for interop-2026 https://github.com/web-platform-tests/interop/issues Right now, the leading CSS proposals are `@container style()`, `corner-shape` and `break-after` https://foolip.github.io/interop-reactions/

Yeesh.. I've definitely tried using break-after and being disappointed it didn't work properly. The amount of hoops I had to jump through to get things to print properly on paper...

>The amount of hoops I had to jump through to get things to print properly on paper...

Anybody know how that compares to Report Definition Language?

https://learn.microsoft.com/en-us/sql/reporting-services/rep...

Seems like an awfully scattered shitshow just to arrive at a typical "What You See Is Not What You Get" result.

And this one is made for printouts.

Re: CSS now has an if() conditional function

#104
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.

So why do people still design declarative languages?

It’s the cycle of newcomers to looking at the existing solutions and declaring “this shit is too complicated, why did these morons design it this way? Check out my DSL that does everything and is super simple!”

Then time passes, edge cases start cropping up and hacks are bolted on to accommodate them. Eventually everything struggles under the weight of not having loops, conditionals, etc. and those are added.

After some time, the cycle begins anew.

Re: CSS now has an if() conditional function

#105
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.

“Now”? This has always been the case.

Re: CSS now has an if() conditional function

#106
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.

Configuration complexity clock

https://mikehadlow.blogspot.com/2012/05/configuration-comple...

Re: CSS now has an if() conditional function

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

CMake was never declarative AFAIK? CMake today is effectively an eso-lang / Turing tarpit with some “modern” declarative conventions that people try to push.

"Modern CMake" is more about scoping all properties to the targets that they belong to (including stuff like what you also need to link against if you link against target foo) than about language features. The CMake language hasn't changed much except correcting some early weirdness about "if" and the addition of generator expressions, which are fortunately not often needed.

Re: CSS now has an if() conditional function

#108
post #4

It's a great way to make conditional styles without having to use JavaScript; however, having used JS for years to make theme color and icon sets that rely on CSS properties, I'm not sure I particularly like this method. I feel like you have to smear a lot of logic across your CSS whereas with JS you can reduce your theme to a data structure and just have a simple function to setup all the CSS variables based on that…

God forbid we use html5

There is no HTML5 other than a buzzword: https://html.spec.whatwg.org/dev/introduction.html#is-this-h...?

Re: CSS now has an if() conditional function

#109
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.

So why do people still design declarative languages?

If you can mostly stick to the declarative way, it's still a benefit. No Turing-complete language completely prevents you from writing "bad" code. "You are not completely prevented from doing things that are hard to understand" is a bad argument. "You are encouraged to do things that are hard to understand" is a good one (looking at you, Perl).
Post reply on HN