Hacker News new | past | comments | ask | show | jobs | submit login

Task<T>/async is a slightly different beast, effectively its a goroutine+channel which can only return 1 value or throw an exception.

A better alternative to channels is Rx (Reactive Extensions) which gives you IObservable<T>. It's very simple and powerful. Observables can be composed using Linq, and they're monadic (if that matters). I like the first class notion that something can fail or be completed (go has close(), which lets you complete a channel, but there is no notion of errors unless you slap a tuple in there).

Rx is available on many platforms (incl JVM, JS).

Rx.NET does not yet support back pressure (Rx 3.0 will, whenever Microsoft release that, maybe at //build). There's an alternative library from Microsoft called Dataflow, though, and Dataflow does support backpressure as well as a lot of other great features. Dataflow is underused, but its great. Rx & dataflow interoperate very easily (.ToObservable() etc)

There are a bunch of videos from Netflix on their use of Rx, which are a good watch if you're interested.

Edit: Channels in Go don't compose: I can't easily take one channel, mutate the values as they arrive, and create another channel from the mutated values. With Rx, that's just `var uppers = keyPresses.Select(key => key.ToUpper())` and now I've got a new stream of data. If keyPresses completes, so does uppers. If it fails, that failure is propagated through uppers. This isn't easy in Go.

goroutines don't have any reasonable kind of monitoring. I can't say "this routine has completed/failed", I have to implement that notion every single time using a WaitGroup or something, and that only handles completion, not failure.

I'm not saying C# is perfect and that go's channels/goroutines don't have any merit, just that there are some things I wish I could do more easily using them.




What is the bind semantic in rx?


For a FRP RX user interface example check out the front page of http://www.reactiveui.net/ (or scroll up a bit where I posted the viewmodel code).

For example of a RX backend API check out https://github.com/AdaptiveConsulting/ReactiveTrader




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: