DEV Community

Discussion on: Components are Pure Overhead

etienneburdet profile image
Etienne Burdet • Edited on

Great article!
A lot of of what you say reminds me of the downside people find in OOP: at some point you need so many accessors and shared methods that your object hardly encapsulate anything. More often than not, components are indeed implemented as classes-or something very close to it and you end up with an absurd amount of props and cumbersome ways to share them.

I recommand the most excellent [talk by Catherine West] and would quote two things:

  • “Sometimes, the elegant implementation is just a function. Not a method. Not a class. Not a framework. Just a function." (originally from Carmack)
  • You can learn an enormous amount about how software works just by looking at its data structures. (Not it's classes or methods !)

It's for Rust and game dev, sure, but I totally relate for web dev. Sometimes I just want a simple function. Sometimes I would just like a few UI elements to "killable" and have that killable define somewhere as a simple function.

I used to think as framework as a ways to suppress the mess, but that's a lie. At best you hide it in patterns, but if what you design is messy, the functions will be. Today I'd rather have a simple framework that makes my life easier on two aspect:

  • React to changes.
  • Manipulate the DOM accordingly.

My days of doing DOMless components or trying to fit a Mapbox entities in Svelte are over! I did it. I won't do it again 😄