Liskov’s Gun: The parallel evolution of React and Web Components

https://www.baldurbjarnason.com/2024/liskovs-gun/

This is a bit of an experiment. Probably the longest essay I've published directly on my website. 🙂

Liskov's Gun: The parallel evolution of React and Web Components

Web dev at the end of the world, from Hveragerði, Iceland

Couldn't come up with a nice linkbait-y title for this one, so ended up with a relatively sensible one that probably downplays the number of hot takes and swearing in it 😆
@baldur It was "Liskov's Gun" that made me read it.
@wim_v12e Thanks! Glad to hear it 🙂
@baldur Curious how long it took to write this one?
@bkardell I jotted down the first few notes that ultimately led to the essay on the 3rd of October. So, six days? Probably should have baked it for longer 😅
@baldur @bkardell wow! I admire your writing / thinking skills
@hdv @bkardell Lot’s of practice! And being open to looking really stupid for writing half-baked stupid things 😅

@baldur can't claim to have read it all in detail (will bookmark), but I agree with a lot of what's being said and like your take in considering the nuance of all this.

There seems common threads in people's takes on this. Another prescient concern is the UX trade offs of [the lack of] progressive enhancement.

Would be interested to know if you've looked at 'Marko' and have a take on it as something of a React alternative:
https://markojs.com/

Marko

The Marko programming language

@stew_sims Only had a quick glance at it a while back. Looked interesting but didn’t quite fit my needs at the time. 🙂👍🏻

@baldur thanks. I did a fairly rambling opinionated blog post about the sustainability of front end view code recently. Marko came up as one framework that ticked the boxes I concluded were required for the way forward (if you have to use a framework at all). That said I still don't know a whole lot Marko and have never actually used it!

https://ssims.co.uk/personal/blog/Writing-sustainable-code-for-apps-part-1-The-View

Writing sustainable code for apps - part 1: The 'View'

Maybe the real UI framework was the HTML we made along the way

Stewart Sims - coder and other things
@baldur I've already laughed audibly a few times during this and I'm only about 40% of the way through it.
@baldur Fantastic post. My only minor quibble is that I do think the React team has kept innovating – concurrent rendering and RSCs come to mind. Although I'm not convinced the first is a great idea (https://nolanlawson.com/2022/10/22/style-performance-and-concurrent-rendering/) and the second seems to be heavily dividing the React community, I have to give them credit for having the guts to try new stuff even though they're the clear market leader.
Style performance and concurrent rendering

I was fascinated recently by “Why we’re breaking up with CSS-in-JS” by Sam Magura. It’s a great overview of some of the benefits and downsides of the “CSS-in-JS”…

Read the Tea Leaves
@baldur BTW I never understood the whole Liskov substitution thing until this post. It's not just a problem for built-ins, but also web component libraries that allow subclassing. Any change to the superclass is effectively a breaking change unless the subclass automatically gets the new behavior somehow (e.g. super.connectedCallback).
@nolan @baldur This was always true! We wanted to add traits or some other factoring mechanism to allow for decomposition, but TC39 could barely do intrinsic subclassing w/ `class` syntax in a ~timely way.
@nolan @baldur DOM is crying out for decomposition to mixins/traits, and we hoped to do it. But browser vendors whatabouting without actually investigating developer problems (and failing to implement what they stopped the presses to relitigate) dragged everything out.
@slightlyoff @nolan I would have loved to see mixins/traits.

@nolan Thanks! And, yeah, I'm definitely not giving React much credit or even the benefit of doubt.

Though, I think it's fair to say that the jury is still out on a lot of their innovations and that they don't really make up for the overall harm that comes from React's popularity

And if they do come up with something genuinely novel and reusable, people can always steal the idea 🙂

@baldur +1 on the laughs sprinkled into a piece with great webdev insights and excellent cross-pollination of CS and SE thoughts throughout. The experiment was successful from my PoV.
@baldur «But, sure, the data only flows one way. You just need to have curious definitions of the words “flow”, “one”, “way”, and “data”.» 👌
@baldur Absolutely amazing work. There's so much cool stuff on the web and the infighting makes progress slow. We need to work together to make the web better, not fight over whether my tool is better than yours (although with that I have to say that React sucks). Everything has a best application and even though I love the fringe experiments that explore the edges of certain tools, let's not treat those as confirmation that they should be used in those contexts.
@matovius Thanks! And, yeah, the web has so much untapped potential.
@baldur it was so freaking good, thanks!
@thomasorus I appreciate hearing that. 🙂👍🏻

@baldur
> The CSS property display: contents; also goes some way to alleviate this issue as it can be used to effectively “disappear” the custom element from the rendering tree, so it doesn’t interfere with, for example, the parent-child relationship between a <ul> and <li> element.

This is not how I at least understood `display: contents`. It rather keeps the DOM meaning as defined when it comes to semantics, and just skips the element when it comes to, well, displaying it.

https://hidde.blog/more-accessible-markup-with-display-contents/#heading-4
@hdv here explores a use-case of adding `display: contents` to `<ul>` to make `<li>` grid items for *styling* while keeping it a list for semantics. So `display: contents` doesn't alleviate the `<ul><my-el><li>` situation if that's what you were suggesting.

More accessible markup with display: contents

<p>With <code>display: contents</code>, we can have more accessible markup for our CSS Grids. One caveat: supporting browsers currently break this.</p>

Hidde's blog
@thesdev @hdv Ah, I think you're right! I'll have to update the essay
Liskov's Gun: The parallel evolution of React and Web Components

Web dev at the end of the world, from Hveragerði, Iceland

@baldur This is a fantastic essay except that it makes me want to weep for a lot of unfortunate early decisions around the DOM, HTML, and XML. (With Java playing a much more important role then too.)
@simonstl Thanks! And, yeah, I know that feeling very well. 🙂