Jump to content

Windows Runtime

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Hnobley (talk | contribs) at 16:25, 23 September 2011 (→‎Technology: WinRT is built upon Win32. Use dependancy walker to verify this!). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Windows RunTime, or WinRT, is Microsoft's new programming model that makes the backbone of the new Metro experience (also known as Immersive) in their new Windows 8 operating system.

The WinRT application model was designed to make interfacing between languages and platforms easy and seamless.

It consists of an execution interface as well as a collection of APIs that give access to the functionality provided by Windows 8.

WinRT was revealed at the Microsoft BUILD-conference September 12th, 2011.

History

Technology

WinRT is designed to create a completely new programming paradigm that is not encumbered with legacy code. WinRT applications will install in seconds and run within a sandbox. Microsoft claim WinRT is a native runtime system that is implemented directly on the Windows NT-kernel and thus not based on previous platforms. However, examination of the runtime libraries reveal that they actually are built upon Win32 API. This is the same approach used by the .NET.

Services

Metadata

See also .NET metadata

The metadata describes the code written for the WinRT platform. It defines a programming model that makes it possible to write object-oriented that can be shared across programming languages. It also enables services like reflection.

Herb Sutter, C++ expert at Microsoft, told during his session on C++ at the BUILD-conference that the WinRT metadata is .NET metadata.[1]. Native code (processor specific) can not contain metadata and it is then stored in separate WINMD-files that can be reflected just like ordinary .NET assemblies.[2]

Because it is .NET metadata the programmer can then use code written in managed .NET languages from unmanaged WinRT-languages and vice versa.

Type system

WinRT has a rich object-oriented class-based type system that is built on the metadata. It supports constructs with corresponding constructs that are found in the .NET framework: classes, methods, properties, delegates and events.

WinRT components

Classes that are compiled to target the WinRT are called WinRT components. They are classes that can be written in any supported language and for any supported platform. The key is the metadata. This metadata makes is possible to interface with the component from any other WinRT language.

Limitations

There are currently some limitations for programmers. The runtime requires WinRT components that are built with .NET Framework to use the defined interface types or .NET type interfaces, which automatically map to the first named.

Inheritance is as yet not supported in managed WinRT components, except for XAML classes. [3]

Programming interfaces

Programs and libraries targeted for the WinRT runtime can be created and consumed from a number of platforms and programming languages. Notably C/C++ (either with language extensions offering first-class support for WinRT concepts, or with a lower-level template library allowing to write code in standard C++), .NET (C# and VB.NET) and Javascript. This is made possible by the metadata.

A language interface (or binding) is also referred to as a language projection.

C/C++

See also: C++

Native C++ is a first-class citizen of the WinRT-platform.

The language has a number of extensions that enables integration with the platform and its type system. The syntax resembles the one of C++/CLI although it produces native code and metadata that integrates with the runtime via COM. The extensions also enables reference counting.

WinRT is a native platform and supports any native C++ code. A C++ developer can reuse existing native C/C++ libraries with the only need to use the language extensions when writing code that is interfacing with the runtime.

.NET

See also: .NET Framework

The .NET Framework and the Common Language Runtime (CLR) is integrated into the WinRT as a subplatform. It also has influenced and set the standards for the ecosystem through the metadata format and libraries. The CLR provides services like JIT-compilation code and garbage collection.

WinRT supports XAML-based .NET Metro-style applications which are primarily written in C# and VB.NET. Although not yet officially supported, programs can also be written in other .NET languages.

Limitations
Classes defined in WinRT components that are built in managed .NET languages must be declared as sealed to not be able to be derived from as a limitation. However, non-sealed WinRT classes defined elsewhere can be inherited from in .NET, their virtual methods overriden, and so on (but the inherited managed class must still be sealed).

Members that interfaces with other language must have a signature with WinRT types or a managed type that is convertible to these. [4]

Javascript

See also: Javascript

Microsoft initially announced that HTML5 and Javascript would be integrated as part of the development experience for Windows 8. The "Chakra" Javascript engine which was developed for Internet Explorer 9 integrates with WinRT. That makes Javascript a first-class citizen in the WinRT ecosystem.

The Javascript environment does some tricks under the hood. It adapts WinRT features to follow the Javascript naming conventions to make the developer get the same experience as on the Web-platform. Namespaces are mapped to JS-objects and some special members are also added in some cases to make the developer experience similar to any web scenario.

Metro interfaces can be built with HTML5 and CSS and Javascript in code-behind.

The current version is Javascript 5.

API

WinRT comes with an Application Programming Interface (API) in the form of a class library that exposes the features of Windows 8 for the developer, like the Metro interface API. It is accessible and consumable from any supported language.

Windows classes

The Windows classes are native C/C++ libraries (unmanaged) that are exposed by the WinRT. They provide access to all functionality from XAML parser to the camera function.

Naming conventions

The naming convetions for the components (classes and other members) in the API are heavily influenced by the .NET naming conventions which uses camel case. Microsoft recommends users to follow these rules in case where no others are given.

These conventions are projected differently in some languages, like Javascript, which converts it to its conventions and the other way around. This is to give a native and consistent experience regarded from programming language.

References