Posted By: Charles | Sep 28th, 2009 @ 8:50 AM | 42,834 Views | 31 Comments
Software Developer extraordinaire and language compiler geek Wes Dyer and programming language design guru and LINQ co-creator Erik Meijer dig into the Reactive Framework (Rx). This is part 2 of 2. See part 1 here.

Here, Erik and Wes continue their discussion on the core ideas behind Rx. Rx is deep (as in profound), as you must have gathered by now. Erik, of course, continues to keep the theoretical basis of all this squarely front and center so we understand the relationship between principles and practice.

Enjoy!
Rating:
7
0
exoteric
exoteric
embarassingly sequential

Still watching but I must say already that the IO<IO<T>> has something extremely satisfying about it. Very simple (well, superficially so).

Let's be honest, wouldn't you just love to be in the room during one of these white board sessions! I know envys not a good thing per say - but you folks who get to work along side Erik et al... Wow.

staceyw
staceyw
Before C# there was darkness...

Thanks much C, Erik, and Wes.  Another great 2 part.  Naturally, I am thinking away about how you might bring this into ADO.Net Data Services (et al).  Say I wanted to get notified each time someone does an update or delete on specific condition, etc.  I can see how you may do this on the service end inside a method, but am wondering about the comm channel.  Because of firewalls and the http request/reply pattern, you still end up with essentially a client-side pull model instead of a pure push model.  Maybe that is just something we have to live with in a distributed environment.  That said, any ideas on this subject?  You can abstract the server side Push by having some kind of timer on the client side that pulls stuff down from a server's observable queue.   However, things like background timer tasks and what is the correct amount of time between pulls, message ordering starts to get messy.  Any new ideas in the network side of this Beauty? It is really cool to find the ONE.  Because now you can standardize on this for all async Push - Sql Notifications based on Linq queries, Ado.Net Data Services notifications, all .Net services, Windows Services, devices, .Net MicroFramework, .Net POS, etc.    Great work. 

staceyw
staceyw
Before C# there was darkness...

Second question.  Do you think there will be a way to remote the observer query to the server, so the server processes any Where clause to reduce unneeded traffic on the wire?  Example, send me X where Y <= 2 || Y >1000

Well I think there would be some restrictions (on types that can be used and method calls), that could be passed to the server.  But look at what ..net ria services, what it does is it takes the IQueryable expression tree and serializes it directly and sends it off to the server.  IQueryable is just expression trees that havnt been compiled into a function that returns an IEnumerable yet.  I am sure they could have a simlar thing in IObservable that would have interfaces like  IRequestable Select<source,result>(this IRequestable , Expression<Func<source,result>> ).  I dont know quite what they would call it though.  IQueryable unforchantly derives from IEnumerable, but otherwise it would be identical in its signatures.  IQueryable assumes that something is going to serialize it to pass it to something else for proccessing.  In the case of observables you would be assuming something is going to serialize it to do the proccessing (filtering or other proccessing) remotely.  Maybe something like you can pass it up to the server and have it tell you when some specific row of a database table changes, or off to active directory to let you know when some user gets locked out.  All the server does is provide you with access to everything you have access to as one giant IObservable, and then the client can select (and filter) the type of events it wishes to listen to, and only those are sent down.

 

Also intresting to think about this in terms of a UI framework.  Where the framework itself has one giant IObserable which sends a new value every time the mouses moves or keyboard is pressed, and it hands off to all its children .Where(...) verions of the giant IObserable that filter for just its selected area of the screen or currently selected child (which then wraps its children in another .Where).  In the end you dont need to even test do any hitbox testing or anything, everything just flows down stream.  I spose most UI frameworks like WPF already do this with thier visual tree's just invoking methods on a child of a known type (like UIElement), but when you look at the 100's of On... overrideable method calls, you got to wonder if filtering only what you need might be a better option.  Where they dont have to keep extending the base class to add additional method calls, and instead add new derived event types that return more specific infromation if you want that extra info.  Or say your a team like Microsoft Surface that has some specific type of "new" interaction events you want to pass to your children based on specific proprietary hardware.  In the current WPF, this is very hard/impossible (I think they derived thier own UIElement type and force all thier children had to derive from that to get the new events).

exoteric
exoteric
embarassingly sequential

Charles, do you think it possible to get perhaps a type proliferation overview, maybe in interview format, talking about where you plan to retrofit these types as well as possibly in what order. I imagine this will be a big undertaking as it basically amounts to every single instance of where you have an event today.

 

I wonder if it wouldn't make sense to systematically and automatically retrofit all of .Net with these types, that is, using some naming convention, simply inject one IObservable property for every event. If I remember correctly, you're just using an event and holding a subscriber delegate to the event and on dispose you just remove the same delegate. So it should be a mechanical process to retrofit. This way we can also have this retrofitted to good old WF.

 

Also, it would seem like this would have some interesting deeper implications for concurrency and coordination if we have parallel events going on and we coordinate them with these query combinators, hmm...

My guess unfortunately is they aren’t going to retrofit anything, at least initially.  We would be lucky to get the IObservable interface in the BCL (and not just as an extension), although this might happen in .NET 4.0.  If they actually went converted events to be IObservable’s they would break everyones code that depended on those events.  Even if they rewrote the compiler somehow so the event keyword now MEANS IObservable, a lot of code would break (think of the IL changes on a different language).  Ah well, the good thing is that at least all events can easily be converted into IObservable’s.

exoteric
exoteric
embarassingly sequential

No no no, you misread - or I used the word retrofit wrongly. The idea is to *add* an IObservable property to all classes where there is already an event. This would bring the meaning of Reactive Extensions to a whole new level, meaning Reactive Extensions *everywhere*.

 

Charles: Maybe you should just rename the posts to Reactive Extensions for .Net: ...... to defuse confusion. Or I should just get to work now heh...

Microsoft Communities