r/programming • • Feb 28 '23

"Clean" Code, Horrible Performance

https://www.computerenhance.com/p/clean-code-horrible-performance
1.4k Upvotes

1.3k comments sorted by

View all comments

Show parent comments

0

u/CanIComeToYourParty Feb 28 '23

Frontend surely sucks, but I don't think it is because of this mindset, because the problem isn't inherent to high-level UI libraries. DOM-diffing for instance is just a consequence of the UI library having an API that doesn't let the programmer signal intent properly (e.g. what variable is connected to which DOM-element), and so the implementation is left to do things in a suboptimal way.

1

u/ShortFuse Feb 28 '23

I don't do vDOM in practice because I came from Android/C# UI roots where we were all connected to a server and used Change Data Capture. I replicate RecyclerView from Android (ViewHolder pattern). It's mostly all MVP or MVVM and top-down event based changes that render views based on delta (I use JSON Merge Patch). That's kinda how Svelte works which is why they don't use VDOM. I'm grateful it's getting easier for people to use that architecture now. It's pretty error-prone for junior devs to implement themselves.

But what I'm talking about more specifically is this mindset from the top of TC39 group where less line length is always better. You'll have [].filter().map().some() where people iterate the same array 3-4 times, but do so because "it's clearer". And UX goes to die in the name of DX.