Hacker News new | ask | show | jobs
by dustingetz 2984 days ago
Real functional languages have "lexical scope" and "dynamic scope", both are necessary for proper functional programming. React.js "functions" don't evaluate depth-first like a traditional call stack, but rather "breadth first" (because it offers optimization opportunities) and this breaks dynamic scope, so these Context hacks are an attempt to get it back. You are right though, I think React.js is not the end state and the harder we push it the more the "almost-functional-programming" abstraction is going to leak.
2 comments

This is totally incorrect. Context has nothing to do with JavaScript scoping behavior. Directly from the React documentation:

"Context provides a way to pass data through the component tree without having to pass props down manually at every level."

That is what dynamic scope is, and javascript doesn't have it, but ClojureScript does, and React still breaks it.
I'm sorry but you're not making any sense. What does the react context api have to do with dynamic scoping?
Today I learned: Haskell is not a "proper" functional programming language
It surprised me to find out that you're right, for anyone following along, I ended up here: https://news.ycombinator.com/item?id=3453141