SlideShare a Scribd company logo
WAY AHEAD™
Native Development for Windows Phone
The Windows Runtime API and Modern C++
2
»Senior Software Engineer at ALK Technologies
»Led development effort to bring CoPilot GPS
navigation app to Windows Phone 8
» #4 Free Navigation App in Window Phone store
»Windows Phone Dev by day and night
» Released 6 of my own apps to Windows Phone store
»Blog: www.robwirving.com
»Twitter: @robwirving
Rob Irving
3
»History of Native on Windows Phone
»Why use Native?
»C++ 11
»Windows Runtime (WinRT)
»Component Extensions (C++/CX)
»Options in Visual Studio
»Sample Code
»Q & A
Agenda
4
»Lack of Native Development on WP7 hurt the
platform
» Lack of high-end games available on other platforms
» More difficult/impossible to port existing apps from
other platforms
»Support for Native Development is the single
largest change in the WP8 SDK
»Native Gaming and Middleware products
» Unity 3D, Havok, Cocos 2D, etc.
History of Native on Windows Phone
WAY AHEAD™
Why use Native?
6
»Reusability
» Existing code that you don’t want to rewrite
» Use of existing 3rd party libraries (SQLite)
»Portability
» Share code between Windows, iOS and Android
» Write once, use it everywhere
Why use Native?
7
»Game development with high-end graphics
» Direct3D on Windows and Windows Phone
» OpenGL on iOS and Android
»Performance
» Should not be viewed as the main reason to use C++
» Performance can be better using Native, but is often
exaggerated
Why use Native?
8
»Portability & Reusability in action
» ~1,000 Lines of C# for WP8
» ~7,000 Lines of new C++ and C++/CX
» ~800,000 Lines of existing C++ code
»~99% shared code between
Windows Phone, iOS and Android!
CoPilot GPS – Native Case Study
WAY AHEAD™
A brief introduction to Modern C++
C++ 11
10
1979
1983
1998 2011
History of C++
C++ began as an
enhancement
to C at Bell Labs
Originally named
‘C with Classes’
Renamed to C++
C++ ISO committee
defined C++ 98
No significant changes
to C++ for 13 years
C++ ISO committee
defined C++ 11
New features heavily
influenced by managed
languages like .NET
11
»Type inference (auto)
» Avoid explicitly declaring the type of a variable
» Similar to .NET ‘var’ keyword
»Lambdas
» Anonymous inline functions
C++ 11 Features
int num1 = 10;
double num2 = 2.5
auto num3 = num1 / num2;
std::vector<CityLocation> cities;
std::sort(begin(cities), end(cities), [](CityLocation a, CityLocation b)
{
return a.distance < b.distance;
});
12
»Strongly type enums
»Foreach-ish loop
C++ 11 Features
int numbers[] = {0, 1, 2, 3, 4, 5};
int sum = 0;
for(int& number : numbers)
{
sum += number;
}
enum class Fruit
{
Apple,
Banana,
Orange
};
if(meal.Fruit == Fruit::Banana)
// do Banana stuff
int fruitAbomination = Apple + Orange; // ERROR - Can’t do this anymore
WAY AHEAD™
Windows Runtime API
14
»Shared API between Windows Phone 8 and
Windows Store Apps
» Overlaps much of the existing Windows Phone .NET
API
» Not all APIs are available for both
» ~11,000 Windows Runtime
» ~2,800 for both
» ~600 Windows Phone Runtime
Windows Runtime API (WinRT)
15
»API is a COM-based Native API
»Accessible from C#, VB.NET and Component
Extensions (C++/CX)
» Also Javascript on Windows 8
»API definitions in Windows Metadata (.winmd)
files
» Similar format to .NET API definitions
Windows Runtime API (WinRT)
16
»Native / Managed Interop
» WinRT is the only supported method of interop
»The most painful parts of Native /Managed
interop are gone with Windows Runtime
» No P/Invoke
» No Marshalling
Native Interop is easy with WinRT
WAY AHEAD™
Component Extensions (C++/CX)
18
»Syntax and Library abstractions to interact with
COM based WinRT API
»Much easier to develop for compared to old
COM programming
Component Extensions (C++/CX)
19
»Syntactically similar to C++/CLI
» ‘ref’ and ‘sealed’ classes
» Reference pointers or ‘hats’ ^
Component Extensions (C++/CX)
public ref class Foo sealed
{
};
Foo^ foo = ref new Foo();
20
»Differences from C++/CLI
» No managed CLR
» No Garbage Collection, ref counted objects instead
» ref new instead of gcnew
» Pure C++ classes allowed in C++/CX classes
» Global ref ptr’s allowed
Component Extensions (C++/CX)
21
»Properties
» No value keyword
» Can’t have public get, private set
Component Extensions (C++/CX)
public ref class Foobar sealed
{
public:
property int Foo; // automatic/trivial property
property int Bar
{
int get() { return _bar; }
void set(int newBar)
{
if(newBar > 0)
_bar = newBar;
}
}
private:
int _bar;
};
22
»Events
» Very similar to .NET events
» Unsubscribe using token
Component Extensions (C++/CX)
MyClass::MyClass()
{
geoLocator = ref new Geolocator();
// subscribe
eventToken = geoLocator->PositionChanged +=
ref new TypedEventHandler<Geolocator^, PositionChangedEventArgs^>(this, &MyClass::OnPosChanged);
}
MyClass::~MyClass()
{
// unsubscribe
geoLocator->PositionChanged -= eventToken;
}
void MyClass::OnPosChanged(Geolocator^ geoLocator, PositionChangedEventArgs^ args)
{
auto geoPos = args->Position->Coordinate;
}
23
»XAML with Direct 3D
Options in Visual Studio
24
»Several Native Projects available
Options in Visual Studio
WAY AHEAD™
Visual Studio Demo
26
Additional Resources
Windows Phone 8 Development Internals
(Whitchapel, McKenna)
http://amzn.to/1a2989c
Modern C++ and Windows Store Apps
(Poduri)
http://amzn.to/GEW6Y4
27
»Channel 9 – channel9.msdn.com
» Build 2012 Sessions
channel9.msdn.com/Events/Build/2012/
» Build 2013 Sessions
channel9.msdn.com/Events/Build/2013/
» Going Native
channel9.msdn.com/Shows/C9-GoingNative
»C++ 11 Features in Visual C++ 11
blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx
Additional Resources
28
»Questions & Answers
»Slides will be posted to blog: robwirving.com
Thank You!

More Related Content

Similar to Native Development for Windows Phone 8 (20)

PPT
MSMDC_CLI363
mokacao
 
PPTX
C++ in windows phone apps
Mirco Vanini
 
PPTX
WINDOWS PHONE APPS IN C++
DotNetCampus
 
PPTX
C++ in Windows Phone Apps - Overview
Mirco Vanini
 
PPTX
App windows phone in c++
Mirco Vanini
 
PPTX
App windows phone in c++
MircoVanini
 
PPTX
Windows Phone 8 - introducing wp8 development
Gouda Mando
 
PPTX
Windows Phone 8 - 1 Introducing Windows Phone 8 Development
Oliver Scheer
 
PPTX
Tizen Native Application Development with C/C++
Gilang Mentari Hamidy
 
PPTX
Runtime 8 and Windows Phone 8
Damir Dobric
 
PDF
Samsung Indonesia: Tizen Native App
Ryo Jin
 
PPTX
Porting tometro
dogra09
 
PDF
C++: a fast tour of a fast language
Adrian Ostrowski
 
PPTX
Return of c++
Yongwei Wu
 
PPTX
Radu vunvulea building and testing windows 8 metro style applications using ...
Radu Vunvulea
 
PDF
Lviv MD Day 2015 Ігор Кантор "Розробка додатків зі спільним C++ кодом для iOS...
Lviv Startup Club
 
PPTX
WIndows Embedded Compact 2013 – What’s news
Mirco Vanini
 
PDF
Programming c++
Khổng Xuân Trung
 
PPTX
Windows Phone 8 App Development
DalpatTapaniya
 
PPTX
Windows phone 8 overview
codeblock
 
MSMDC_CLI363
mokacao
 
C++ in windows phone apps
Mirco Vanini
 
WINDOWS PHONE APPS IN C++
DotNetCampus
 
C++ in Windows Phone Apps - Overview
Mirco Vanini
 
App windows phone in c++
Mirco Vanini
 
App windows phone in c++
MircoVanini
 
Windows Phone 8 - introducing wp8 development
Gouda Mando
 
Windows Phone 8 - 1 Introducing Windows Phone 8 Development
Oliver Scheer
 
Tizen Native Application Development with C/C++
Gilang Mentari Hamidy
 
Runtime 8 and Windows Phone 8
Damir Dobric
 
Samsung Indonesia: Tizen Native App
Ryo Jin
 
Porting tometro
dogra09
 
C++: a fast tour of a fast language
Adrian Ostrowski
 
Return of c++
Yongwei Wu
 
Radu vunvulea building and testing windows 8 metro style applications using ...
Radu Vunvulea
 
Lviv MD Day 2015 Ігор Кантор "Розробка додатків зі спільним C++ кодом для iOS...
Lviv Startup Club
 
WIndows Embedded Compact 2013 – What’s news
Mirco Vanini
 
Programming c++
Khổng Xuân Trung
 
Windows Phone 8 App Development
DalpatTapaniya
 
Windows phone 8 overview
codeblock
 

Recently uploaded (20)

PDF
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
PDF
Simplify React app login with asgardeo-sdk
vaibhav289687
 
PPTX
Get Started with Maestro: Agent, Robot, and Human in Action – Session 5 of 5
klpathrudu
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PDF
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
Simplify React app login with asgardeo-sdk
vaibhav289687
 
Get Started with Maestro: Agent, Robot, and Human in Action – Session 5 of 5
klpathrudu
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Ad

Native Development for Windows Phone 8

  • 1. WAY AHEAD™ Native Development for Windows Phone The Windows Runtime API and Modern C++
  • 2. 2 »Senior Software Engineer at ALK Technologies »Led development effort to bring CoPilot GPS navigation app to Windows Phone 8 » #4 Free Navigation App in Window Phone store »Windows Phone Dev by day and night » Released 6 of my own apps to Windows Phone store »Blog: www.robwirving.com »Twitter: @robwirving Rob Irving
  • 3. 3 »History of Native on Windows Phone »Why use Native? »C++ 11 »Windows Runtime (WinRT) »Component Extensions (C++/CX) »Options in Visual Studio »Sample Code »Q & A Agenda
  • 4. 4 »Lack of Native Development on WP7 hurt the platform » Lack of high-end games available on other platforms » More difficult/impossible to port existing apps from other platforms »Support for Native Development is the single largest change in the WP8 SDK »Native Gaming and Middleware products » Unity 3D, Havok, Cocos 2D, etc. History of Native on Windows Phone
  • 6. 6 »Reusability » Existing code that you don’t want to rewrite » Use of existing 3rd party libraries (SQLite) »Portability » Share code between Windows, iOS and Android » Write once, use it everywhere Why use Native?
  • 7. 7 »Game development with high-end graphics » Direct3D on Windows and Windows Phone » OpenGL on iOS and Android »Performance » Should not be viewed as the main reason to use C++ » Performance can be better using Native, but is often exaggerated Why use Native?
  • 8. 8 »Portability & Reusability in action » ~1,000 Lines of C# for WP8 » ~7,000 Lines of new C++ and C++/CX » ~800,000 Lines of existing C++ code »~99% shared code between Windows Phone, iOS and Android! CoPilot GPS – Native Case Study
  • 9. WAY AHEAD™ A brief introduction to Modern C++ C++ 11
  • 10. 10 1979 1983 1998 2011 History of C++ C++ began as an enhancement to C at Bell Labs Originally named ‘C with Classes’ Renamed to C++ C++ ISO committee defined C++ 98 No significant changes to C++ for 13 years C++ ISO committee defined C++ 11 New features heavily influenced by managed languages like .NET
  • 11. 11 »Type inference (auto) » Avoid explicitly declaring the type of a variable » Similar to .NET ‘var’ keyword »Lambdas » Anonymous inline functions C++ 11 Features int num1 = 10; double num2 = 2.5 auto num3 = num1 / num2; std::vector<CityLocation> cities; std::sort(begin(cities), end(cities), [](CityLocation a, CityLocation b) { return a.distance < b.distance; });
  • 12. 12 »Strongly type enums »Foreach-ish loop C++ 11 Features int numbers[] = {0, 1, 2, 3, 4, 5}; int sum = 0; for(int& number : numbers) { sum += number; } enum class Fruit { Apple, Banana, Orange }; if(meal.Fruit == Fruit::Banana) // do Banana stuff int fruitAbomination = Apple + Orange; // ERROR - Can’t do this anymore
  • 14. 14 »Shared API between Windows Phone 8 and Windows Store Apps » Overlaps much of the existing Windows Phone .NET API » Not all APIs are available for both » ~11,000 Windows Runtime » ~2,800 for both » ~600 Windows Phone Runtime Windows Runtime API (WinRT)
  • 15. 15 »API is a COM-based Native API »Accessible from C#, VB.NET and Component Extensions (C++/CX) » Also Javascript on Windows 8 »API definitions in Windows Metadata (.winmd) files » Similar format to .NET API definitions Windows Runtime API (WinRT)
  • 16. 16 »Native / Managed Interop » WinRT is the only supported method of interop »The most painful parts of Native /Managed interop are gone with Windows Runtime » No P/Invoke » No Marshalling Native Interop is easy with WinRT
  • 18. 18 »Syntax and Library abstractions to interact with COM based WinRT API »Much easier to develop for compared to old COM programming Component Extensions (C++/CX)
  • 19. 19 »Syntactically similar to C++/CLI » ‘ref’ and ‘sealed’ classes » Reference pointers or ‘hats’ ^ Component Extensions (C++/CX) public ref class Foo sealed { }; Foo^ foo = ref new Foo();
  • 20. 20 »Differences from C++/CLI » No managed CLR » No Garbage Collection, ref counted objects instead » ref new instead of gcnew » Pure C++ classes allowed in C++/CX classes » Global ref ptr’s allowed Component Extensions (C++/CX)
  • 21. 21 »Properties » No value keyword » Can’t have public get, private set Component Extensions (C++/CX) public ref class Foobar sealed { public: property int Foo; // automatic/trivial property property int Bar { int get() { return _bar; } void set(int newBar) { if(newBar > 0) _bar = newBar; } } private: int _bar; };
  • 22. 22 »Events » Very similar to .NET events » Unsubscribe using token Component Extensions (C++/CX) MyClass::MyClass() { geoLocator = ref new Geolocator(); // subscribe eventToken = geoLocator->PositionChanged += ref new TypedEventHandler<Geolocator^, PositionChangedEventArgs^>(this, &MyClass::OnPosChanged); } MyClass::~MyClass() { // unsubscribe geoLocator->PositionChanged -= eventToken; } void MyClass::OnPosChanged(Geolocator^ geoLocator, PositionChangedEventArgs^ args) { auto geoPos = args->Position->Coordinate; }
  • 23. 23 »XAML with Direct 3D Options in Visual Studio
  • 24. 24 »Several Native Projects available Options in Visual Studio
  • 26. 26 Additional Resources Windows Phone 8 Development Internals (Whitchapel, McKenna) http://amzn.to/1a2989c Modern C++ and Windows Store Apps (Poduri) http://amzn.to/GEW6Y4
  • 27. 27 »Channel 9 – channel9.msdn.com » Build 2012 Sessions channel9.msdn.com/Events/Build/2012/ » Build 2013 Sessions channel9.msdn.com/Events/Build/2013/ » Going Native channel9.msdn.com/Shows/C9-GoingNative »C++ 11 Features in Visual C++ 11 blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx Additional Resources
  • 28. 28 »Questions & Answers »Slides will be posted to blog: robwirving.com Thank You!

Editor's Notes

  • #6: So why use Native? Can anyone tell me some of the reasons why you might want to use Native Code instead of something like C# ? Performance is not the main reason