Couple this with the new concept of Virtual DOM as pioneered in React and you get purely functional UI on the web, a radical departure from the status quo of just a few years ago. Defintely a new development for JS. Indeed, React Native suggests that this could be an important development for UI in general.
* Dynamic Typing * Garbage Collection * First Class Functions
However, Python also meets those requirements. Now, looking at it from the Scheme perspective, Python is missing
* Tail Recursion * Macros * Continuations * Concise Language Spec
However, Javascript is also missing those same factors (though I might be wrong about the tail recursion). Yet, I rarely hear of Python described as an infix version of Scheme, yet I often hear that remark about Javascript.
I really want to like Javascript and I already do like Scheme, so I have a vested interest in seeing the connection, but I'm still missing something. What's the strong resemblance between Scheme and Javascript?
def why_is_scoping_hard():
n = 4
def print_n():
print n
def modify_n(new_value):
n = new_value
print n
return [print_n, modify_n]
>>> print_n, modify_n = why_is_scoping_hard()
>>> print_n()
4
>>> modify_n(7)
7
>>> print_n()
4
When you assign to a variable it is automatically created in the local scope, shadowing a variable with the same name from an outer scope. If you don't assign to it, you get the value from the outer scope. If you try to print it, but then assign to it later, the print call raises an error. def modify_n(new_value):
nonlocal n
(and of course the print x -> print(x) changes), will result in 4,7,7Scheme gets mentioned re Javascript because: https://brendaneich.com/tag/history/
Doug Crockford popularised prototypical inheritance and function programming techniques in JS on his blog nearly 10 years ago.
KnockoutJS has been around for a similar amount of time and data flow was a big part of its design. React and Elm are evolutions of design that has been a part of front-end dev for a long time.