News for hackers. Stuff that matters.
Re:Inline CSS works better in a component world by inglor on Thursday August 20, 2020 @04:36AM (#24221183)
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.

Re:Inline CSS works better in a component world by krageon on Thursday August 20, 2020 @04:46AM (#24221253)
You'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?

Re:Inline CSS works better in a component world by ximm on Thursday August 20, 2020 @05:12AM (#24221381)
> 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.

Re:Inline CSS works better in a component world by j-krieger on Thursday August 20, 2020 @05:58AM (#24221613)
SSGs use templates with template arguments. How is that different from a component?
[dead]
Re:Inline CSS works better in a component world by dragonwriter on Thursday August 20, 2020 @05:30AM (#24221495)
> 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.

Re:Inline CSS works better in a component world by mosselman on Thursday August 20, 2020 @10:10AM (#24223408)
You are right in correcting me that MVC et al. can also reference something other than frameworks like Rails. I may have jumped the gun there.

> I'm not sure what want/need distinction you are trying to make here.

What I feel is happening in these discussions is that people take the issues they run into when creating SPA with component frameworks (state management, making calls to back ends and error handling to name a few) and present them as fundamental issues of creating web applications.

When React first came out, you quickly ran into the issue that, for a bigger application, you needed to pass too many parameters through the whole stack to reach the outermost components just to update something like a counter badge, etc. Then came Redux and it 'solved' this.

This issue of passing parameters down the component stack is only an issue within the context of using a stack of components. It isn't one of the issues that exist when building a web application using server side rendering. So what I mean with 'you don't need' state management in the front-end is that the issue of managing state is completely inherent to building a UI with components, it isn't an absolute problem of creating web applications.