.NET 4 Revealed
The next-generation .NET Framework 4 and Visual Studio 2010 beta 1 bits reached developers' workstations last month, after a seven-month hiatus. The ﬁrst -- and in some cases, only -- community technology previews (CTPs) appeared last October at Microsoft's Professional Developers Conference (PDC).
The updated framework promises maturing class libraries and new parallelism capabilities to facilitate the development of components that can take advantage of the intensive I/O capabilities of multi-core systems.
"With 4, I see less new things and more of an extension in terms of beefing up what's there-the Windows Communication Foundation, Windows Presentation Foundation, Workflow services," says Mark Driver, vice president of research at Gartner Inc. "I don't see a whole lot of new APIs but rather the evolution of the APIs that they introduced as part of 3.5."
Richard Hale Shaw has spent most of his time looking at the Base Class Libraries (BCL) and Common Language Runtime (CLR), which he describes as the "meat" of the framework. "I think sometimes [Microsoft] teams lose focus on what is it that is going to make a developer more productive that isn't being addressed in the current product and isn't being addressed by cute bells and whistles," says Shaw, CEO of The Richard Hale Shaw Group, a specialist in Microsoft development technologies.
.NET 4 marks the first major upgrade to the CLR since .NET 2.0, which debuted alongside Visual Studio 2005 and SQL Server 2005, and served as the execution environment for .NET 3.0 and .NET 3.5.
18-Month Tool Fest
Last month, Microsoft IT and developer professionals got a closer look at what's coming in .NET 4 beta 1 at Tech-Ed North America 2009 in Los Angeles, where the release candidates of Windows 7 and Windows Server 2008 R2 grabbed center stage. R2 includes the .NET Framework with a "server core" option that supports ASP.NET, IIS 7.5, Remote Management and PowerShell. (.NET 3.5 is the default framework.) Windows Mobile 6.5, the first version to include the new Market Place component, was officially kicked off at Tech-Ed. It ships with .NET 3.5 Compact Framework and SQL Server 3.5 Compact Edition.
The annual confab in May topped off an 18-month tool fest since .NET 3.5 and Visual Studio 2008 shipped in November 2007. During that span, Microsoft has introduced new data access tools-Language Integrated Query (LINQ) and related providers in the .NET 3.5 release and the beleaguered ADO.NET Entity Framework, an object-relational mapping model in .NET 3.5 Service Pack (SP) 1.
At Microsoft PDC in late October, developers were briefed on the upcoming Azure Services Platform for cloud computing and the new Live Framework for Live Services and Live Mesh.
In March, Microsoft continued to shore up its "standards-based" Web platform at its MIX09 Web developer and designer conference. The company showcased what's coming in ASP.NET 4 with improved AJAX, Dynamic Data and better Silverlight integration. The new Model-View-Controller (MVC) framework ASP.NET MVC 1.0 was released. Silverlight 3, which is expected to ship later this year, was announced, along with new .NET RIA Services.
All of these libraries and SDKs are part of the .NET Framework stack, or extensions, that rely on Visual Studio as the underlying tooling. As Microsoft packs it all into .NET, some concerns about the framework's size and performance are being addressed. The .NET 3.5 SP1 introduced a subset of the framework in the .NET Client Profile (28MB), compared to the entire 250MB download. Distribution size is further improved in .NET 4, according to Brian Goldfarb, Microsoft's director of developer and user experience platforms.
Updating the CLR
With .NET 4, Microsoft Group Program Manager Joshua Goodman says that the CLR team has worked hard on solving performance and compatibility issues. The core of the platform encompasses the just-in-time compiler, garbage collection, a security model, exception handling, profiling and debugging APIs, and the BCL.
Developers have run different versions of the framework side by side on the same box since .NET 1.1 was introduced in 2003. The .NET 4 CLR supports processes side by side in the same host, enabling components to use different versions of the CLR in the same application.
"If they can make that happen, I think it would be a big win," says Shaw.
SRT Solution founder Bill Wagner, who writes the Visual Studio Magazine C# Corner column, agrees. "This functionality is really critical for anyone who's doing any development with Office, where you're writing an add-in that gets loaded into another application."
Microsoft's "parallel story" is another critical facet of .NET 4 for both native and managed code developers. Parallel LINQ (PLINQ) is a declarative data programming model for executing queries in parallel. The Task Parallel Library (TPL) in the .NET Framework supports both task-and data-driven parallelism. A Coordination Data Structure manages the shared states.
Developers can expect to see numerous PLINQ, TPL and coordination-data structure updates in the .NET 4 beta; the TPL CTP released at PDC was based on code from July 2008. In beta 1, the default work scheduler for the TPL is now the .NET CLR Thread Pool. The team is also working on an improved algorithm so that the .NET Thread Pool can dynamically optimize the number of threads for a workload.
Shaw, who has looked at the early CTPs, likes what he's seen so far. "I kind of wish there was a little more abstraction in there but it's not bad the way they did it," he says. "My only gripe with the parallel libraries so far-and it's a minor one, because of the way they designed them-[is that] there are fewer opportunities to take advantage of some of the language features like extension methods and things like that. But that may happen if the language teams get their hands on them in a later release," he says.
The Dynamic Language Runtime services (hosting API, dynamic type system, dynamic methods and code generation), currently available on Microsoft's open source project hosting site CodePlex, are also part of the .NET 4 core platform. The DLR, which sits on top of the CLR, will support IronRuby, IronPython 2.0 (which was released in December), the upcoming Visual Basic 10.0 and Managed JScript. Dynamic support has also been added in C# 4.0.
"The one use case that is not played up as much is that you've got the ability to invoke .NET objects dynamically through the DLR and where that becomes a win is if you're currently using .NET objects via reflection," says Shaw.
In addition to Microsoft's implementations of dynamic languages in .NET, the new framework will support functional programming for the first time, specifically F#, which is developed by Microsoft Research.
"F# is going to be a standard language product in this release, which I think over the long haul is going to be a big, big win," says Shaw. "I see it as a great tool for a C# developer who understands it because you can't do functional programming as effectively in C# as you can in F#."
Technology that evolved out of Microsoft Research's Spec# is also making its way into .NET 4. The new Code Contracts in the BCL allow developers "to tell the compiler what they know" according to Microsoft's Goodman, by writing pre-conditions similar to assert.debug, post-conditions for exiting the code and object invariants. Some offline static analysis tools out of MSR are also included.
Yet Another Data Layer
Along with substantial improvements to ASP.NET, Microsoft has updated the ADO.NET framework class libraries. The confusion about which data access technologies to adopt with multiple frameworks and tools driven by different stakeholders within Redmond has left many developers frustrated. Microsoft is making some changes in .NET 4 that may make these choices clearer.
"We're making significant investments in the Entity Framework such that as of .NET 4.0 the Entity Framework will be our recommended data access solution for LINQ to relational scenarios," wrote Tim Mallalieu, Microsoft program manager, LINQ to SQL and Entity Framework (EF), in a blog post last October. "We are listening to customers regarding LINQ to SQL and will continue to evolve the product based on feedback we receive from the community as well."
With .NET 4 beta 1, developers will likely get their first look at EF version 2. According to Microsoft, EFv2 adds support for n-tier APIs and templates, increases Plain Old CLR Objects (POCO) coverage and improves Persistence Ignorance, among other enhancements.
"I don't know that it's pure POCO," says Roger Jennings, principle of OakLeaf Systems and a VSM contributor. "The abstraction may be a little leaky; a little bit of the data table design may still be in the classes."
Change tracking in the client and state changes in n-tier apps will be handled to some extent by developers, according to a November posting by the EF Design team:
"[E]ntity Framework won't impose a pattern for N-Tier. Both DTO-style and DataSet-like experiences can be built on top of a minimal set of building blocks APIs. It is up to the developer to select the pattern that better suits the application."
While some developers may appreciate the flexibility and choice, others see it as more work.
"We want to make the developer experience much less about having to write low-level structures where they have to know the database schema and really to abstract them up to high-level programming that really targets the entities that they're trying to manipulate using the EDM [Entity Data Model]," asserts Burley Kawasaki, director of developer platform product management at Microsoft. "And then we take care of a lot of the lower-level mapping relational data, a lot of the infrastructure code that you would typically write."
Jennings, who uses LINQ to SQL today, is anxious to try out the updated technology. "The feature that will be most useful to me in .NET 4 will be Entity Framework version 2 primarily because I am going to be able to split it into tiers," he says. "Basically what it does is it enables you to run a disconnected Web service. Then you don't need ADO.NET Data Services anymore-you can get rid of that layer."
Connected to the Cloud
Microsoft is also advancing the foundation libraries that debuted in .NET 3.0, designed to help developers build business logic, presentation layers and identity management in .NET 4.
The service-oriented messaging model, Windows Communication Foundation (WCF), is now extended to support cloud services through .NET Services in the Azure Services Platform.
Microsoft is continuing to improve the integration between WCF 4 and Windows Workflow Foundation (WF) 4. "A big piece of what we are doing is making the programming very fluid between WF and WCF," says Kawasaki. "We started a little in 3.5 and you will see in .NET 4 that we take that even further." Developers can now use a consistent declarative model (XAML stack) underneath WF, WCF and Windows Presentation Foundation (WPF).
Much has been made of the rebuilding of WF 4. Feedback on WF indicated that some developers preferred to use configurations or models, says Kawasaki. "So Microsoft is extending the model so that you can do much more declarative programming and trying to limit the cases where you need to write code in defining the workflow."
The team has also focused on making it easier for developers to not have to choose between performance and maintenance. WF 4 is showing 10X improvements in internal benchmarking of the raw executions of workflow, according to Kawasaki, who says it is used in Team Foundation Server for Visual Studio Team System 2010.
Building composite apps that connect Web and data services should get easier as these frameworks and tools advance. WCF 3.5 added support for RESTful services. With EDM and RESTful services, developers can call business data as opposed to writing lower-level SQL statements, in effect tying together datagrids, data services and the EF, according to Kawasaki. A new Windows Web Services API enables native code in apps such as Windows 7 and Windows Server 2008 R2 to interop with WCF.
WPF 4 is perhaps the most critical technology for Microsoft. Visual Studio 2010 will feature a new shell built using WPF 4.
Many developers hope the integration of WPF into Visual Studio is going to have a positive effect on WPF performance and WPF adoption. "It isn't just a flagship app, but a resource-intensive app. [It has] a community of users that's far more concerned about performance than a lot of other things, which means that the WPF integration and the necessary changes to both the IDE and to the framework-[and] the WPF libraries to make those work well-is going to be probably the biggest critical success factor," explains Wagner. "It is going to either help both Visual Studio and WPF or hurt them both."
"With .NET 4, WPF gets 25 to 40 percent faster automatically," says Goldfarb, "just by moving your application forward." WPF 4 will offer multitouch support, better text clarity and pixel snapping, among other enhancements. A new Windows 7 Ribbon Control is subject to the Office Fluent UI License.
Even so, many enterprise developers are frustrated with the lack of basic WPF controls, which requires them to look to third-party options. Microsoft also has no plans to implement an MDI solution at the framework level despite repeated customer requests.
The Managed Extensibility Framework (MEF), currently available on CodePlex, is also part of .NET 4. It's a component system that offers a standard way to build apps with add-ins. The new Visual Studio 2010 shell is built on a subset of WPF and MEF.
New Class of Developer
As Microsoft continues to push .NET into the enterprise, critical technologies such as EF-added specifically to attract that audience-and WPF still appear unfinished in .NET 4.
".NET has made it much more realistic to consider Microsoft for these [higher-end] solutions but here's the problem," says Gartner's Driver. "When I am building an application with a five- to 10-year lifecycle, and that application is truly running my business, I am highly motivated to keep that thing stable-I don't want to rewrite the code every three years because they've introduced some latest and greatest new things.
"Now in the past, Microsoft could have gotten away with that because the average Visual Basic program only lasted three to five years. All of a sudden with .NET, they have a whole new class of developer," he says.
Microsoft's Kawasaki and Goldfarb acknowledge the challenges of trying to offer stability for enterprise developers and at the same time provide agility for developers interested in the latest technologies. "That's why we're putting a lot of focus on interoperability, being able to extend existing apps to run side by side," says Kawasaki. "That's a core tenant of .NET, as well as a lot of incremental enhancements that are very targeted for consumption for [your] type of app."
Driver thinks that over time Microsoft will be forced to keep larger portions of the platform more stable. "I don't think the changes in 4 are enough to warrant a major problem," he says. "It's not like they've thrown things out. They're not reinventing things in the CLR. But I do expect organizations that perhaps would have been much more aggressive in updating to the latest versions to take a more measured approach this time, and perhaps go through a bit more regression testing and those kinds of things."
Shaw also anticipates a slower adoption. "We've already seen resistance from customers migrating up to new frameworks even when there wasn't a new CLR, just new libraries," he says. "Their IT personnel freak out at the idea of new stuff on the box-including developer boxes and server boxes they have to support.
"With VS 2005/.NET 2.0, there was a lot of resistance to moving up to that new CLR," he recalls, "even though in my opinion it was a largely non-obtrusive upgrade and Microsoft did a great job of documenting the 97 or 98 really odd circumstances when that CLR would actually interfere with your system."
.NET 4 is a maturity wave, rather than a wave where Microsoft is introducing a bunch of new framework-level components, says Steven Martin, senior director of developer platform product management at Microsoft.
"When we find that developers are building the same thing over and over again, we think: Is that something we could productize to help them move to the next level in development? We have significant work going on right now to help us understand what some of those new app patterns are," he says.
"Clearly, as we move to a world where we're building applications that are truly composite, that take advantage of services that live in a cloud environment and a premises environment and [are] being authored by developers that are really aggregating services that other developers are creating," says Martin, "we think that that gives us an opportunity to look for additional components that we might offer in the framework and we will have more to talk about there over time."
The final release of .NET 4 and Visual Studio 2010 is likely around PDC2009 in November or early next year. Either way, .NET 4 is expected to have a Go Live license by the end of 2009.
Shaw is anxious to move past the virtual PCs and try out features in the new framework on a regular machine. "I'm hoping they will do that with these betas," he says. "Because otherwise, it kind of delays your ability to find out what happens when the framework meets the metal."