5 ms·
Not going into the CSS vs. inline bit (I think CSS modules solved this for components years ago) but I think composing components is a reasonable abstraction an
by inglor 6y ago
Not going into the CSS vs. inline bit (I think CSS modules solved this for components years ago) but I think composing components is a reasonable abstraction and it _is_ self evident because it's what we've been doing everywhere else.
"Component based" is basically just "functions composing other functions and calling each other in a top-down flow with bottom-up updates through framework state". It's "evident" that it's the correct abstraction because the alternatives (things like managing app state and UI interactions through MVC, MVVM and MVP) are mostly not needed or are not the right level of abstraction for composing large UIs in web apps (where components make it trivial and shift the complexity to stitching the state manangement <-> component interop when you need to break the abstraction).
Also - components are pretty uncontested these last few years.
- krageon 6y agoYou've outlined a preference, but you haven't informed the reader why your preferred solution is superior other than by saying that it makes your problems "trivial" (which in any moderately complex problem space is extremely unlikely). If I can't see it given that I have actual experience with what you're talking about and can reasonably be expected to have the background to understand, how is someone from a different field supposed to understand what you wrote?
- ximm 6y ago> components are pretty uncontested these last few years I don't think so. Many people still use traditional frontends, i.e. static or server-rendered HTML and CSS. Components are newer and there is still more to talk about, so they naturally are more prominent on sites like hacker news. That doesn't mean they are uncontested in practice.
- j-krieger 6y agoSSGs use templates with template arguments. How is that different from a component?
- mosselman 6y ago> Also - components are pretty uncontested these last few years. Throwing buckets of shit out the window was uncontested for years in medieval times as well. > is basically just With this you are basically just paraphrasing 'self evident'. > It's "evident" that it's the correct abstraction because the alternatives (things like managing app state and UI interactions through MVC, MVVM and MVP) are mostly not needed or are not the right level of abstraction for composing large UIs in web apps (where components make it trivial and shift the complexity to stitching the state manangement <-> component interop when you need to break the abstraction). MVC isn't the alternative to components. You are comparing apples and oranges. You don't need MVC to compose large UIs in web apps. You use the MVC pattern to separate concerns: fetching data from the database (M), presenting said data (V), handling requests and managing sessions (C) and because the pieces of code live in different places: MC on the server, V in the browser. Whatever you do in the V is what we are talking about, you still need places for M and C in an SPA. > just "functions composing other functions and calling each other in a top-down flow with bottom-up updates through framework state" The whole "top-down..bottom-up" thing is a mechanism that only makes sense when you have decided that you want to have some sort of SPA, it isn't something you _need_ or an alternative to how things were done before, you are making it sound like it is. Alternatively to using something like React, you could render HTML and go from page to page, redirect after handling a form, etc. In that case you don't need any stack of functions that need lots of passed down data and state management at all. I am not saying either is better in all cases. I am trying to point out some inaccuracies in what you are saying.
- dragonwriter 6y ago> MVC isn't the alternative to components. MV(C/VM/P) is in fact one of the front-end alternatives to components. > You don't need MVC to compose large UIs in web apps. As the argument was that components were the obviously correct solution to that, I think the poster you are responding to would agree you do t need MVC, etc., for that, but they are still used for it. > You use the MVC pattern to separate concerns: fetching data from the database (M), presenting said data (V), handling requests and managing sessions (C) and because the pieces of code live in different places: MC on the server, V in the browser. Classical MVC was for local GUI apps, an the later original web MVC had all three components on the backend. (View being the conponent that rendered final HTML, or XML/JSON for APIs, often from templates + objects from the controller.) In web frontend, the M usually interacts with APIs rather than DBs, the V still renders HTML, and the C, VM, or P does it's usually role. > The whole "top-down..bottom-up" thing is a mechanism that only makes sense when you have decided that you want to have some sort of SPA, Sure. > it isn't something you _need_ I'm not sure what want/need distinction you are trying to make here. > or an alternative to how things were done before Both having a SPA and using components vs other approaches for a SPA are alternatives to what was done before. You seem really only to be disagreeing with the latter, but HTML+JS apps that were SPAs (even if the name wasn't originally in use) are almost as old as JS, and much older than component based approaches.