Your SlideShare is downloading. ×
ITCamp 2012 - Raffaele Rialdi - Introduction to WinRT
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

ITCamp 2012 - Raffaele Rialdi - Introduction to WinRT

769
views

Published on

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
769
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
20
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Introduction to Windows Runtime (WinRT) Raffaele Rialdi @raffaeler raffaeler@vevy.com http://www.iamraf.net@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 2. Mobile &ITCamp 2012 sponsors Development@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 3. Mobile &Agenda Development• You already heard about – «Tailored User eXperience» • Inspiring confidence, Fast and fluid, Touch-first, Immersive, Engaging and Alive, Connected – Why current applications does not fit the new market• We will dig into: – What is the Windows Runtime (WinRT) – Why Win8 is not a simple UI restyling – What are the pillars (from a developer point of view) – How can you get it to the max@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 4. Mobile &OO vs not-OO Development• Procedural languages have no implicit lifetime concept – malloc free, CreateFile  CloseHandle, …• In .NET, Dispose pattern is a partial solution – Its not automatic – Can lead to resources leak• Requires PInvoke for accessing C-Libraries• Communication between processes is done via IPC and not between components@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 5. Mobile &Windows Runtime Architecture Development Metro apps Desktop apps Win MFC XAML DirectX HTML WPF SL form HTML DX Language Projections .NET / Js / C++ .NET / Js / C++ Filtered access BCL / libraries to WinRT Windows Runtime APIs and Services UI Controls Storage Media Win32 Windows Win32 Metadata XAML Pickers Network … Runtime Broker Windows Runtime Core Windows Kernel Services@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 6. Mobile &What is the Windows Runtime Development• Its the evolution of Component Object Model (COM) – Easier – Totally different Type System – Same metadata of the .NET Fx (ECMA-335) • WinRT and CLR talks the same "language" • No marshalling gotchas• Its not a replacement for the CLR• CLR is required for managed languages infrastructure@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 7. Mobile &Reference Count VS Garbage Collector Development Root Root A B A B Parent Parent Parent • Circular references • GC finds can find them as it freeze the app and search the roots • Reference Count is autonomous and it cant • In the new C++11 standard we have weak references@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 8. Mobile &WinRT Type System Development• Basic types - bool, integers, floats, enum, guid, type, object• Strings - binary compatibile with .NET (string) and C++ STL (wstring) - are immutable - are value-types (non-nullable)• There are Reference Types - All types that implement WinRT interfaces• There are Value Types - All the others … for example arrays and structures - Structures cant declare reference (deep/shallow copy problem)• "Complex" types - Vector (collection) and Map (dictionary) - Vector<T> implements IObservableVector<T> that is mapped to INotifyCollectionChanged@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 9. Mobile &Language Projections Development•Projections map WinRT types to the projected language• Different casing standards - Javascript (camelCase), C++ and .NET (PascalCase)• Developers need to understand edge-cases - Javascript standard only support IEEE-754 (floats). This means the max integer is 53 bit maximum• Few types are defined both in WinRT and .NET - They are treated as special and seen as equivalent - INotifyPropertyChanged, INotifyCollectionChanged, …• Some .NET types cannot be mapped transparently - Streams, Buffers, Tasks are mapped via extension methods• I expect third party projections too - Java?, Python?, D language?, Delphi?, …@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 10. Mobile &Application Activation Development Explorer.exe Activate RPCSS Activation System Application.exe DCOM Class Launch Catalog@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 11. Mobile &Contracts : «XXI centurys clipboard» Development• A standard way to "talk" to other Apps or OS services • A sort of publisher / subscriber pattern• Main Contracts available: • Search, Share, Protocol, PlayTo, App to App picking• WinRT activate Apps that expose Contracts • Running Apps is done via Launch Contract • Tiles are NOT shortcuts!• Apps use the Manifest to opt-in for Contracts • They receive parameters in the activation method@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 12. Mobile &Asynchronous by design DevelopmentProblem: Apps should never block UI threadSolution: API that may take more than 50ms are only async• Special objects wraps Asynchronous Operations• In WinRT they implement IAsyncOperation<T> • AsTask extension method is used to convert it to a Task<T>• In .NET these objects are Task<T> • AsAsyncOperation extension method to obtain an IAsyncOperation<T>• C# 5.0 have new async/await keywords• Javascript and C++ can use "promises" pattern@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 13. Mobile &Application lifecycle Development Process Suspend App in Process Low App is Active in Suspended Memory is state state Activated (system) closed Resume • Suspension happens after ~5s the App is not visible • Suspension message is used to save App state • Resume happens when user switch to the App • Typically used to refresh data from sensors, WS, … •There is no notification for the close transition • App state is already saved during suspension@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 14. Mobile &The sandbox Development Application Package Application code Manifest Marketplace Security Broker Proxy WinRT Libraries Win32 White-listed Windows Kernel Services@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 15. Mobile &Developing with WinRT Development• XAML UI for .NET and C++• XAML / DirectX can share surfaces • DirectX inside a XAML control • Large virtual DirectX surface in conjunction with XAML • High Performance DirectX drawing, XAML overlapped• Custom WinRT components are easy to write • i.e. exposing C# or C++ code to Javascript or vice-versa • Custom components are private to the App (no RegSvr32)• Cross language calls are cheap • No more P-Invokes! • As fast as a vtable call • Desktop Apps can use a WinRT APIs subset• CLR have an additional weapon: "Portable Class Library" • A DLL with code that run on Metro, desktop, SL, … • As its IL code, it runs as 32 or 64 bits as well@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 16. Mobile &Metro profile for .NET development Development Metro profile was a good opportunity to clean BCL • Removed: Xml DOM, WebClient, Threads, … • Moved Reflection in System.Reflection • GetTypeInfo extension method to access reflection classes Metro Fx 4.5 WP7 # assemblies 15 120 22 # namespaces 60 400 88 # types ~1000 ~14000 ~2000 # members ~10000 ~110000 ~14000 • What else is not in the Metro profile? • APIs that are already in WinRT (Storage, Sockets, Network, etc.) • Server libraries like WCF, Asp.net, … • APIs that could bypass the sandbox • System.Data, Remoting, AppDomain, Private Reflection, …@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 17. Mobile &Developer thoughts Development• No need to elevate (UAC) a Metro App • Admin Apps will run in the old desktop• Storage • Apps can access only locations specified by manifest • Users can pick (via UI) a file that is stored elsewhere • No local db APIs at the moment• Media and Sensors • Easy access to cameras, accelerometer, … • Require user consent (requested via manifest)• Network • Great library to ease oAuth authentication • Flexible HttpClient replace WebClient • Websockets support• Dig into the APIs and discover it by yourself!@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 18. Mobile &Takeaways Development• WinRT is a great step in Windows evolution • Exposes native OS services in a pure OOP way • Closes the gap between managed and native languages• Developers can use their current knowledge to create Apps from small devices to classic PCs• Marketplace is an opportunity for developers and a sweet experience for end-users• Think about performance/battery issues• Its Framework.NET best friend@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 19. Mobile &Tools for WinRT Development• WinRT.codeplex.com• Debug Activation, WRL project template, ... (more to come)@ itcampro # itcamp12 Premium conference on Microsoft technologies
  • 20. Q&A@ itcampro # itcamp12 Premium conference on Microsoft technologies