News for hackers. Stuff that matters.
Re:Algebraic Effects – You Can Touch This (2019) by tuukkah on Wednesday December 14, 2022 @04:17AM (#33981515)
Considering that React with function components is popular and their hook mechanism is seemingly weird, should people also learn algebraic effects as the beautiful theory behind it?

Also, if React hooks is the way to describe UI components, I think the mechanism behind it should be either formalised as a proper language feature in JS or in some new language used for frontend development. For example, I noticed this teaser bit in the first materials about Verse: "The full Verse language also has a statically-checked effect system, including both mutable references and input/output." https://simon.peytonjones.org/verse-calculus/ Discussed earlier here: https://news.ycombinator.com/item?id=33946933

Or is this something that e.g. ClojureScript with Reagent already formalises and we all should study that?

Re:Algebraic Effects – You Can Touch This (2019) by seer on Wednesday December 14, 2022 @05:25AM (#33981849)
Well there's https://crank.js.org that uses native js generators where you would you normally put hooks in. Never used it but looked like a very neat idea. I believe Reagent utilises Clojure's native "atom" to accomplish what hooks try to do but with much better language level guarantees.

I guess what js needs is an actual proper language level immutable type, and it wouldn't need all the hooks trickery?