TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Understanding React Compiler

114 pointsby kiyanwang11 months ago

12 comments

vbezhenar11 months ago
I used to think that React is awesome, but this has gone too far. They just don&#x27;t care about JavaScript.<p>1. They introduced hooks which must be called in the same order for every execution. You can&#x27;t put hook inside `if`. Hooks are based on magic. This is terrible design.<p>2. They didn&#x27;t adopt async&#x2F;await, inventing their own suspend stuff.<p>3. Now this: they just convert the source language into something else.<p>The JSX idea is gold: introduce XML-like template syntax into the language to avoid need for foreign template language. Make XML templates valid at startup and even with proper types for TypeScript. This is very important advancement compared to text templates which are used everywhere else.<p>The stateless render function is good. Emit desired-state, let framework to reconcile current state to desired state.<p>But rest of React is not gold.
评论 #40822597 未加载
评论 #40823584 未加载
评论 #40822516 未加载
评论 #40822443 未加载
评论 #40822745 未加载
评论 #40822654 未加载
评论 #40822299 未加载
评论 #40821875 未加载
评论 #40823631 未加载
评论 #40823242 未加载
评论 #40821354 未加载
评论 #40824288 未加载
a_wild_dandan11 months ago
I love React. It feels foundational somehow. It&#x27;s also vindicating after toiling for years on bloated frameworks. Declaratively describe your UI, React paints it. That&#x27;s it. No app state management. No routing. No learning yet another templating system (which inevitably morphs into a shitty programming language). Just full JS(X optional). No grokking convoluted, bespoke abstractions. It&#x27;s clean, narrowly scoped, and as simple as possible (but not simpler).<p>Having recently worked on two legacy apps -- one ASP.NET, one Angular -- it made me deeply appreciate React and how far UI tech has come. Phenomenal work from the React team on more optimizations via this compiler. Good article too.
评论 #40821773 未加载
评论 #40821489 未加载
评论 #40822583 未加载
评论 #40822867 未加载
whalesalad11 months ago
I haven&#x27;t used React in about 6 years - used to be pretty heavily involved with it across web and native. These days I truly feel like ecosystem has lost its mind and the developers are just bikeshedding the most esoteric and unhinged choices possible.
评论 #40821041 未加载
评论 #40820631 未加载
评论 #40823262 未加载
评论 #40822652 未加载
评论 #40820629 未加载
rixtox11 months ago
I think React would get better developer experience and performance if they adopt language coroutine feature to implement direct style algebraic effect. In fact the React Fiber system is already an implementation of algebraic effect.[1] However, it’s “suspending” a routine by raising an exception. Thus unwinding all the call stack, therefore, it needs to re-run that same routine on resume. This is the core reason why they have a performance issue and why they created the compiler to cache values on reruns.<p>JavaScript has language level coroutine features like async&#x2F;await or yield&#x2F;yield* and we have seen libraries using these features to implement direct style algebraic effect. For example Effect[2] and Effection[3]. You don’t need to memoize things if the language runtime can suspend and resume your functions instead of throwing exceptions and rerun them.<p>[1]: <a href="https:&#x2F;&#x2F;youtu.be&#x2F;7GcrT0SBSnI" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;7GcrT0SBSnI</a><p>[2]: <a href="https:&#x2F;&#x2F;effect.website&#x2F;" rel="nofollow">https:&#x2F;&#x2F;effect.website&#x2F;</a><p>[3]: <a href="https:&#x2F;&#x2F;frontside.com&#x2F;effection&#x2F;" rel="nofollow">https:&#x2F;&#x2F;frontside.com&#x2F;effection&#x2F;</a>
评论 #40823144 未加载
评论 #40823113 未加载
BigJono11 months ago
What am I missing? You gave two examples:<p>The first is replacing useMemo with some inline code that does the same thing, so, as far as I can tell that literally saves just one function call to useMemo but none of the actual work it does? How could that possibly have a performance impact?<p>The second is de-inlining (or whatever the proper word is) map(x =&gt; foo(x)) to save function definitions on each loop. I don&#x27;t understand why a &quot;React compiler&quot; would be able to do this if a JS JIT compiler can&#x27;t, what guarantee does it have that a JS compiler doesn&#x27;t? This should be done by V8 or not at all.<p>Even though you have a whole paragraph on the cognitive load of an extra compilation step at the end of your post, which is bang on, IMO you don&#x27;t even come CLOSE to explaining why this trade off is worth it.<p>I&#x27;ve been telling people for nine years that React is the best of the declarative DOM libraries because it has a simple line-for-line transform instead of a big complicated compilation step. It looks to me like we&#x27;re just throwing that all in the bin for absolutely fuck all.
评论 #40820553 未加载
评论 #40820529 未加载
评论 #40820199 未加载
评论 #40821017 未加载
评论 #40820897 未加载
评论 #40820188 未加载
评论 #40820206 未加载
Waterluvian11 months ago
The thing I&#x27;m struggling with as I read the official documentation and various blogs is exactly how this changes the <i>developer experience</i>. Do I get to remove `React.memo` and `useMemo` and never use them again? Is their use still useful for other cases? What do I have to think about when writing components so that I get this automagical memoization in some cases?
评论 #40820088 未加载
willsmith7211 months ago
I love how we&#x27;re all talking about state management.<p>Just use Remix. The database&#x2F;url is your state.<p>Messy state management in Client-Side react is a problem of the late 2010s
评论 #40830392 未加载
chrsig11 months ago
Slightly tangential question: Where is jsx defined, as a language? are there multiple transpiler implementations? is it standardized at all?
评论 #40822146 未加载
评论 #40820101 未加载
评论 #40819885 未加载
评论 #40820044 未加载
robertoandred11 months ago
Not sure what everyone is so upset about. Since when is code optimization a bad thing?
TonyAlicea1011 months ago
I’m the author of this blog post, very cool to have it here.<p>One thing I didn’t say in the post: I’m very much a fundamentals-first kind of dev. I teach fundamentals in my courses.<p>I don’t think you should use tools like frameworks or transpilers&#x2F;compilers without understanding how they work, because debugging is always better when you know what the tool is doing for you, and it makes it easier to use the tool. React is a particularly leaky abstraction that benefits from understanding it under-the-hood.<p>You need strong fundamentals to understand how things work.
gepardi11 months ago
I’ve worked with React, plenty of years. I haven’t had to touch it in months and don’t want to.<p>Seeing JSX and reading about all the complexity in this post makes me hope I’ll never use React again.<p>BTW I do like JavaScript.
meiraleal11 months ago
For almost 10 years, the core react developers would repeat incessantly: React is a library, not a framework.<p>In the past 2 or 3 years, they just &quot;gave&quot; up, turned it into the biggest most bloated framework in the frontend area while the official Web APIs in the browsers evolved so much that React is actually completely useless and now it is completely useless with a compiler.<p>I&#x27;m wondering if that was actually the reason they pivoted to this Frankstein? The loss of relevance as a frontend library.<p>Anyway, I jumped off the bandwagon and don&#x27;t have a say in this fight anymore. But I&#x27;m doing my part advising every Junior Developer to not make the mistake of choosing React today.
评论 #40820229 未加载
评论 #40820415 未加载
评论 #40820761 未加载
评论 #40820112 未加载
评论 #40820755 未加载
评论 #40822861 未加载