

Reactive Programming in JavaScript - salar
http://engineering.silk.co/post/80056130804/reactive-programming-in-javascript

======
sfvisser
Inspired by the client side FRP library we use internally, I've build a small
Haskell version as well:
[https://gist.github.com/sebastiaanvisser/9639321](https://gist.github.com/sebastiaanvisser/9639321)

Although the implementation is different, I tried to keep the interace similar
in spirit. Building a Haskell version of a JavaScript library on the side
really helps validating your design decisions.

------
jongold
This is excellent - I've been enjoying playing around with ReactiveCocoa
recently and it's nice to see how those concepts can work in JS.

Question (and opening a can of worms) - if I'm looking to learn more about FP,
should I go for Haskell or Clojure?

~~~
dropit_sphere
As someone who's been going down this rabbit hole for the last year or so:

Haskell is worth learning because a lot of the work done in FRP has been done
in a Haskell mindset. Flapjax, Fran, reactive-banana, Elm---all are written in
Haskell or trace significant ancestry therefrom.

Clojure is worth learning because, well, it's the future, but also because the
community seems to be bent on finding actual application for lofty CS
concepts. If you want to use facebook's React, you can use JS, coffescript,
facebook's "JSX" compiler, or clojurescript. I'd argue that clojurescript is
the most pleasant option.

If you want to learn about FRP inside and out, Haskell. If you want to write
something cool and reactive, Clojure.

(Other names to look at if you go clojure: Shafty, Javelin, Lamina,
core.asynchronous)

------
thecolorblue
Looks cool but I prefer the syntax of angular's data binding (no need to use
#get() or #set()). Is this pretty much the same as angular's data binding?

~~~
sfvisser
The ideas here are similar in a sense. I'm not an expert on Angular, but their
focus seems to be on templates that update automatically using data bindings.
Our framework focuses more on compositionally of reactive data networks,
connecting it to the DOM using reactive jQuery methods is just one of the
outputs we allow.

The set and get methods are there to go from the JS world to the reactive
world and back. Usually you're working with reactive variables (as if they
were actual values) directly, in that case you won't use get and set at all.

~~~
thecolorblue
Ok, I see where there is not getting/setting. Looks very cool.

In angular, there are no setters/getters, you just set values the vanilla
way... val = newVal; Angular keeps a reference and a copy of all the watched
variables, checks for a change during the 'digest' cycle, and triggers events
accordingly. It's not completely for updating the DOM. The syntax for Reactive
looks cleaner (I guess ES6 helps a bit).

------
hexasquid
Awesome! Where is the library? I've been looking on silks github but I must
have missed it.

~~~
hesselink
Sadly we haven't open sourced the library (yet?). The actual implementation is
quite a bit larger, and messier, than described in this blog post.
Additionally, it's written in our own module system. So while we'd like to
open source it, it currently is more work than we have time for.

------
worldsayshi
I think I see a typo: 'asVar' should be 'myValue'

~~~
sfvisser
Fixed, thanks!

