News for hackers. Stuff that matters.
Re:Understanding React Compiler by codeflo on Friday June 28, 2024 @09:00AM (#40820206)
I mean, if you don't understand how specialized inlined code could be faster than a generic function, or how not creating temporary arrays could be faster than creating them, then it's clear that you can't see that there could be any benefit.

I can't judge the React compiler yet, but in general, compilation steps don't cause cognitive load if they work. How many different levels of interpretation and compilation does V8 do? And do you care? Do you have to? No, and that's the point. Whether React Compiler reaches the same level of "it just works", we'll have to see.

Re:Understanding React Compiler by afavour on Friday June 28, 2024 @09:22AM (#40820377)
> How many different levels of interpretation and compilation does V8 do?

This part is key to the OPs objection. They’re saying that V8 is a very capable optimizer (which it is), so why can’t it optimize the things React Compiler optimizes? It’s a fair question.

> compilation steps don't cause cognitive load if they work

Personally I disagree. Any source code transformation adds cognitive load because my original source code now doesn’t match the source in the browser. Source maps are the traditional answer to that but if React is rewriting logic (like getting rid of arrays) you’re not going to be able to maintain a 1:1 source map.

Re:Understanding React Compiler by a_wild_dandan on Friday June 28, 2024 @09:49AM (#40820581)
> They’re saying that V8 is a very capable optimizer (which it is), so why can’t it optimize the things React Compiler optimizes?

Because capable != exhaustive? All compiled languages can benefit from further optimizations. I genuinely don't understand the issue here. Help!

Re:Understanding React Compiler by andybak on Friday June 28, 2024 @10:13AM (#40820785)
I think OP is questioning whether these are optimizations or whether they are just redundant.

I don't know the answer - I don't use React personally.