News for hackers. Stuff that matters.
Re:Reactive Programming in JavaScript by sfvisser on Wednesday March 19, 2014 @06:53AM (#7427779)
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

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.

Re:Reactive Programming in JavaScript by jongold on Wednesday March 19, 2014 @07:00AM (#7427807)
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?

Re:Reactive Programming in JavaScript by dropit_sphere on Wednesday March 19, 2014 @07:28AM (#7427909)
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)

Re:Reactive Programming in JavaScript by thecolorblue on Wednesday March 19, 2014 @08:01AM (#7428021)
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?
Re:Reactive Programming in JavaScript by sfvisser on Wednesday March 19, 2014 @08:41AM (#7428186)
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.

Re:Reactive Programming in JavaScript by thecolorblue on Wednesday March 19, 2014 @08:51AM (#7428249)
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).

Re:Reactive Programming in JavaScript by cowbertvonmoo on Wednesday March 19, 2014 @06:53PM (#7432442)
Not exactly Functional Reactive Programming, FRB (Bindings) are actually a form of Self Adjusting Computation, but similar in spirit to what you see here, and what you see in Angular. You don’t need #get() and #set(), but it’s implemented using ES5 property descriptors and propagates synchronously. Also, unlike dependent properties like Ember, the dependencies do not have to be repeated—they are inferred from the expression language.

https://github.com/montagejs/frb

Re:Reactive Programming in JavaScript by hexasquid on Wednesday March 19, 2014 @09:07AM (#7428341)
Awesome! Where is the library? I've been looking on silks github but I must have missed it.
Re:Reactive Programming in JavaScript by hesselink on Wednesday March 19, 2014 @02:56PM (#7430879)
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.
Re:Reactive Programming in JavaScript by worldsayshi on Wednesday March 19, 2014 @06:49AM (#7427771)
I think I see a typo: 'asVar' should be 'myValue'
Re:Reactive Programming in JavaScript by sfvisser on Wednesday March 19, 2014 @06:55AM (#7427786)
Fixed, thanks!