Live data from Hacker News

If Inheritance is so bad, why does everyone use it?

buttondown.email

241–250 of 389 posts

Re: If Inheritance is so bad, why does everyone use it?

#241

Earlier quoted context omitted.

> Those that tend to hate the cascade tend to fight the browser a lot, whether they realize it or not. Generally speaking, they want things to work a certain way (IE everything in isolation) and prefer to think of styles isolated bits. So, wouldn't that be the browser fighting them, then? They want something specific, and the broswer forces a paradigm upon them that they don't want. They are the humans and the browse…

If someone picks up a hammer and struggles to pound screws in with them, it’s not the hammer that’s defective. I don’t think CSS is the perfect tool for all browser-based styling but it’s the tool that’s there and it’ll probably work a lot better if you use it the way it’s intended to be used. If you want a screwdriver instead of a hammer… you have options (don’t target a browser, propose an alternative to CSS, use s…

>If someone picks up a hammer and struggles to pound screws in with them, it’s not the hammer that’s defective.

If someone wants to hammer nails and they're given a blender, then the blender might not be defective, but it surely is not the right tool for the job, and it's imposed upon them.

Few people ever loved CSS. The majority always either hated it or learned to tolerate it. Most who do CSS today use a few different paradigms on top to make them tolerable like BEM, or use different transpilers to get a better language, or directly control styling from code, with CSS-in-JS libraries or like React does it.

>I don’t think CSS is the perfect tool for all browser-based styling but it’s the tool that’s there

Sure, I never denied its existance. Just its design.

Re: If Inheritance is so bad, why does everyone use it?

#242

Earlier quoted context omitted.

Mainly because nobody is a "CSS Dev". If someone's entire job was developing CSS, you might expect that they would be willing to learn one new slightly different way of doing it. But in reality the pushback comes from full stack developers who already have a million other things to worry about, such that relearning all the basic CSS they already know, to achieve benefits that are rather minuscule in the grand scheme…

On the contrary, Tailwind's ergonomics are what attract me to it. With the autocomplete features via the VSCode intellisense plugin, I'm able to create UIs at a pretty extraordinary pace. As a trivial example, let's imagine we need to apply a border radius to an element. Without Tailwind, it looks like this: 1. I find the element I need to style 2. I look at which class it's using 3. I navigate to my CSS file 4. I sc…

Fully agree with this. The regular arguments against Tailwind like "it's just inline styles", "learn CSS properly", "it looks ugly" and "normal CSS is easy" say nothing about how fast the Tailwind approach lets you make edits and stay focused in comparison.

Normal CSS is usually worse than this too e.g. you hit save, and your edit doesn't change anything, so you have to use the web inspector to hunt down which class is overriding your style then weigh up options for how you're going to refactor while jumping between multiple files. It's exhausting when you're trying to focus on styling.

Re: If Inheritance is so bad, why does everyone use it?

#243

Earlier quoted context omitted.

On the contrary, Tailwind's ergonomics are what attract me to it. With the autocomplete features via the VSCode intellisense plugin, I'm able to create UIs at a pretty extraordinary pace. As a trivial example, let's imagine we need to apply a border radius to an element. Without Tailwind, it looks like this: 1. I find the element I need to style 2. I look at which class it's using 3. I navigate to my CSS file 4. I sc…

Fully agree with this. The regular arguments against Tailwind like "it's just inline styles", "learn CSS properly", "it looks ugly" and "normal CSS is easy" say nothing about how fast the Tailwind approach lets you make edits and stay focused in comparison. Normal CSS is usually worse than this too e.g. you hit save, and your edit doesn't change anything, so you have to use the web inspector to hunt down which class…

I also assumed that a class already existed for it. Because otherwise you have to think about whether you use a class or an id or an element selector, you have to think about what the class name is going to be, which file it should go into, etc etc. What I presented was absolute best case scenario lol.

Re: If Inheritance is so bad, why does everyone use it?

#244

Earlier quoted context omitted.

>It looks like composition over inheritance has caught on as the better default in other languages, but in the CSS world people still cling to the cascade as a best practice for some reason I find this falls into generally two camps, those who want to fight the browser and those who don’t. Those that tend to hate the cascade tend to fight the browser a lot, whether they realize it or not. Generally speaking, they wan…

I'd ask what you mean by "fighting the browser"- as generally, the number one way to ruin the performance of your CSS is to introduce depth to it. In general, keeping everything isolated regularly leads to better rendering performance.

Avoiding the cascade at all costs, for example. It can introduce a lot of unintended consequences.

Another anti pattern I have seen is the over use of media queries to force the browser to do certain things rather than embracing relative sizing constraints via intrinsic design and letting the flexbox and grid algorithms do most of the heavy lifting.

Here though I want to point out isolation is relative, as is the cascade. I think it’s important to leverage the cascade wherever you can but that doesn’t mean you are leveraging it from top to bottom per say, but it does mean thinking more wholistic about the context of styling

Re: If Inheritance is so bad, why does everyone use it?

#245

Earlier quoted context omitted.

Mainly because nobody is a "CSS Dev". If someone's entire job was developing CSS, you might expect that they would be willing to learn one new slightly different way of doing it. But in reality the pushback comes from full stack developers who already have a million other things to worry about, such that relearning all the basic CSS they already know, to achieve benefits that are rather minuscule in the grand scheme…

On the contrary, Tailwind's ergonomics are what attract me to it. With the autocomplete features via the VSCode intellisense plugin, I'm able to create UIs at a pretty extraordinary pace. As a trivial example, let's imagine we need to apply a border radius to an element. Without Tailwind, it looks like this: 1. I find the element I need to style 2. I look at which class it's using 3. I navigate to my CSS file 4. I sc…

I actually just downloaded the VS Code extension earlier today as a result of this discussion, perhaps that will change my opinion. Because for me the two flows would be:

   1. I find the element I need to style
   2. I add/edit the inline style={{}} attribute I have for it by typing `sty{borrad`
   3. I add a value
VS:

   1. I find the element I need to style
   2. I add/edit the className attribute
   3. I pull up the tailwind documentation to find how to type the CSS I already have memorized in their DSL (I know some Tailwind by heart, but wayyyyy more CSS)
   4. I wait for it to load
   5. I scroll down to find the version of the class name that I need
   6. I go back to the editor and add the class.
Also a very common flow for me is to edit the CSS directly in the browser, it's a much faster devloop than the fastest live reload server. In that case it's far easier to just copy from the `changes` view into the CSS than go through and remap everything from CSS into Tailwind.

Re: If Inheritance is so bad, why does everyone use it?

#246

Earlier quoted context omitted.

Fully agree with this. The regular arguments against Tailwind like "it's just inline styles", "learn CSS properly", "it looks ugly" and "normal CSS is easy" say nothing about how fast the Tailwind approach lets you make edits and stay focused in comparison. Normal CSS is usually worse than this too e.g. you hit save, and your edit doesn't change anything, so you have to use the web inspector to hunt down which class…

I also assumed that a class already existed for it. Because otherwise you have to think about whether you use a class or an id or an element selector, you have to think about what the class name is going to be, which file it should go into, etc etc. What I presented was absolute best case scenario lol.

Only if you're refusing to consider inline styles. Which is an odd decision to make if we're comparing to Tailwind.

That said, I agree that this doesn't work for pseudo selectors, very unfortunately, and I wish it would.

Re: If Inheritance is so bad, why does everyone use it?

#247

Earlier quoted context omitted.

Fully agree with this. The regular arguments against Tailwind like "it's just inline styles", "learn CSS properly", "it looks ugly" and "normal CSS is easy" say nothing about how fast the Tailwind approach lets you make edits and stay focused in comparison. Normal CSS is usually worse than this too e.g. you hit save, and your edit doesn't change anything, so you have to use the web inspector to hunt down which class…

I also assumed that a class already existed for it. Because otherwise you have to think about whether you use a class or an id or an element selector, you have to think about what the class name is going to be, which file it should go into, etc etc. What I presented was absolute best case scenario lol.

[deleted]

Re: If Inheritance is so bad, why does everyone use it?

#248

Earlier quoted context omitted.

On the contrary, Tailwind's ergonomics are what attract me to it. With the autocomplete features via the VSCode intellisense plugin, I'm able to create UIs at a pretty extraordinary pace. As a trivial example, let's imagine we need to apply a border radius to an element. Without Tailwind, it looks like this: 1. I find the element I need to style 2. I look at which class it's using 3. I navigate to my CSS file 4. I sc…

I actually just downloaded the VS Code extension earlier today as a result of this discussion, perhaps that will change my opinion. Because for me the two flows would be: 1. I find the element I need to style 2. I add/edit the inline style={{}} attribute I have for it by typing `sty {borrad ` 3. I add a value VS: 1. I find the element I need to style 2. I add/edit the className attribute 3. I pull up the tailwind doc…

That's fair - styling directly in the browser does indeed cut down several of the steps I mentioned, or at least it condenses it to one step at the end. I do think that installing the extension changes the experience entirely, because then you don't need to reference the docs.

Re: If Inheritance is so bad, why does everyone use it?

#249

Nobody calls it this, but cascading styles in CSS is just like inheritance and I think should be avoided for all the same reasons. I feel it's a big part of why CSS at scale becomes unmaintainable. There isn't even a built-in way to compose two classes together if you want to avoid cascading/inheritance. It looks like composition over inheritance has caught on as the better default in other languages, but in the CSS…

>It looks like composition over inheritance has caught on as the better default in other languages, but in the CSS world people still cling to the cascade as a best practice for some reason I find this falls into generally two camps, those who want to fight the browser and those who don’t. Those that tend to hate the cascade tend to fight the browser a lot, whether they realize it or not. Generally speaking, they wan…

Two camps I see are (1) those who want to hold the program in their head and be able to answer ever more obscure questions about the program using their understanding. And (2) those who try things until it works and then address problems as needed.

Do these two camps align with your two camps? Those who want control fight the cascade, others just fiddle with it until it looks good?

I don't mean to disparage either camp, because we need both approaches in the real world.

Re: If Inheritance is so bad, why does everyone use it?

#250

Nobody calls it this, but cascading styles in CSS is just like inheritance and I think should be avoided for all the same reasons. I feel it's a big part of why CSS at scale becomes unmaintainable. There isn't even a built-in way to compose two classes together if you want to avoid cascading/inheritance. It looks like composition over inheritance has caught on as the better default in other languages, but in the CSS…

I'm inclined to semi-agree with this, although I'm not sure I'd be quite as adamant about it myself. But I do generally think that CSS is taught in a way that encourages some bad practice around cascade/inheritance. I will point out though that (at least in my experience), BEM solved the majority of these problems for me even without a preprocessor. The language is definitely oriented towards inheritance/cascade, but…

Do you have a CSS component framework that you can recommend for use with BEM?
Post reply on HN