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

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube