Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is over-simplified: the overhead of an abstraction can be cancelled out by work or optimizations which you wouldn't have done without the abstraction. As a simple example, most Python programs are faster than the C code the same developer would have written in the same time because they have a rich library of optimized code and getting it working quickly means that they had more time to focus on algorithm-level improvements. That of course doesn't mean that a C programmer can't beat it in performance but once you're past very simple examples those abstractions are harder to beat than they might seem — I've seen multiple cases where someone thought they could do that and wasted days (or in one case, months) only to eke out less than a 10% improvement.

In this case, React is slow and memory hungry because when you make a change you go through this process:

1. Update some value

2. … triggering updates to the virtual DOM

3. … requiring it to caluclate the difference between the real DOM and the virtual DOM

4. … and finally apply the changes to the real DOM

That abstraction requires substantial extra state to be stored and managed. If you have a different abstraction which directly manages the DOM, you can avoid steps 2 and 3. The big question is a) does your code do enough manipulation for this to be noticeable? (React is less slow than it used to be but I've seen 4 order of magnitude deltas in optimized React code so it's not uncommon to see it chug with large pages, especially on older hardware like a lot of the public uses) and b) does that other abstraction have drawbacks for your developers which cost you more than the performance savings?



Tough crowd today... My comment was a reference to xkcd: https://xkcd.com/378/

Maybe I should have made it more obvious by referencing the butterflies instead.


Heh, yes. This runs into something like Poe’s law because you can find people who sound exactly like that but are serious. I especially remember someone’s reaction when their hand-tuned assembly started under-performing compared to GCC once we recompiled for (IIRC) Pentium 4 chips.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: