News for hackers. Stuff that matters.
Re:Clojure core.async Channels by swannodette on Friday June 28, 2013 @03:27PM (#5959883)
The ClojureScript support needs work but you can already express some incredible things, those familiar with channels in Go should be dropping their jaws that you can do this in the browser:

http://gist.github.com/swannodette/5886048

With timeout channels, the throttler is a beautiful 7 lines of clear code - compare to the Underscore.js imperative mess: http://underscorejs.org/docs/underscore.html#section-64

I've been doing sophisticated JS UIs for 8 years now and had largely given up on ever being able to really manage async complexity - neither JavaScript Promises nor ES6 generators provide this level of process coordination and clarity.

Very exciting times.

EDIT: Oh and don't forget you can pattern match on the result of a select (alt!) with core.match to get Erlang style matching http://github.com/clojure/core.match :) All this from libraries

Re:Clojure core.async Channels by adambard on Friday June 28, 2013 @03:34PM (#5959913)
This has me super excited to build something cool with ClojureScript in the near future. I'm used to using lamina (https://github.com/ztellman/lamina) in Clojure, but for working with the browser this is a whole new world.
Re:Clojure core.async Channels by jamii on Friday June 28, 2013 @03:45PM (#5959975)
I would be interested in seeing a comparison to lamina. I haven't had a chance yet to think about it properly but my first impression is that core.async is strictly more expressive but it couldn't implement something like lamina's flow diagrams.
Re:Clojure core.async Channels by prospero on Friday June 28, 2013 @04:47PM (#5960269)
CSP is message-oriented, Lamina is more stream-oriented. One implication of this is that in Lamina multiple threads can traverse the stream topology without any contention, but in core.async this isn't possible. Another is that the topology is explicitly described in Lamina, but it's implicit in core.async.

That being said, I'm not clear if any of these differences are important to most people's use cases. I suspect that Lamina channels can behave like a core.async channel without much trouble, so it wouldn't bother me much if core.async became the primary interface for these sorts of things. If someone cares a lot about throughput or other distinguishing factors, they can just look under the covers.

I am, however, a little curious how well the goroutine mechanism works in terms of being able to sample the state of the various tasks. Without some equivalent for "jstack", they become something of a black box.

Re:Clojure core.async Channels by puredanger on Friday June 28, 2013 @04:24PM (#5960160)
Do you mean in constructing networks or visualizing them? I see no reason why you couldn't do either with core.async.
Re:Clojure core.async Channels by prospero on Friday June 28, 2013 @04:29PM (#5960191)
Can you walk the chain of consumers and where they're forwarding the messages? I didn't see anything like that in the code, but you're far more familiar with it than I am.
Re:Clojure core.async Channels by puredanger on Friday June 28, 2013 @04:34PM (#5960218)
No, that's not there. I just mean conceptually there is no reason we won't have those kinds of debugging, visualization, etc tools eventually. This is a work in progress. Zach has done a phenomenal job with that stuff in Lamina.
Re:Clojure core.async Channels by prospero on Friday June 28, 2013 @04:52PM (#5960289)
It seems to me that there are real obstacles to that; since the propagation of messages from one channel to another requires a separate 'take' and 'put', there's some halting problem-style obstacles to figuring out the causality of how messages are propagated.

You can maybe create propagation operators that make these relationships explicit, but that would require either eschewing the bare take/put methods, or making sure the take/put behavior is in sync with whatever metadata you use to describe it.

Re:Clojure core.async Channels by jamii on Friday June 28, 2013 @07:41PM (#5960911)
That's the kind of thing I was thinking about. The topology in lamina is described by data whereas in core.async it's described by code. I'll have to experiment more with both and see where the tradeoffs lie.
Re:Clojure core.async Channels by puredanger on Saturday June 29, 2013 @08:12AM (#5962156)
It seems possible to me to build the lamina style topologies on top of core.async.
Re:Clojure core.async Channels by snprbob86 on Saturday June 29, 2013 @04:47PM (#5963686)
In fact, that seems preferable to me.
Re:Clojure core.async Channels by swannodette on Friday June 28, 2013 @09:23PM (#5961189)
I've made a debounce example and compare to an Angular.js promises encoding: http://gist.github.com/swannodette/5888989
Re:Clojure core.async Channels by bkirkbri on Friday June 28, 2013 @04:33PM (#5960212)
Using core.match with core.async does sound promising! Am I correct that Erlang-style selective receive would NOT be possible?

I don't see this as much of a downside though, considering the issues one can have with selective receives.

Re:Clojure core.async Channels by swannodette on Friday June 28, 2013 @05:11PM (#5960364)
Yes I'm pretty sure selective receive is not supported.
Re:Clojure core.async Channels by pron on Friday June 28, 2013 @06:12PM (#5960584)
Re:Clojure core.async Channels by snprbob86 on Saturday June 29, 2013 @04:51PM (#5963694)
You can mimic selective receive using a router process. Essentially, you could generate one channel for every branch of the pattern match, then generate a process which reads from the input channel and deals the message to the appropriate branching channel.