1 / 36

The Windows Runtime

The Windows Runtime. Martyn Lovell Development Manager Windows Runtime Experience Microsoft Corporation. Agenda. What is the Windows Runtime? The Windows Runtime Contract Projecting into Languages Call to Action. What is the Windows Runtime?. The Windows 8 Developer Experience.

reneeg
Télécharger la présentation

The Windows Runtime

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Windows Runtime Martyn Lovell Development ManagerWindows Runtime Experience Microsoft Corporation

  2. Agenda • What is the Windows Runtime? • The Windows Runtime Contract • Projecting into Languages • Call to Action

  3. What is the Windows Runtime?

  4. The Windows 8 Developer Experience The Windows Runtime is the solid, efficient foundation for building great Metro style apps • Easy to build a Metro style app • Dramatic improvements in developer experience • Freedom of choice – language, library, markup • Enabing a new generation of fast, fluid, responsive apps

  5. Major improvement to developer experience Great intellisense& tooling Native, Managed, Dynamic all first-class citizens JavaScript, C#/VB and C++ initial targets Platform based Versioning Apps keep running on future Windows versions Simple low-level constructs; usability in projection Responsive and Fluid Apps Async APIs where they are needed Well-designed, consistent objects API surface is clear and consistent Design Principles

  6. Metro style application APIs User Interface HTML5/CSS XAML DirectX Controls Data Binding SVG Tiles Input Accessibility Printing Devices Communications & Data Web Contracts Geolocation Portable Sensors NFC Local & Cloud Storage Streams Notifications Media SMS Background Transfer XML Networking Visual Effects Playback Capture PlayTo Fundamentals Application Services Threading/Timers Memory Management Authentication Cryptography Globalization

  7. Windows Runtime Architecture Windows 8 “Metro style” app Language Support (CLR, WinJS, CRT) Language Projection (Generated from Metadata) Web Host (HTML, CSS, JavaScript)) Windows Metadata & Namespace UI Pickers Controls Media XAML Storage Network … Windows Runtime Core Runtime Broker Windows Core

  8. The Windows Runtime Contract

  9. What is a Windows Runtime Object? Shell32.dll IInspectable IUnknown IStorageItemInformation Object IStorageItem FileInformation Runtime Class IStorageFile Interfaces Windows Metadata (Disk) Activation Store

  10. Windows Runtime Basic Types

  11. Windows Runtime Patterns

  12. Collections IInspectable IUnknown IVector<T> Array IVectorView<T> IObservableVector<T> IInspectable IUnknown IMap<T> Associative Collection IMapView<T> IObservableMap<T>

  13. Windows Metadata • Concise, complete description of the Windows Runtime • Full description of Windows ships in SDK and on system • Use to describe your objects • Generated natively from C++ or C#/VB Compiler • Efficient binary format derived CLI Metadata • Profile of ECMA 335, Partition II • Same structures, different meanings • Readable by existing tools • Rich enough to allow multi-language projection generation • Full intellisense on statically known information

  14. Versioning IInspectable IInspectable IUnknown IUnknown Future Windows Windows 8 Object Object Windows Metadata v8 App Windows Metadata v9 App Projection Projection

  15. Asynchronous Objects • Basic requirement for Metro style apps • Always responsive, ready • “Long running” APIs must be delivered as async • Simpler to allow apps to make synchronous calls • But then bad apps can overwhelm quality of system • Instead, build async into API shape • And have language projections integrate it deeply • Async protocol is low-level • Language projection provides simplified high level view

  16. Threading App Threadpool Main UI Thread Windows UI Object Windows Object Windows Object App Code App Code App Code

  17. Three main types of object Thread bound – works only on the thread where it was created – most UI Thread flexible – direct call and works on any thread, uses locking if needed to control simultaneous access – most others Brokered – out of process for resource protection UI runs in single threaded environment that is not reentrant (“Application STA”) Callbacks can only enter if they are related to an outgoing call Most non-UI runs in any thread Windows Runtime Threading

  18. The Windows Namespace • Windows.* Runtime objects are in a simple, unified, hierarchical namespace • Great intellisense and browsing in Visual Studio • One Clear type for each function • Catalogis extensible but private • Your apps can add objects • Only visible in your app • Objects can be seen from any language

  19. Projecting into Languages

  20. Projections C++ App Projection IInspectable IUnknown Object C#/VB App CLR Projection HTML App JS Chakra Projection Windows Metadata

  21. Projections • Projections make Windows Runtime APIs natural and familiar in every language. • Automatically generated at compile/run time • Ensures you don’t wait for language/framework to catch up • Windows exposes simple concepts – interfaces, functions • Metadata shows how they compose • Patterns allow projections to adapt • Examples: classes, events, delegates, async and collections • Each language expresses patterns differently • Uses styles that are natural and familiar to their developers

  22. Language Integration • Will the Windows Runtime be at home in each language? • Yes, but never perfectly • Many aspects can adapt well • object creation • collections • Naming typography(pascal vs.. camel vs. lower) • Return value usage

  23. Language Integration • Some other aspects must match function • Parameter ordering • Concept naming (e.g. file vs. item) • Great interop with language types possible • Depends on work from language teams • Some overlap/duplication inevitable • Some language semantics are more foreign • We have side-effects, so functional language integration less natural • Overlap with standard libraries inevitable • Projection can reduce (e.g. System::String vs HSTRING) • Some will remain (e.g. XML)

  24. Designing your projection • Map type systems • 2 Way mapping for basic types • Carefully consider round-trip typing • Map patterns and abstractions • Ensure your users collections can be passed to Windows • Fit delegates/events into your call-back model • Integrate threading and async • Project async in simple way • Consider promise/future approach • Critical step to get this right

  25. Designing your projection • Harmonize object lifetime • Windows Runtime objects deterministic • Consider proxy object approach for GC languages • Like CLR’s RCW/CCW. • Take account of ICloseable semantics. • Plan shutdown carefully • Consider versioning • Windows Runtime versions like the operating system • Binary compatible • Additive • Users need to tell compiler/projection what version of platform they are targeting

  26. Implementing your Projection • Handle Errors • Windows Runtime is HRESULT error code based • Expected to map to exceptions in most languages • Read and write Metadata • Must Use our APIs to read metadata • We will reorganise on-disk naming and structure • Only way to correctly find all metadata for a type • Ensure your written metadata is conformant • Bind to types • Use type resolution APIs to load metadata

  27. Implementing Your Projection • Adjust Standard Library • Can only use Metro style APIs – e.g. No Console! • Obscure types with natural analogues • Don’t expose a Windows type with a tight mapping to a language type • E.g. hideWinRT’sstring, int32 • Do expose if there are important semantic differences. • Ensure efficient behaviour at projection boundary • Don’t copy strings (pass by ref – we allow) • Don’t copy collections

  28. Windows Runtime in JavaScript • function peerFinder_AcceptRequest() { • // Accept the connection if the user clicks okay. • ProximityHelpers.displayStatus("Connecting to " + requestingPeer.displayName + " ..."); • ProximityHelpers.id("peerFinder_AcceptRequest").style.display = "none"; • ProxNS.PeerFinder.connectAsync(requestingPeer).then( • function (proximitySocket) { • ProximityHelpers.displayStatus("Connect to " + requestingPeer.displayName + " succeeded"); • startSendReceive(proximitySocket); • }, • function (err) { • ProximityHelpers.displayError("Connect to " + requestingPeer.displayName + " failed with " + err); • ProximityHelpers.id("peerFinder_Connect").style.display = "none"; • }); • }

  29. Windows Runtime in C# • async privatevoid PeerFinder_Accept(object sender, RoutedEventArgs e) • { • rootPage.NotifyUser("", NotifyType.ErrorMessage); • rootPage.NotifyUser("Connecting to " + _requestingPeer.DisplayName + "....", NotifyType.StatusMessage); • PeerFinder_AcceptButton.Visibility = Visibility.Collapsed; • try • { • _socket = await PeerFinder.ConnectAsync(_requestingPeer); • rootPage.NotifyUser("Connection succeeded", NotifyType.StatusMessage); • PeerFinder_StartSendReceive(); • } • catch (Exception err) • { • rootPage.NotifyUser("Connection to " + _requestingPeer.DisplayName + " failed: " + err.Message, NotifyType.ErrorMessage); • } • }

  30. Windows Runtime in C++ • void PeerFinderScenario::PeerFinder_Accept(Object^ sender, RoutedEventArgs^ e) { • m_rootPage->NotifyUser("", NotifyType::ErrorMessage); • m_rootPage->NotifyUser("Connecting to " + m_requestingPeer->DisplayName + "....", NotifyType::StatusMessage); • PeerFinder_AcceptButton->Visibility = Visibility::Collapsed; • auto op = PeerFinder::ConnectAsync(m_requestingPeer); • Concurrency::task<StreamSocket^> connectTask(op); • connectTask.then([this](Concurrency::task<StreamSocket^> resultTask) { • try { • m_socket = resultTask.get(); • m_rootPage->NotifyUser("Connection succeeded", NotifyType::StatusMessage); • PeerFinder_StartSendReceive(); • } • catch(Exception^ e) { • m_rootPage->NotifyUser("Connection to " + m_requestingPeer->DisplayName + " failed: " + e->Message, NotifyType::ErrorMessage); • } • }); • }

  31. Call to Action • The Windows Runtime is the solid, efficient foundation for the new Windows 8 developer platform • Build Metro style apps easily with the Windows Runtime • Windows available in your choice of language and environment • Bring your language to the Windows runtime • Create a language projection • Make Windows a natural and familiar part of your world • We can engage and help

  32. Q&A • http://msdn.microsoft.com/windows • Email:martynl@microsoft.com • Windows 8: http://channel9.msdn.com/Events/BUILD/BUILD2011/KEY-0001 • Platform: http://channel9.msdn.com/Events/BUILD/BUILD2011/BPS-1005 • Windows Runtime: http://channel9.msdn.com/Events/BUILD/BUILD2011/PLAT-874T • Internals: http://channel9.msdn.com/Events/BUILD/BUILD2011/PLAT-875T

  33. Backup

  34. Windows 8 Metro style Apps Desktop Apps HTML JavaScript HTML / CSS XAML View JavaScript (Chakra) C/C++ C#, VB Model Controller C C++ C# VB WinRT APIs Devices & Printing Communication & Data Graphics & Media System Services .NET SL Internet Explorer Win32 Application Model Windows Core OS Services Core

  35. Object Creation

  36. Brokered Objects RuntimeBroker.exe App Proxy Projection IInspectable IUnknown Object

More Related