If Dart is going to target JavaScript or replace it someday, I'd like
it to have weak references. I have grepped specification for words
"weak", "raii", "finally". Hopefully Dart has try ... finally, but
still far from having weak references.
Weak references are essentional in functional-reactive programming.
Visit
http://flapjax-lang.org/ , watch video at
http://asana.com/luna/
to become familiar.
In FRP environments behaviors are everywhere, and they are linked
bidirectionally. When "a" changes, it notifies "a * b". In order to do
so, "a" has stored a reference to "a * b" behavior. In JavaScript
nothing will be garbage collected without an extra effort.
Extra effort is high enough e. g. introducing reference counting
overhead in an overlay language that targets JavaScript. Every closure
and every object must be reference counted to make it work. Or,
alternativelly, limiting FRP to an in-memory database semantics. In a
databases, DELETEs are explicit and so is destruction of behaviors in
the second case. Behaviors can't be used just like normal values.
Third way is to don't bother about dead data still sitting in memory
and consuming CPU. Sooner or later user will reload the page.
A fourth way... maybe we can introduce our own garbage collection in
an overlay language that targets JavaScript.
Lack of weak references results in big headache
--
If you want to get to the top, you have to start at the bottom