Live data from Hacker News

Web Components could replace frontend frameworks?

dannymoerkerke.com

171–180 of 248 posts

Re: Web Components could replace frontend frameworks?

#171
post #163

Earlier quoted context omitted.

It’s still opaque string blobs no matter how you try to dress them up. —- I should probably edit this: It’s still string blobs that are totally opaque to the browser, and that are parsed with regular expressions[1] at runtime[2] and dumped into DOM via innerHtml[3]. [1] https://github.com/Polymer/lit-html/blob/61c08a615abadbe58bc... [2] http://exploringjs.com/es6/ch_template-literals.html [3] https://github.com/Polym…

It's a bit disingenuous to say the templates are parsed with regular expressions. The way lit-html generates DOM Templates from strings is by letting the browser parse the string through innerHTML. The purpose of the regexes you are referring to is to find the correct insertion points for dynamic values in the template, and has nothing to do with the HTML parsing process. There is nothing fundamentally wrong with usi…

> It's a bit disingenuous to say the templates are parsed with regular expressions. The way lit-html generates DOM Templates from strings

"generates DOM templates from strings" - parses opaque string blobs [1]

- parses them with regexps [2]

- concatenates string chunks together [3]

- dumps the resulting string blob into DOM via .innerHtml [4]

So it does everything that was considered bad programming practices as early as 1999. And does all that at runtime.

> and has nothing to do with the HTML parsing process.

Yeah, no. This is literally parsing HTML with regexps. Because lit-html has to know whether a value is inside an HTML attribute, or inside a tag, for example. In order to know that it has to... well, parse the string that's passed to it. And what do you pass into lit-html? Oh, HTML. That it parses.

> I don't think anyone is advocating to replace index.html with a single script that creates these nodes using a virtualDOM type rendering system.

Yeah, you're apparently advocating to replace index.html with a function call that parses strings at runtime and dumps blobs of strings via innerHtml into DOM.

[1] Because tagged template literals are just function calls with lists of strings, and some values

[2] https://github.com/Polymer/lit-html/blob/master/src/lib/temp...

[3] https://github.com/Polymer/lit-html/blob/master/src/lib/temp...

[4] https://github.com/Polymer/lit-html/blob/master/src/lib/temp...

Re: Web Components could replace frontend frameworks?

#172

Earlier quoted context omitted.

React is pure JS, no string parsing is involved at runtime (JSX is just function calls [1]). Vue has its own templating language that gets compiled to function calls that are very similar to React’s [2]. I have my fair share of criticisms against Vue (as any templating system, it’s quite inconsistent[3]). I don’t think any of them just dump string blobs via innerHtml. And I doubt any of them parse strings with regexp…

> React is pure JS, no string parsing is involved at runtime (JSX is just function calls [1]). Why does this matter? React still eventually compiles down to DOM operations whether that be innerHTML or XML modifications.

To quote stevebmark [1]

--- quote ---

…we’ve learned not to write code in strings. You’d think this would be a fundamental law of software engineering

Writing code, not strings, means you can do everything to it that you can do to code. You can type check code. You can lint it. You can optimize it, compile it, validate it, syntax highlight it, format it with tools like Prettier, tree shake it…

--- end quote ---

https://news.ycombinator.com/item?id=18511943

Re: Web Components could replace frontend frameworks?

#173

Being native to the browser, how fast is it compared to React? It is 10x faster because it's native? Is it on par, with room for browsers to improve it's performance even further? I'm all for something that's native to the browser. Right now you write a ` ` tag for a paragraph element. No question about it. Imagine if you needed to use a P-tag library just to render a paragraph tag? Of course not right, you would jus…

I totally agree - we need "one framework to rule them all". I don't want to learn another 10 technologies we won't use anymore in 5-10 years.

Re: Web Components could replace frontend frameworks?

#174

I wonder why HTML never got includes. It would be so nice to just write: On Hacker News, for the first pageview, this would load the whole "Guidelines | FAQ | Support ..." section. On all other pageloads, the browser would already have it in the cache. So it does not have to be loaded again. Building complex websites would become so much nicer. Because each part of a page would be an include.

If you are looking for just a simple load some html and replace this where my tag is kind of thing you are right, nothing does that because it’s more complicated then that... what about the styles of the included html? What about the behaviors (JavaScript) for it. How does that translate with the include?

But, if you use Web Components, organize your code, and plan ahead, this is very doable today with Web Components. You just create say a component complete with style and behavior, and then drop that into your page html along with an import of the component definition. It’s clean and simple and the encapsulation of all your footer needs in one place is really nice.

ZephJS, the library I am promoting, or another Web Component engine, makes this even easier and allows your components to be bundle yup really nicely. ZephJS, for example, offers a cli bundler command that does this (via rollup) and it makes for a really clean component experience. https://gist.github.com/arei/8083a6270e704b830c68a2020f3e5e3...

B

Re: Web Components could replace frontend frameworks?

#175
One thing that is particularly important to take into account when comparing web components to framework is that they can and should work together. If indeed "web components" replace your "framework" it will most likely be because a new framework that takes advantage of web components and all that the web is now replaces your old framework. Already libraries that combine popular concepts like hooks from React with web components (https://github.com/matthewp/haunted) are pointing the way to a more powerful future for both site that need just that little extra something via a stand alone web component or a whole family of components wedded to a framework into a rich application. That being said, don't get confused by people on either side being overly defensive of their place in the web ecosystem things are they are now will change. Techniques will grow and merge and there will be something else that is "the thing" before too long. Web components will likely be as much a part of that as the elements who's shoulders they stand on (e.g. and ). That's the power of the web.

Re: Web Components could replace frontend frameworks?

#176

I love writing Web Components, but they're never going to really be a thing. The promise was that we could create native components without any dependencies at all but it just hasn't worked out that way. Shadow DOM support, the real killer feature, is patchy at best without polyfills. Orchestrating them into any kind of complex app still requires some kind of framework to handle things like passing down props and eve…

Strongly disagree. We (Ionic) built our new version directly on top of Web Components and they are certainly a thing for us and our users building real apps on top. Plus, they are a huge reason why we now support React and Vue and plain JS. Frankly, this has been transformational for our project and for our business . I'm completely sold. One problem with the WC debate is people constantly compare the raw Web Compone…

> In that sense, the killer app for Web Components is actually Design Systems, not SPAs.

My read too

Re: Web Components could replace frontend frameworks?

#177
post #167

Earlier quoted context omitted.

Yeah, articles that proclaim the end of frameworks due to Web Components always revolve around a misunderstanding of what those frameworks bring. This article, likewise, starts out on the same incorrect premise: > [Frameworks like Angular and React] have enabled us to do what we always wanted but never were able to: creating reusable autonomous frontend components That's not what we always wanted to do, and not why p…

I reuse react components ALL the time. I think the problem with the article is that it is just looking at components (as a developer I have wanted the encapsulation this methodology brings), whereas react offers more than that - the virtual DOM, for example.

Ah, yes - within the same applications, components are often re-used. Still, it's a stretch to say code re-use is the main reason people are using React. Rather, its advantage lies in its composability and how easy it makes it to separate view logic from other logic. And probably a few other reasons that other people would name as well; in any case, it's not just the ability to re-use components, and an alternative only providing that part is not going to replace React in my applications any time soon.

Re: Web Components could replace frontend frameworks?

#178
post #167

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…

Yeah, articles that proclaim the end of frameworks due to Web Components always revolve around a misunderstanding of what those frameworks bring. This article, likewise, starts out on the same incorrect premise: > [Frameworks like Angular and React] have enabled us to do what we always wanted but never were able to: creating reusable autonomous frontend components That's not what we always wanted to do, and not why p…

> How often do you re-use your Angular and React application?

A lot, our Angular components are re-usable across projects.

Re: Web Components could replace frontend frameworks?

#179
post #139
post #104

Earlier quoted context omitted.

Yeah, the DOM the web layout engine isn't complicated at all ... display: block; display: inline; display: run-in; display: flow; display: flow-root; display: table; display: flex; display: grid; display: ruby; display: block flow; display: inline table; display: flex run-in; display: list-item; display: list-item block; display: list-item inline; display: list-item flow; display: list-item flow-root; display: list-i…

Those file sizes miss the dependencies that are native to the browser. Web Components: 0 kb

You forgot the polyfills.
Post reply on HN