News

.NET Rx Framework: A Watershed Advance in Asynch Programming

This summer Microsoft quietly released the first key components of its .NET Reactive (Rx) Framework, which allows developers to write Language Integrated Query (LINQ) expressions against events. Components of the Rx Framework were included in the latest drop of the Silverlight Toolkit. A complete version is expected to be part of Visual Studio 2010 and will be supported by .NET Framework 4.

According to language designer Erik Meijer, the Rx Framework consists of a pair of interfaces (IObserver/IObservable) that represent "push-based" observable collections, along with a library of extension methods that implement Microsoft's LINQ Standard Query Operators and other stream-transformation functions. Meijer runs the Data Programmability Languages Team at Microsoft, and he outlined the .NET Rx Framework during a session at the recent O'Reilly Open Source Convention (OSCON) in San Jose, Calif. Observable collections capture the essence of the subject/observer design pattern, Meijer said, and are especially useful for dealing with event-based and asynchronous programming.

Meijer and software design engineer Wes Dyer have designed what Meijer described as a major breakthrough in asynchronous programming: "Of all the work I've done in my career so far, this is the most exciting," Meijer told session attendees. "I know it's a bold statement, but I really believe that the problem of asynchronous programming events has been solved."

Veteran .NET developers agree that the Rx Framework is likely to change the way developers deal with asynchronous programming. "This is a completely new way of perceiving event handlers, delegates and asynchronous programming," says Julie Lerman, a .NET mentor and the author of the recently released book "Programming Entity Framework" (O'Reilly Media Inc., 2009). "I'm reacting like most programmers. We're uttering a collective, 'Oh my god.' They just peeled something open and showed us something new that has always been there."

Andrew Brust, chief of new technology at twentysix New York, says the Rx Framework solves the challenges inherent in asynchronous programming, which is the model employed in AJAX, Silverlight, Microsoft's Azure, cloud-based services and multi-core/multi-processor/multi-threaded programming. "It's an important step in making the delicate parts of AJAX, rich Internet applications, and cloud computing less disruptive to line-of-business programmers," Brust says.

"Asynchronous programming is really hard," Lerman notes. "It's hard for programmers to get their heads around it. Microsoft has been trying to find a way to make it more accessible to developers. In the same way that LINQ has made interacting with data objects easier, the Reactive Framework is going to make interacting with events easier. But not only that, it's going to give us a new level of access to working with events."

Microsoft included components of the Rx Framework in the latest version of its Silverlight Toolkit. The biggest chunk is a new assembly called system.reactive.dll, located in the bin folder of the Silverlight Toolkit Unit Tests. Jafar Husain, a software developer who works on Microsoft's Presentation Platform Controls team, has posted bits of sample code on his blog that can be downloaded and run inside Visual Studio 2008 via the Silverlight SDK.

"Just by thinking about events and asynchronous complications as collections, I know I have this very powerful mechanism to glue these things together," Meijer said at OSCON. "Really, I've just sort of rephrased stuff that people have been doing for a long time."

He pointed to the Unix shell as an example. "Unix pipelines are also an observable collection, because each stage of the pipeline pushes the value to the next stage," he said. "The way you glue these things together is by wiring up these data-flow networks." Another example: event-driven state machines in Windows Workflow, which is also a concrete type that implements the Observable interface.

Meijer has been involved in the development of a wide range of languages, including Haskell, Mondrian, X#, Cw, C# and even Visual Basic. He also led development of LINQ, which adds native data-querying capabilities to .NET languages such as C# and VB.

As for .NET Rx Framework, Lerman says it will take some time to understand. "Be patient while you wrap your head around this thing," she suggests. "Once it clicks, it will make perfect sense, and it will change the way you think about event handlers and delegates."

About the Author

John K. Waters is the editor in chief of a number of Converge360.com sites, with a focus on high-end development, AI and future tech. He's been writing about cutting-edge technologies and culture of Silicon Valley for more than two decades, and he's written more than a dozen books. He also co-scripted the documentary film Silicon Valley: A 100 Year Renaissance, which aired on PBS.  He can be reached at [email protected].

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube