Live data from Hacker News

Web Components could replace frontend frameworks?

dannymoerkerke.com

151–160 of 248 posts

Re: Web Components could replace frontend frameworks?

#151
post #95

Earlier quoted context omitted.

> It's actually particularly heavy Huh? It's a very small API built _into_ the web browser. What's heavy about it? It's kinda similar to how JSX works just with less bells and whistles, more standard web stuff. > It disagrees with many of the (much more popular) frontend frameworks far too much. Ember, React and others plan to eventually support them. So, I am unconvinced that it disagrees with them at all. In fact I…

>Huh? It's a very small API built _into_ the web browser. Being built into the browser doesn't make it lightweight. I mean, if you look in terms of functions that WebComponents adds, it's a relatively small API surface. However those APIs encompass an awful lot of different functions that imo bloat basic concepts by introducing complexity into HTML elements and the DOM. >Ember, React and others plan to eventually sup…

> However should React let you export a component as a "WebComponent," via custom elements, sure, that's fine. Interoperabilility is not really notable though.

I don't really care about exporting my React applications as Web Components; I'm not going to re-use them inside another application anyway.

What I care about is React supporting interoperability in the sense of allowing Web Components to be used in a React application. I think that's largely possible already, but slightly cumbersome, IIRC.

I also don't really care about the other option: exporting a React Component as a Web Component. If I want to re-use a component in a different application, that's when Web Components by themselves are the right choice, and I'd prefer not having to ship React with it. Especially not once you get to the likely point where you'd want to use two different Web Components that use two conflicting versions of the same framework, or multiple components pulling in different frameworks.

Re: Web Components could replace frontend frameworks?

#152
post #52

The reality of Web Components is that it was never intend to take share away from the large frameworks. Instead Web Components is intended to fill the middle ground between a simple web page and a full blown web application. There is a real need for web page developers to be able to just drop in a prebuilt web component and go without having to reach for the 10,000 pound gorilla of frameworks. That’s where Web Compon…

> The reality of Web Components is that it was never intend to take share away from the large frameworks. Instead Web Components is intended to fill the middle ground between a simple web page and a full blown web application.

Exactly. More specifically, it was created in response to the years-long hiatus in development of the HTML spec, when we were still waiting for a date picker element (heck, we still are!).

With Web Components, we might all use the same widely supported and actively maintained emoji picker regardless of the framework we're using. But they do not solve the problems that framework solves.

Re: Web Components could replace frontend frameworks?

#153

Web Components don’t offer a declarative way of updating the DOM; it’s still `innerHTML` and using DOM APIs to edit the state of the live DOM. Backbone was a hassle to manage in any sizeable app because updating the view was left up to every dev to figure out themselves. React brought a declarative wrapper around the statefulness of the DOM, and that is the killer feature that Web Components does not offer at all. Vu…

I use lit-html and it is more than enough for our needs!

Re: Web Components could replace frontend frameworks?

#154

Web Components did replace frameworks for me. I built KanRails ( https://www.kanrails.com/ ) with LitElement, without React/Vue/etc. The alpha is at https://app.kanrails.com/signup . Again, it's in alpha. It is essentially a Trello + Google Forms + Workflow wannable. How? Stick to patterns, not libraries. Check out https://pwa-starter-kit.polymer-project.org/ for LitElement starter kits. And just use Webpack, rip out…

Right... why use an existing framework when you can just build your own!

Re: Web Components could replace frontend frameworks?

#155
At least for current Web Component API, no.

Html is good because it's declarative, but it's not good since it lack abstraction. So React combine JSX template and lambda as declarative component. Means you have parametrized template and loop etc.

Vanilla and jQuery is not so good because it's not reactive by default, which means you're not always describing things you want, instead you have to update something. Eventually you will forget some. It's called imperative.

Current Web Components spec include attribute changed hooks but it's far from React since most of the APIs are imperative.

But why declarity matters? Because it turns out front-end world is totally different from request-response backend programming. Because in front-end you're dealing with continuous sequence of signals instead of one off requests. Declarative style makes you describe the relation between model, views and derived values, not how to update or maintain those relations.

Re: Web Components could replace frontend frameworks?

#157
I think a lot of you are missing the point of Web Components here. They're not going to replace React et. al for huge frontend applications. But they are a great solution to drop in for a lot of projects where you need things like:

- Sliders

- Lazy loading images

- Complex select dropdowns

Rather than having to import a js file, css file, and use some weird wrapper around the existing DOM we have, we can import one file and be done with it.

Re: Web Components could replace frontend frameworks?

#158
I see a lot of anger directed at the innerHTML command for various reasons. Then i think, what about the html tag, why isn’t that illegal yet, you know, the one that imports your latest fancy framework into the dom, surely thats an antipattern and a code smell.

Re: Web Components could replace frontend frameworks?

#159
post #9

>Web Components will replace your frontend framework Yeah, I very much doubt that. Web Components is basically a suite of browser technologies. It's actually particularly heavy and I kind of hope it doesn't catch on personally, since it pushes so much to already giant monolithic web browsers. Frameworks and libraries like React and Angular are tools for developing applications first and foremost. The actual technolog…

Thank you for your constructive argument. I now know I don't need Web Components either ;-)

Re: Web Components could replace frontend frameworks?

#160
Web Components are an ideal complement to pure statically typed languages like Elm, where it's a bit of a hassle to implement simple, isolated components.

An example would be: a text paragraph which has "read more" button, when clicked, expands. Or an info popup with a "close" button. No need to put its state in your model and forward its messages.

Post reply on HN