SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Programming Windows 8 With WinRT



                                             Rainer Stropek
                                             software architects gmbh




WinRT                                Mail
                                     Web
                                   Twitter
                                             rainer@timecockpit.com
                                             http://www.timecockpit.com
                                             @rstropek


The Start Of A New Era
                                             Saves the day.
Agenda



                                            What's WinRT?
                                            Windows Runtime (WinRT) is the
                                             basic technology that enables
                                             Windows 8.

                                            What is WinRT from a developer's
                                             standpoint?

                                            Is it really revolutionary new?
                                               What has changed? Why was
                                               change necessary?

                                            This session will be a technical
                                              deep dive into WinRT. It will not
                                              be a design or marketing
Windows reimagined                            session for Windows 8.
Metro-Design, Fast And Fluid, Touch, etc.
The Early Days…



                                                                        Before .NET…
                                                                        … every language had it's own
                                                                          compiler/interpreter, runtime
                                                                          environment, libraries, etc.
      Compiler            Compiler/Interpreter   Compiler/Interpreter


                                                                        This caused a lot of problems:

                                                                         Expensive to implement.

                                                                         How can they work together?

                                                                         How can one benefit from
                                                                          innovation happening in
                                                                          another island?
The World Before .NET…                                                  And many, many more.
…consisted of a lot of islands
The Early Days…



                                                                   COM…
                                                                   … introduced a binary interface
                                                                     for interoperable components.
                                                                     This opened a whole new world
      Compiler       Compiler/Interpreter   Compiler/Interpreter
                                                                     on the Windows platform:

                                                                    Cross-language component
                                                                     libraries.

                                                                    Rich application integration
                                                                     became possible – can you
                                                                     remember OLE?

                                                                    Even richer component
                                                                     technologies appeared – can
COM                                                                  you remember
Component Object Model                                               COM+, DCOM, or VBA?
Problems
 What Was Wrong With COM?

 Some    design flaws
 Can you remember the "DLL Hell"?
 Not really ready for the upcoming internet.

 COM    was no native part of the programming languages
 Inside a component you could use all language features.
 You had to write separate COM wrapper (e.g. map your types to COM's type system).
 Etc.
Problems
 And Finally…

 There   was this new language "Java"
 More productive and robust than e.g. C++.
 Built for a component-oriented world from day one.
 Platform independent.
 The next big thing?
.NET Appears…



                                                                        The .NET Revolution
Compiler
                                                                        Let's introduce a common
                                                                        language runtime with a class
                                                                        library and a language that can
                                                        Still
                                               important, someone
                                                                        compete with Java.
                                                has to build all this
                                                                         Building languages will be
                                                                          easier.
                                                                         Strong cross-language
                                                                          interoperability.
                                                                         Many languages benefit from
                                                                          the world-class, internet-ready
                                                                          class library.
 .NET = CLR + Library                                                    Make the CLR a standard and
 Common Language Runtime + .NET Framework Class Library                   become platform independent.
.NET – A Big Success!
 Today    dozens of languages are based on CLR
  We even have a DLR for dynamic languages like Python, Ruby and JavaScript.

 In   various products (hosts) and on multiple platforms
  CLR and C# are standards, somewhat platform independent (e.g. Mono, Silverlight).

 .NET   Framework Class Library
  One of the most complete frameworks on the market today.
  Big success factor for the .NET platform.
.NET For Everybody!
 Well…

 Huge    C++ Codebase
 PInvoke and COM Interop are ok but definitively no perfect solution.

 Unmanaged         code is important in some cases
 Games, compute-intensive calculations, etc.

 …and    than there is the browser
 JavaScript rules the web.
10 Year After The Rise Of .NET…



                                                           Limits Of .NET?
                                                            .NET Library often just a thin
                                                             wrapper around OS services.

                                                            (Unmanaged) C++ is still very
                                                             important, cannot benefit from
                                                             .NET Class Library (e.g. XAML).
                                                            JavaScript has become popular;
                                                             de-facto standard for platform
                                                             independence.
                                                            .NET Class Library needs some
                                                             redesign.

C++ And JavaScript                                         WinRT is for the new world of
C++ is still strong and JavaScript is the new big player   touch, tablets, and language
                                                           interoperability.
Access Native Code From .NET


[DllImport("avicap32.dll", EntryPoint="capCreateCaptureWindow")
]                                                                 PInvoke
static extern int capCreateCaptureWindow(
  string lpszWindowName, int dwStyle,                             Platform Invoke.
  int X, int Y, int nWidth, int nHeight,
                                                                  Import functions from
  int hwndParent, int nID);
                                                                    unmanaged libraries in .NET.
[DllImport("avicap32.dll")]                                       See MSDN for details.
static extern bool capGetDriverDescription(
  int wDriverIndex,
  [MarshalAs(UnmanagedType.LPTStr)] ref string lpszName,
  int cbName,
  [MarshalAs(UnmanagedType.LPTStr)] ref string lpszVer,
  int cbVer);
Access Native Code From .NET



                                                                              COM Interop
                                                                              Access COM objects from .NET

                                                                              Simplified in latest versions of
                                                                                .NET, still it does not feel
                                                                                "natural" to .NET developers.

                                                                              See MSDN for details.
//000013: var x = new XmlDocument();
 IL_0001: newobj
            instance void [System.Xml]System.Xml.XmlDocument::.ctor()


//000014: var y = new MyComObjectLib.MyClass();
 IL_0007: ldstr    "F61ED984-6153-486D-8392-303545E63C2D"
 IL_000c: newobj   instance void [mscorlib]System.Guid::.ctor(string)
 IL_0011: call     class [mscorlib]System.Type
   [mscorlib]System.Type::GetTypeFromCLSID(valuetype [mscorlib]System.Guid)
 IL_0016: call     object [mscorlib]System.Activator::CreateInstance([...])
 IL_001b: castclass MyComObjectLib.MyClass
From .NET To WinRT
 Combine        what's great in COM and .NET
  Binary interface for language interoperability.
  Metadata management of .NET.

 "New     COM" as a natural part of all languages/platforms
  .NET, C++, and JavaScript; maybe others will join the party, too.

 Build   a new class library on the new runtime
  Cleanup the library compared to .NET (e.g. async rules, dependencies, etc.)

 Do   not enforce managed code
The Windows 8 Platform



                                                    WinRT is…
                                                    … underlying infrastructure of
                                                      metro-style apps in Windows 8.


                                                     Binary interface for
                                                      interoperability (based on
                                                      COM).

                                                     Language projection layer for
                                                      .NET languages, C++ and
                                                      JavaScript.

                                                     Class library targeted at
                                                      development of metro-style
WinRT                                                 apps.
Windows Runtime – The Common Runtime Of Windows 8
The Windows 8 Platform



                                                    WinRT is…
                                                     secure runtime environment
                                                      which is the basis for the
                                                      upcoming Windows Store.


                                                    And a lot of other things that we
                                                    cannot cover here because of the
                                                    limited time.




WinRT
Windows Runtime – The Common Runtime Of Windows 8
The Windows 8 Platform



                                              Projection Means…
                                              … you can stick to naming
                                                conventions you are used to
                                                (e.g. camelCasing in
                                                JavaScript, PascalCasing in C#).

                                              … you can write WinRT
                                                components and your compiler
                                                will generate the necessary
                                                infrastructure (e.g. interfaces)

                                              … ref counting is automatically
                                                done behind the scenes.


Language Projection Layer
Because WinRT should feel "natural" to you.
The Windows 8 Platform



                                              Projection Means…
                                              … COM's interface-based logic is
                                                translated into namespaces and
                                                classes in the OO world.




Language Projection Layer
Because WinRT should feel "natural" to you.
Language Projection Layer


// Note that all parameters are passed as "hat pointers" (^). Hat
// pointers are pointers to WinRT objects. The pointer is           C++/CX
// automatically reference counted (COM’s IUnknown.AddRef and
// IUnknown.Release methods).                                       Extends the C++ syntax to make it
void OnShowMsgBoxWithCx(                                              easier to consume and write
  Object ^sender, Windows::UI::Xaml::RoutedEventArgs ^eventArgs)      WinRT components.
{
  // Note that we create the new instance of the WinRT component    In this sample RoutedEventArgs
  // "MessageDialog" using "ref new" instead of new. This is           and MessageDialog are no
  // necessary to retrieve a handle to the instance and let            C++ classes, they are WinRT
  // WinRT do the reference counting.                                  (=COM) objects.
  auto msgBox = ref new Windows::UI::Popups::MessageDialog(
     "Hello World!");
  msgBox->ShowAsync();
                                                                    Quite similar to C#, isn't it?
}
Language Projection Layer


namespace MyApplication
{
                                                       C++/CX
  // Note that this class is defined as a ref class.
  // It becomes a WinRT component.                     Extends the C++ syntax to make it
  public ref class BlankPage sealed
                                                         easier to consume and write
  {
                                                         WinRT components.
    public:                                            In this sample RoutedEventArgs
      BlankPage();                                        and MessageDialog are no
    protected:                                            C++ classes, they are WinRT
      virtual void OnNavigatedTo(                         (=COM) objects.
         NavigationEventArgs^ e) override;
    private:
      void OnShowMsgBoxWithCx(
         Object ^sender, RoutedEventArgs ^eventArgs)
    { … }
  }
}
Language Projection Layer



Windows::UI::Popups::MessageDialog msgBox(
  "Hello World!");
                                             C++, WRL
msgBox.ShowAsync();                          It is possible to consume and
                                                 write WinRT components in
                                                 plain C++.

                                             You can even do it without any
                                               library support (not
                                               recommended).

                                             If you need to use plain C++
                                                instead of C++/CX use the
                                                Windows Runtime Library
                                                (WRL).


                                             These two lines of C++/CX code
                                               become…
Language Projection Layer



                                                                                   C++, WRL
void BlankPage::OnShowMsgBoxWrl(
  Object ^sender, Windows::UI::Xaml::RoutedEventArgs ^eventArgs) {
  const wchar_t *msgBoxClassName = L"Windows.UI.Popups.MessageDialog";
  const wchar_t *helloWorldMessage = L"Hello World!";
  HSTRING hString, hWelcomeString;                                                 … many lines of code in plain C++
                                                                                     with WRL.
  auto hr = ::WindowsCreateString(msgBoxClassName,
    static_cast<UINT32>(::wcslen(msgBoxClassName)), &hString);
  if (SUCCEEDED(hr)) {
    Microsoft::WRL::ComPtr<ABI::Windows::UI::Popups::IMessageDialogFactory>        However, this example shows us
                                                                                     that at the very bottom WinRT…
      factory;
    hr = Windows::Foundation::GetActivationFactory(hString, &factory);
    if (SUCCEEDED(hr)) {
      hr = ::WindowsCreateString(helloWorldMessage,                                 is based on COM.
        static_cast<UINT32>(::wcslen(helloWorldMessage)), &hWelcomeString);

                                                                                    is exception-free (exceptions
      if (SUCCEEDED(hr)) {
        Microsoft::WRL::ComPtr<ABI::Windows::UI::Popups::IMessageDialog> dialog;
        hr = factory->Create(hWelcomeString, &dialog);                               are introduced by the language
                                                                                     projection layer).
        if(SUCCEEDED(hr)) {
          Microsoft::WRL::ComPtr<
            __FIAsyncOperation_1_Windows__CUI__CPopups__CIUICommand> command;
          hr = dialog->ShowAsync(&command);                                         has it's own type system.
        }

                                                                                    etc.
        ::WindowsDeleteString(hWelcomeString);
      }
    }
    ::WindowsDeleteString(hString);
  }
}
Language Projection Layer



                                                            WinRT And .NET
                                                            C# and VB can consume WinRT
                                                              components as if they were
                                                              native .NET classes.

                                                            Even IL knows about the WinRT. It
.assembly extern System.Runtime {                             is deeply integrated into the
  .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )                .NET platform.
  .ver 4:0:0:0
}
.assembly extern windowsruntime Windows {
  .ver 255:255:255:255
}
[...]
//000008: var x = new Windows.Data.Xml.Dom.XmlDocument();
  IL_0001: newobj instance void
    [Windows]Windows.Data.Xml.Dom.XmlDocument::.ctor()
Language Projection Layer



                              WinRT And .NET
                              While writing a COM component
                               in C#/VS 2010 was complex and
                               a lot of work…




COM Component In C#/VS 2010
A Lot Of Manual Coding…
Language Projection Layer



                                                       WinRT And .NET
                                                       … it is easy with the next version
                                                         of C# and VS.

                                                       If you follow some basic rules the
                                                          compiler will generate the
                                                          necessary infrastructure for you.

                                                       For details see MSDN.




WinRT Component In VS11
Very Simple With Some Limitations You Have To Follow
Language Projection Layer




Language Interop From C# To JavaScript Via WinRT
Note The Automatic Changes Of Casing…
So What?
 If You Are A .NET Developer…

 You   may ask yourself why you need something new
 Why didn't the other guys simply join your .NET platform?

 You   will continue to use the CLR.
 It is your bridge to seamless integration with WinRT.

 Access    OS services directly using WinRT
 No wrappers around Windows API any more.
 The parts of the .NET class library you will use will shrink.
So What?
 If You Are A C++ Developer…

 Welcome      to the world of XAML!
 You do not need to be jealous any more because the .NET guys have WPF ;-)
 Freely combine e.g. Direct3D with XAML-based UI parts.

 You   can easily program WinRT with C++/CX
 If you want/need to you can stick to ISO C++ by using WRL.

 Language      interop with .NET and JavaScript
 Share components with .NET and JavaScript developers.
So What?
  If You Are A JavaScript Developer…

 Use     your existing skillset to write apps for Windows
  You can enter the upcoming Windows Store.

 Visit   my next session about WinRT and JavaScript
Programming Windows 8 With WinRT



                                             Rainer Stropek
                                             software architects gmbh



                                     Mail    rainer@timecockpit.com

Q&A                                  Web
                                   Twitter
                                             http://www.timecockpit.com
                                             @rstropek


Thank You For Coming.
                                             Saves the day.

Weitere ähnliche Inhalte

Was ist angesagt?

.Net framework
.Net framework.Net framework
.Net frameworkArun Pal
 
Java vs .net
Java vs .netJava vs .net
Java vs .netTech_MX
 
.NET Framework 4.0 – Changes & Benefits
.NET Framework 4.0 – Changes & Benefits .NET Framework 4.0 – Changes & Benefits
.NET Framework 4.0 – Changes & Benefits Deepika Chaudhary
 
.net CLR
.net CLR.net CLR
.net CLRDevTalk
 
Evolution of .net frame work
Evolution of .net frame workEvolution of .net frame work
Evolution of .net frame workvc7722
 
Presentation1
Presentation1Presentation1
Presentation1kpkcsc
 
Java Programming (M&M)
Java Programming (M&M)Java Programming (M&M)
Java Programming (M&M)mafffffe19
 
Droidcon 2011: Mosync mobile framework, Stefan Sels, Tronicum
Droidcon 2011: Mosync mobile framework, Stefan Sels, TronicumDroidcon 2011: Mosync mobile framework, Stefan Sels, Tronicum
Droidcon 2011: Mosync mobile framework, Stefan Sels, TronicumDroidcon Berlin
 
Windows Phone 8 - 1 Introducing Windows Phone 8 Development
Windows Phone 8 - 1 Introducing Windows Phone 8 DevelopmentWindows Phone 8 - 1 Introducing Windows Phone 8 Development
Windows Phone 8 - 1 Introducing Windows Phone 8 DevelopmentOliver Scheer
 
02 intro to programming in .net (part 2)
02   intro to programming in .net (part 2)02   intro to programming in .net (part 2)
02 intro to programming in .net (part 2)Felisha Hosein
 
test2PPT
test2PPTtest2PPT
test2PPTAdmin
 

Was ist angesagt? (19)

.Net framework
.Net framework.Net framework
.Net framework
 
Java vs .net
Java vs .netJava vs .net
Java vs .net
 
.NET Framework 4.0 – Changes & Benefits
.NET Framework 4.0 – Changes & Benefits .NET Framework 4.0 – Changes & Benefits
.NET Framework 4.0 – Changes & Benefits
 
.net CLR
.net CLR.net CLR
.net CLR
 
Evolution of .net frame work
Evolution of .net frame workEvolution of .net frame work
Evolution of .net frame work
 
Net framework
Net frameworkNet framework
Net framework
 
Presentation1
Presentation1Presentation1
Presentation1
 
Net framework
Net frameworkNet framework
Net framework
 
Java Programming (M&M)
Java Programming (M&M)Java Programming (M&M)
Java Programming (M&M)
 
Synapse india reviews sharing asp.net
Synapse india reviews sharing  asp.netSynapse india reviews sharing  asp.net
Synapse india reviews sharing asp.net
 
Droidcon 2011: Mosync mobile framework, Stefan Sels, Tronicum
Droidcon 2011: Mosync mobile framework, Stefan Sels, TronicumDroidcon 2011: Mosync mobile framework, Stefan Sels, Tronicum
Droidcon 2011: Mosync mobile framework, Stefan Sels, Tronicum
 
SynapseIndia dotnet development framework
SynapseIndia  dotnet development frameworkSynapseIndia  dotnet development framework
SynapseIndia dotnet development framework
 
Vb.net class notes
Vb.net class notesVb.net class notes
Vb.net class notes
 
Windows Phone 8 - 1 Introducing Windows Phone 8 Development
Windows Phone 8 - 1 Introducing Windows Phone 8 DevelopmentWindows Phone 8 - 1 Introducing Windows Phone 8 Development
Windows Phone 8 - 1 Introducing Windows Phone 8 Development
 
02 intro to programming in .net (part 2)
02   intro to programming in .net (part 2)02   intro to programming in .net (part 2)
02 intro to programming in .net (part 2)
 
Electron
ElectronElectron
Electron
 
Asp dot net
Asp dot netAsp dot net
Asp dot net
 
Asp net
Asp netAsp net
Asp net
 
test2PPT
test2PPTtest2PPT
test2PPT
 

Ähnlich wie Programming With WinRT And Windows8

Computer Languages And Programming Frameworks
Computer Languages And Programming FrameworksComputer Languages And Programming Frameworks
Computer Languages And Programming FrameworksGracie Segura
 
ITCamp 2012 - Raffaele Rialdi - Introduction to WinRT
ITCamp 2012 - Raffaele Rialdi - Introduction to WinRTITCamp 2012 - Raffaele Rialdi - Introduction to WinRT
ITCamp 2012 - Raffaele Rialdi - Introduction to WinRTITCamp
 
Robots in Human Environments
Robots in Human EnvironmentsRobots in Human Environments
Robots in Human EnvironmentsAndreas Heil
 
.Net introduction by Quontra Solutions
.Net introduction by Quontra Solutions.Net introduction by Quontra Solutions
.Net introduction by Quontra SolutionsQUONTRASOLUTIONS
 
Using Technology to Make People More Powerful
Using Technology to Make People More PowerfulUsing Technology to Make People More Powerful
Using Technology to Make People More PowerfulIan Heron
 
229 Convergence In Device Software
229   Convergence In Device Software229   Convergence In Device Software
229 Convergence In Device SoftwareEric Cloninger
 
Visula C# Programming Lecture 1
Visula C# Programming Lecture 1Visula C# Programming Lecture 1
Visula C# Programming Lecture 1Abou Bakr Ashraf
 
Interopability with Suse Linux: MoonLight Project
Interopability with Suse Linux: MoonLight Project Interopability with Suse Linux: MoonLight Project
Interopability with Suse Linux: MoonLight Project Alessandro Binhara
 
BUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and ApproachesBUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and ApproachesLinaro
 
Dotnet ch1
Dotnet ch1Dotnet ch1
Dotnet ch1007laksh
 
Unit 4 Assignment 1 Comparative Study Of Programming...
Unit 4 Assignment 1 Comparative Study Of Programming...Unit 4 Assignment 1 Comparative Study Of Programming...
Unit 4 Assignment 1 Comparative Study Of Programming...Carmen Sanborn
 

Ähnlich wie Programming With WinRT And Windows8 (20)

Computer Languages And Programming Frameworks
Computer Languages And Programming FrameworksComputer Languages And Programming Frameworks
Computer Languages And Programming Frameworks
 
ITCamp 2012 - Raffaele Rialdi - Introduction to WinRT
ITCamp 2012 - Raffaele Rialdi - Introduction to WinRTITCamp 2012 - Raffaele Rialdi - Introduction to WinRT
ITCamp 2012 - Raffaele Rialdi - Introduction to WinRT
 
Qtframework
QtframeworkQtframework
Qtframework
 
Os Rego
Os RegoOs Rego
Os Rego
 
Robots in Human Environments
Robots in Human EnvironmentsRobots in Human Environments
Robots in Human Environments
 
.Net introduction by Quontra Solutions
.Net introduction by Quontra Solutions.Net introduction by Quontra Solutions
.Net introduction by Quontra Solutions
 
Using Technology to Make People More Powerful
Using Technology to Make People More PowerfulUsing Technology to Make People More Powerful
Using Technology to Make People More Powerful
 
Intermediate Languages
Intermediate LanguagesIntermediate Languages
Intermediate Languages
 
229 Convergence In Device Software
229   Convergence In Device Software229   Convergence In Device Software
229 Convergence In Device Software
 
Compilers
CompilersCompilers
Compilers
 
Visula C# Programming Lecture 1
Visula C# Programming Lecture 1Visula C# Programming Lecture 1
Visula C# Programming Lecture 1
 
Chapter1
Chapter1Chapter1
Chapter1
 
Qt introduction
Qt introductionQt introduction
Qt introduction
 
Interopability with Suse Linux: MoonLight Project
Interopability with Suse Linux: MoonLight Project Interopability with Suse Linux: MoonLight Project
Interopability with Suse Linux: MoonLight Project
 
Unit ii oo design 9
Unit ii oo design 9Unit ii oo design 9
Unit ii oo design 9
 
BUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and ApproachesBUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and Approaches
 
Dotnet ch1
Dotnet ch1Dotnet ch1
Dotnet ch1
 
Programming landuages
Programming landuagesProgramming landuages
Programming landuages
 
Introduction to .net
Introduction to .netIntroduction to .net
Introduction to .net
 
Unit 4 Assignment 1 Comparative Study Of Programming...
Unit 4 Assignment 1 Comparative Study Of Programming...Unit 4 Assignment 1 Comparative Study Of Programming...
Unit 4 Assignment 1 Comparative Study Of Programming...
 

Kürzlich hochgeladen

ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7DianaGray10
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Websitedgelyza
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfDaniel Santiago Silva Capera
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfAijun Zhang
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Brian Pichman
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 

Kürzlich hochgeladen (20)

ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Website
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdf
 
20150722 - AGV
20150722 - AGV20150722 - AGV
20150722 - AGV
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
20230104 - machine vision
20230104 - machine vision20230104 - machine vision
20230104 - machine vision
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 

Programming With WinRT And Windows8

  • 1. Programming Windows 8 With WinRT Rainer Stropek software architects gmbh WinRT Mail Web Twitter rainer@timecockpit.com http://www.timecockpit.com @rstropek The Start Of A New Era Saves the day.
  • 2. Agenda What's WinRT? Windows Runtime (WinRT) is the basic technology that enables Windows 8. What is WinRT from a developer's standpoint? Is it really revolutionary new? What has changed? Why was change necessary? This session will be a technical deep dive into WinRT. It will not be a design or marketing Windows reimagined session for Windows 8. Metro-Design, Fast And Fluid, Touch, etc.
  • 3. The Early Days… Before .NET… … every language had it's own compiler/interpreter, runtime environment, libraries, etc. Compiler Compiler/Interpreter Compiler/Interpreter This caused a lot of problems:  Expensive to implement.  How can they work together?  How can one benefit from innovation happening in another island? The World Before .NET… And many, many more. …consisted of a lot of islands
  • 4. The Early Days… COM… … introduced a binary interface for interoperable components. This opened a whole new world Compiler Compiler/Interpreter Compiler/Interpreter on the Windows platform:  Cross-language component libraries.  Rich application integration became possible – can you remember OLE?  Even richer component technologies appeared – can COM you remember Component Object Model COM+, DCOM, or VBA?
  • 5. Problems What Was Wrong With COM?  Some design flaws Can you remember the "DLL Hell"? Not really ready for the upcoming internet.  COM was no native part of the programming languages Inside a component you could use all language features. You had to write separate COM wrapper (e.g. map your types to COM's type system). Etc.
  • 6. Problems And Finally…  There was this new language "Java" More productive and robust than e.g. C++. Built for a component-oriented world from day one. Platform independent. The next big thing?
  • 7. .NET Appears… The .NET Revolution Compiler Let's introduce a common language runtime with a class library and a language that can Still important, someone compete with Java. has to build all this  Building languages will be easier.  Strong cross-language interoperability.  Many languages benefit from the world-class, internet-ready class library. .NET = CLR + Library  Make the CLR a standard and Common Language Runtime + .NET Framework Class Library become platform independent.
  • 8. .NET – A Big Success!  Today dozens of languages are based on CLR We even have a DLR for dynamic languages like Python, Ruby and JavaScript.  In various products (hosts) and on multiple platforms CLR and C# are standards, somewhat platform independent (e.g. Mono, Silverlight).  .NET Framework Class Library One of the most complete frameworks on the market today. Big success factor for the .NET platform.
  • 9. .NET For Everybody! Well…  Huge C++ Codebase PInvoke and COM Interop are ok but definitively no perfect solution.  Unmanaged code is important in some cases Games, compute-intensive calculations, etc.  …and than there is the browser JavaScript rules the web.
  • 10. 10 Year After The Rise Of .NET… Limits Of .NET?  .NET Library often just a thin wrapper around OS services.  (Unmanaged) C++ is still very important, cannot benefit from .NET Class Library (e.g. XAML).  JavaScript has become popular; de-facto standard for platform independence.  .NET Class Library needs some redesign. C++ And JavaScript WinRT is for the new world of C++ is still strong and JavaScript is the new big player touch, tablets, and language interoperability.
  • 11. Access Native Code From .NET [DllImport("avicap32.dll", EntryPoint="capCreateCaptureWindow") ] PInvoke static extern int capCreateCaptureWindow( string lpszWindowName, int dwStyle, Platform Invoke. int X, int Y, int nWidth, int nHeight, Import functions from int hwndParent, int nID); unmanaged libraries in .NET. [DllImport("avicap32.dll")] See MSDN for details. static extern bool capGetDriverDescription( int wDriverIndex, [MarshalAs(UnmanagedType.LPTStr)] ref string lpszName, int cbName, [MarshalAs(UnmanagedType.LPTStr)] ref string lpszVer, int cbVer);
  • 12. Access Native Code From .NET COM Interop Access COM objects from .NET Simplified in latest versions of .NET, still it does not feel "natural" to .NET developers. See MSDN for details. //000013: var x = new XmlDocument(); IL_0001: newobj instance void [System.Xml]System.Xml.XmlDocument::.ctor() //000014: var y = new MyComObjectLib.MyClass(); IL_0007: ldstr "F61ED984-6153-486D-8392-303545E63C2D" IL_000c: newobj instance void [mscorlib]System.Guid::.ctor(string) IL_0011: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromCLSID(valuetype [mscorlib]System.Guid) IL_0016: call object [mscorlib]System.Activator::CreateInstance([...]) IL_001b: castclass MyComObjectLib.MyClass
  • 13. From .NET To WinRT  Combine what's great in COM and .NET Binary interface for language interoperability. Metadata management of .NET.  "New COM" as a natural part of all languages/platforms .NET, C++, and JavaScript; maybe others will join the party, too.  Build a new class library on the new runtime Cleanup the library compared to .NET (e.g. async rules, dependencies, etc.)  Do not enforce managed code
  • 14. The Windows 8 Platform WinRT is… … underlying infrastructure of metro-style apps in Windows 8.  Binary interface for interoperability (based on COM).  Language projection layer for .NET languages, C++ and JavaScript.  Class library targeted at development of metro-style WinRT apps. Windows Runtime – The Common Runtime Of Windows 8
  • 15. The Windows 8 Platform WinRT is…  secure runtime environment which is the basis for the upcoming Windows Store. And a lot of other things that we cannot cover here because of the limited time. WinRT Windows Runtime – The Common Runtime Of Windows 8
  • 16. The Windows 8 Platform Projection Means… … you can stick to naming conventions you are used to (e.g. camelCasing in JavaScript, PascalCasing in C#). … you can write WinRT components and your compiler will generate the necessary infrastructure (e.g. interfaces) … ref counting is automatically done behind the scenes. Language Projection Layer Because WinRT should feel "natural" to you.
  • 17. The Windows 8 Platform Projection Means… … COM's interface-based logic is translated into namespaces and classes in the OO world. Language Projection Layer Because WinRT should feel "natural" to you.
  • 18. Language Projection Layer // Note that all parameters are passed as "hat pointers" (^). Hat // pointers are pointers to WinRT objects. The pointer is C++/CX // automatically reference counted (COM’s IUnknown.AddRef and // IUnknown.Release methods). Extends the C++ syntax to make it void OnShowMsgBoxWithCx( easier to consume and write Object ^sender, Windows::UI::Xaml::RoutedEventArgs ^eventArgs) WinRT components. { // Note that we create the new instance of the WinRT component In this sample RoutedEventArgs // "MessageDialog" using "ref new" instead of new. This is and MessageDialog are no // necessary to retrieve a handle to the instance and let C++ classes, they are WinRT // WinRT do the reference counting. (=COM) objects. auto msgBox = ref new Windows::UI::Popups::MessageDialog( "Hello World!"); msgBox->ShowAsync(); Quite similar to C#, isn't it? }
  • 19. Language Projection Layer namespace MyApplication { C++/CX // Note that this class is defined as a ref class. // It becomes a WinRT component. Extends the C++ syntax to make it public ref class BlankPage sealed easier to consume and write { WinRT components. public: In this sample RoutedEventArgs BlankPage(); and MessageDialog are no protected: C++ classes, they are WinRT virtual void OnNavigatedTo( (=COM) objects. NavigationEventArgs^ e) override; private: void OnShowMsgBoxWithCx( Object ^sender, RoutedEventArgs ^eventArgs) { … } } }
  • 20. Language Projection Layer Windows::UI::Popups::MessageDialog msgBox( "Hello World!"); C++, WRL msgBox.ShowAsync(); It is possible to consume and write WinRT components in plain C++. You can even do it without any library support (not recommended). If you need to use plain C++ instead of C++/CX use the Windows Runtime Library (WRL). These two lines of C++/CX code become…
  • 21. Language Projection Layer C++, WRL void BlankPage::OnShowMsgBoxWrl( Object ^sender, Windows::UI::Xaml::RoutedEventArgs ^eventArgs) { const wchar_t *msgBoxClassName = L"Windows.UI.Popups.MessageDialog"; const wchar_t *helloWorldMessage = L"Hello World!"; HSTRING hString, hWelcomeString; … many lines of code in plain C++ with WRL. auto hr = ::WindowsCreateString(msgBoxClassName, static_cast<UINT32>(::wcslen(msgBoxClassName)), &hString); if (SUCCEEDED(hr)) { Microsoft::WRL::ComPtr<ABI::Windows::UI::Popups::IMessageDialogFactory> However, this example shows us that at the very bottom WinRT… factory; hr = Windows::Foundation::GetActivationFactory(hString, &factory); if (SUCCEEDED(hr)) { hr = ::WindowsCreateString(helloWorldMessage,  is based on COM. static_cast<UINT32>(::wcslen(helloWorldMessage)), &hWelcomeString);  is exception-free (exceptions if (SUCCEEDED(hr)) { Microsoft::WRL::ComPtr<ABI::Windows::UI::Popups::IMessageDialog> dialog; hr = factory->Create(hWelcomeString, &dialog); are introduced by the language projection layer). if(SUCCEEDED(hr)) { Microsoft::WRL::ComPtr< __FIAsyncOperation_1_Windows__CUI__CPopups__CIUICommand> command; hr = dialog->ShowAsync(&command);  has it's own type system. }  etc. ::WindowsDeleteString(hWelcomeString); } } ::WindowsDeleteString(hString); } }
  • 22. Language Projection Layer WinRT And .NET C# and VB can consume WinRT components as if they were native .NET classes. Even IL knows about the WinRT. It .assembly extern System.Runtime { is deeply integrated into the .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) .NET platform. .ver 4:0:0:0 } .assembly extern windowsruntime Windows { .ver 255:255:255:255 } [...] //000008: var x = new Windows.Data.Xml.Dom.XmlDocument(); IL_0001: newobj instance void [Windows]Windows.Data.Xml.Dom.XmlDocument::.ctor()
  • 23. Language Projection Layer WinRT And .NET While writing a COM component in C#/VS 2010 was complex and a lot of work… COM Component In C#/VS 2010 A Lot Of Manual Coding…
  • 24. Language Projection Layer WinRT And .NET … it is easy with the next version of C# and VS. If you follow some basic rules the compiler will generate the necessary infrastructure for you. For details see MSDN. WinRT Component In VS11 Very Simple With Some Limitations You Have To Follow
  • 25. Language Projection Layer Language Interop From C# To JavaScript Via WinRT Note The Automatic Changes Of Casing…
  • 26. So What? If You Are A .NET Developer…  You may ask yourself why you need something new Why didn't the other guys simply join your .NET platform?  You will continue to use the CLR. It is your bridge to seamless integration with WinRT.  Access OS services directly using WinRT No wrappers around Windows API any more. The parts of the .NET class library you will use will shrink.
  • 27. So What? If You Are A C++ Developer…  Welcome to the world of XAML! You do not need to be jealous any more because the .NET guys have WPF ;-) Freely combine e.g. Direct3D with XAML-based UI parts.  You can easily program WinRT with C++/CX If you want/need to you can stick to ISO C++ by using WRL.  Language interop with .NET and JavaScript Share components with .NET and JavaScript developers.
  • 28. So What? If You Are A JavaScript Developer…  Use your existing skillset to write apps for Windows You can enter the upcoming Windows Store.  Visit my next session about WinRT and JavaScript
  • 29. Programming Windows 8 With WinRT Rainer Stropek software architects gmbh Mail rainer@timecockpit.com Q&A Web Twitter http://www.timecockpit.com @rstropek Thank You For Coming. Saves the day.

Hinweis der Redaktion

  1. This slide contains animations and cannot be printed appropriately. The next (hidden) slide contains the status of the slide after all animation. It is fine for printing.
  2. This slide is for printing only (same content as animated slide before).