What’s Next for .NET Developers
An introduction to Windows 8Windows RuntimeMetro.NET 4.5C# 5Visual Studio 11
Ivan Towlson, Mindscape
Windows Evolution
1.0
Real modeRudimentary shell
3.0
386 modeGraphical shell
95
32-bitVirtual memory
Pre-emptive multitaskingExplorer shell (Start)
NT 4NT
XP
Unified enterprise and consumer
platforms
Windows Today
• Dominant operating system on traditional PCs• User experience tailored to keyboard-mouse-
monitor setup• Technology largely tied to x86/x64, boot from
disk• Fundamentals of user experience largely
unchanged since Windows 95
Market Challenges
• Shifting away from traditional PCs towards consumer devices– Smartphones– ‘Fondleslab’ tablets– Media devices (audio/video, portable/home
entertainment)– Game consoles
• Microsoft needs to compete in these markets
Design Challenges – Traditional Desktop
• Users need to be able to manage:– Very large number of installed applications– Lots of notifications (e.g. social media) – don’t
want to have to keep opening lots of applications to check or catch up on different things
• Sharing silo-ed data (in apps and services)– Most of ‘My Pictures’ may be on Facebook!
• Application distribution
Design Challenges – Devices
• Start menu is fiddly to navigate with touch• Window management is fiddly, and in most
cases is useless overhead• Battery life needs to be better• Boot time needs to be near instant• Buying an app needs to be low friction• Keep multiple devices (including a PC) in sync• It needs to look awesome (and harmonious)
Introducing Windows 8
• A new shell• A new set of UI standards• A new application model• A new set of APIs– Rich visual design– Asynchrony everywhere– Multiple language support
• ARM support and diskless boot support• A new set of cloud services
Introducing Visual Studio 11
• Compiler support for Windows Runtime• Designer support for Metro• Language changes for C#, F# and Visual Basic– C# and VB: async– F#: type providers
Introducing the Windows 8 Drinking Game
• “Fast and fluid” – CHUG• “Re-imagining” – DOWN IN ONE
DO NOT PLAY THIS GAME AT TECHEDIT WILL KILL YOU
Windows Runtime
• A common runtime for Windows applications providing a safe, object-oriented API to a variety of services, accessible from multiple languages
• Cripes! That sounds familiar!
WinRT Architecture
• Internally based on COM, but looks like .NET• Sandboxed• Language ‘projections’• Component-based– Metadata format (.winmd) is very similar to .NET
• Can also be used from native code (C++)• Windows 8 only
Diagram credit: Doug Seven
WinRT Class Library
• Mostly a subset of the .NET basic profile– Not the full profile!– Roughly comparable to Silverlight (plus classes for
Win8 and local machine features)– C#/VB still target 4.5 CLR, but compiler restricts
you to APIs in the Metro profile (a la Client Profile)• Some .NET features unavailable or moved– Language projections take care of some changes– Many things now in Windows.* namespaces
WinRT Class Library
• Potentially long-running APIs (e.g. file, network) are only available in async form– E.g. no HttpClient.Get, only HttpClient.BeginGet– C# and VB await keyword works with WinRT
IAsyncOperation as well as CLR tasks
WinRT Application Model
• XAML-based user interface– Very similar to Silverlight– Styles and templates– Data binding
WinRT Application Model
• Capabilities specified in manifest– Services the application wants to consume– E.g. location, camera
• Declarations specified in manifest– Services the application offers– E.g. file type association, search provider
• Contracts which applications can consume or implement (e.g. search, share, picker)
WinRT Application Model
• OS suspends application when not active– Notifications via live tile
• Non-Metro apps run on Desktop as before– The desktop is effectively just a (special) app!
.NET 4.5
• Updates to the .NET 4.0 CLR– Not side-by-side
• Windows 8 support– Framework does not require Windows 8 though
• New versions of C#, VB and F#• Many enhancements to high-level libraries– ASP.NET, WPF, WCF, WF, MEF, ADO.NET
http://www.heikniemi.net/hardcoded/2011/10/whats-new-in-net-framework-4-5-poster/
.NET 4.5 Class Library – Selected Highlights
• BCL: async APIs using Task objects• ASP.NET: HTML5 forms, model binders in Web
Forms, minification, AntiXSS, lots more!• ADO.NET: Entity Framework enhancements• WPF: ribbon control, async validation,
multithreaded collection updates, perf!• WCF: Web Sockets, simplification!• WF: state machines, C# expressions,
versioning enhancements, designer
Languages
• C# 5• Visual Basic… er… lost count… 11?• Visual C++ 11• F# 3
C# and Visual Basic Async
• Long running operations present a dilemma• Synchronous:– Pro: Clear top-to-bottom program flow– Con: Locks up UI (and blocks other operations)
• Asynchronous:– Pro: Fast and fluid (CHUG!)– Con: Splits program flow, especially if you have a
sequence of async operations• Solution: use F#
C# and Visual Basic Async
• async method modifier means method might not complete synchronously
• Within an async method, use await keyword to call an asynchronous method and wait for its completion without blocking
• In an async method, you can write your code in a top-to-bottom way and the compiler will transform it into ‘callback style’
F# 3.0
• We doan’ need no steenkin’ async– Because we’ve had that stuff and more for ages– Wake me up when C# has async agents
• LINQ operators– Okay, I admit it, that one, C# got there first
• Type providers
Visual C++ 11
• C++/CLI-like syntax that compiles to native (COM) code targeting WinRT– WinRT constructs like lists mapped to C++ STL
• Lots of other C++1x goodness including lambdas which is outside the scope of this talk – see Herb Sutter’s Build sessions for details
Building Great Metro-Style Applications
• Metro style design• Fast and fluid (CHUG!)• Snap and scale beautifully• Use the right Contracts• Invest in a great Tile• Feel connected and alive• Roam to the cloud• Embrace Metro principles
Metro Style Design
• The silhouette of a Metro style app– Standard layouts, type sizes, etc. (as in VS
templates) – harmonious across applications• Content before chrome• The edge• Comfort and touch – how people hold devices
Metro Style Design – Silhouette
Metro Style Design – Silhouette
Metro Style Design – Content Before Chrome
Metro Style Design – Content Before Chrome
Metro Style Design – The Edge
• Left and right edges are for system UI• Top and bottom edges are for
application UI
Metro Style Design – Comfort and Touch
Building Great Metro-Style Applications
• Metro style design• Fast and fluid• Snap and scale beautifully• Use the right Contracts• Invest in a great Tile• Feel connected and alive• Roam to the cloud• Embrace Metro principles
Live Tiles
• Windows.UI.Notifications defines the available tile templates– E.g. plain text, text above picture, etc.
• Live tiles can show application data while application is not running– E.g. unread message count, stock ticker– Your back end service sends notifications to
Windows Push Notification Service (WNS)– WNS notifies the Windows 8 client
Building Great Metro-Style Applications
• Metro style design• Fast and fluid• Snap and scale beautifully• Use the right Contracts• Invest in a great Tile• Feel connected and alive• Roam to the cloud• Embrace Metro principles
Learn More
• Watch the videos from the Build conference– Jensen Harris (Big Picture)– Chris Sells (Big Picture)– Anders Hejlsberg (C#/VB)
• Follow the ‘Building Windows 8’ blog– http://blogs.msdn.com/b/b8/
• Download the developer preview– Install to VHD – Hanselman has instructions– VS11 preview for non-Metro will install on Win7
Thanks!
• Windows 8– http://www.buildwindows.com/– http://blogs.msdn.com/b/b8/
• Me– http://hestia.typepad.com/flatlander/– http://www.mindscapehq.com/– [email protected]– [email protected]