React uses exceptions for flow control!?!?!?!!?!
Never do this. Exceptions are for exceptional cases. It's right there in the name. Basically all implementations of exceptions optimize heavily for the non-exceptional case, at the expense of the exceptional case, because duh.
(And yeah unfortunately we're seeing this throw is happening *quite often* in some of those benchmarks...)
@KentonVarda i have news for you about how nextjs does redirects
@aaron__vi TBH I'm not that offended if it's one time at the top level of a request (I mean, slightly offended, but meh). React is seemingly doing it on every chunk of a stream, wtf.
@KentonVarda Python pretty much has this as a part of the language itself in the iterator protocol.
@hacksparr0w JavaScript also has iterators and generator functions.
@KentonVarda It's a port of OCaml's coroutine (algebraic effect), and back in OCaml exceptions are cheap. The fancy semantics React copied are correct except the perf didn't carry over
@KentonVarda @justfly1984 Yes, for "aborting" deep stack nestings. It's actually pretty efficient in that context.
@KentonVarda Your "exception as control flow logic" strikes again! (https://pytorch.org/blog/intro...
@KentonVarda The magic of react suspense. throwing you guessed it... promises not errors.
@KentonVarda Suspense is also based on throwing a promise
@KentonVarda Reminds me of Bryan Cantrill on Ruby blasting thru array’s and then catching exceptions to know when they got to the end, instead of iterating to the last element in a… sane way? https://youtu.be/YKv_IDN0zCA 26:45-30:00
@KentonVarda I could be wrong but I think this is how react implements the fiber runtime. The y need short circuiting to jump onto different fibres of work in a single threaded runtime I believe
@KentonVarda How to do it? Return an optional? Class?
@KentonVarda based
@KentonVarda That's how suspense works if i understood it correctly

