Windows 8 development                             C# vs. C++                         practical experience                 ...
About mesobota, 5 stycznia 13
About me        13sobota, 5 stycznia 13
About me        13         7sobota, 5 stycznia 13
About me        13         7sobota, 5 stycznia 13
About me        13         7sobota, 5 stycznia 13
About me        13         7sobota, 5 stycznia 13
Two appssobota, 5 stycznia 13
In common                        • Windows 8 app targeting touch devices                        • Relatively simple (in sc...
Top differences                        •   Customer types:                            •   Corporate vs. Startup entity    ...
Top differences                        •   Customer types:                            •   Corporate vs. Startup entity    ...
Team, process &                                 communication                        •   Roles and competences            ...
Designsobota, 5 stycznia 13
Designsobota, 5 stycznia 13
Designsobota, 5 stycznia 13
Designsobota, 5 stycznia 13
Design                        •   When porting from Web/IOS:                            •   New features (non existing on ...
CPP vs. C#                                       experience                        •   Easy part:                         ...
WinRT in C++ from                               C-sharpers’                        •   Basic Platform::String example:    ...
WinRT in C++ from                           C-sharpers’                        •   How to sub divide, search and execute o...
PPL Tasks 	   if	  (file	  !=	  nullptr) 	   { 	   	   Platform::String^	  m_imageFileName	  =	  file-­‐>Name; 	  	  	  	 ...
PPL Tasks	   loadAndRenderTask.then([=]()  	   if	  (file	  !=	  nullptr)	   {  	   {	   	   Dispatcher-­‐>RunAsync(CoreDi...
Dynamic Binding 	                            and Cache        Windows::UI::Xaml::Media::Imaging::BitmapImage^	  bitmapSrc	...
Dynamic Binding 	                              and Cache        Windows::UI::Xaml::Media::Imaging::BitmapImage^	  bitmapSr...
Resource                              Management                        • BitmapSource <=> DirectX/WIC                    ...
Direct 2D paths,                   nice stuff and bad stuff                        •   Nice stuff, it handles ink over bez...
Sharing API                                    challenges 	     RandomAccessStreamReference^	  imp	  =	  nullptr;	   	    ...
Sharing API                                          challenges                        •   Publisher side has no control: ...
Of course there is                               more                        • but we have only 30 minutes, so...sobota, 5...
.. to summarize                        •   C++ experience is much better than Win32/MFC/whatever old-school               ...
Thank you                        daniel.biesiada@ushine.plsobota, 5 stycznia 13
Upcoming SlideShare
Loading in …5
×

Windows 8 Dev, C# vs. C++ experience in practical projects

1,863 views

Published on

Slides from casual talk I gave during Appspirina X-mas 2012 edition in BlackSheep club in Warsaw/Poland (Dec 28th). Slides as well as the talk itself are very casual too, but I hope some of you may find the information valuable.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,863
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Windows 8 Dev, C# vs. C++ experience in practical projects

  1. 1. Windows 8 development C# vs. C++ practical experience Daniel Biesiada consultant and solution architectsobota, 5 stycznia 13
  2. 2. About mesobota, 5 stycznia 13
  3. 3. About me 13sobota, 5 stycznia 13
  4. 4. About me 13 7sobota, 5 stycznia 13
  5. 5. About me 13 7sobota, 5 stycznia 13
  6. 6. About me 13 7sobota, 5 stycznia 13
  7. 7. About me 13 7sobota, 5 stycznia 13
  8. 8. Two appssobota, 5 stycznia 13
  9. 9. In common • Windows 8 app targeting touch devices • Relatively simple (in scope ~= 1 month) • B2B model: • I’m just the dev and advisory guy • Product design, management and ownership => customer sidesobota, 5 stycznia 13
  10. 10. Top differences • Customer types: • Corporate vs. Startup entity • Technology: • C# & Xaml vs. C++, Xaml & DirectX • Design • Core „Metro” vs. 95% custom • In-app business model {free vs. paid}sobota, 5 stycznia 13
  11. 11. Top differences • Customer types: • Corporate vs. Startup entity • Technology: • C# & Xaml vs. C++, Xaml & DirectX • Design • Core „Metro” vs. 95% custom • In-app business model {free vs. paid}sobota, 5 stycznia 13
  12. 12. Team, process & communication • Roles and competences • think carefully about communication inside the team • especially when customer is part of the team • Tools: • for prototyping • for testing • for software and design requirements • „Agile” approach • short iterations vs. discussion about „imperfect product” • milestones and again appropriate communication with the customersobota, 5 stycznia 13
  13. 13. Designsobota, 5 stycznia 13
  14. 14. Designsobota, 5 stycznia 13
  15. 15. Designsobota, 5 stycznia 13
  16. 16. Designsobota, 5 stycznia 13
  17. 17. Design • When porting from Web/IOS: • New features (non existing on other platforms) • Snap View • Search, Share contracts • Understanding of Metro Design principles • If only possible everything asynchronous • (Data = Content) Driven Development • Expression Blend, tricky yet unavoidable and handy tool for design keen developers.sobota, 5 stycznia 13
  18. 18. CPP vs. C# experience • Easy part: • Xaml is the same and behaves the same, you can trust it and your skills • Great async support with PPL Tasks • still, remember about the Dispatcher • Challenges: • WinRT projection to C# != projection to C++ • DirectX mappings, then it’s cool too. • Understanding of share contractsobota, 5 stycznia 13
  19. 19. WinRT in C++ from C-sharpers’ • Basic Platform::String example: • In C++: • initializer, • cast to std::wstring • ::Begin, ::End iterators • array [] wchar_t indexer • Concat method & operators • AND THAT’S ALL WHAT YOU HAVEsobota, 5 stycznia 13
  20. 20. WinRT in C++ from C-sharpers’ • How to sub divide, search and execute other usual string operations? • cast to std::wstring and go with STL • Pros: great interaction with STL • Cons: stupid question rather: why the heck so basic object is so limited? • .. and there is more diffs like that, C#‘ers will catch them oftensobota, 5 stycznia 13
  21. 21. PPL Tasks   if  (file  !=  nullptr)   {     Platform::String^  m_imageFileName  =  file-­‐>Name;                           task<Streams::IRandomAccessStream^>  createStreamTask( file-­‐>OpenAsync(FileAccessMode::ReadWrite)); createStreamTask.then( [=](Streams::IRandomAccessStream^  randomAccessStream)  {   SaveImageToStream(randomAccessStream,  saveBackground); });   }sobota, 5 stycznia 13
  22. 22. PPL Tasks   loadAndRenderTask.then([=]()   if  (file  !=  nullptr)   {   {     Dispatcher-­‐>RunAsync(CoreDispatcherPriority::Normal,     Platform::String^  m_imageFileName  =  file-­‐>Name;       ref  new  DispatchedHandler([=]()                             {                       task<Streams::IRandomAccessStream^>  createStreamTask(   LoadWaitGrid-­‐>Visibility  = file-­‐>OpenAsync(FileAccessMode::ReadWrite)); Windows::UI::Xaml::Visibility::Collapsed;         LoadProgressRing-­‐>IsActive  =  false; createStreamTask.then( SpeedText-­‐>Visibility  =   [=](Streams::IRandomAccessStream^  randomAccessStream)  { Windows::UI::Xaml::Visibility::Visible;     SaveImageToStream(randomAccessStream,  saveBackground);         BackgroundButtonSpeed-­‐>Visibility  =   });   } Windows::UI::Xaml::Visibility::Visible; ...       }       }sobota, 5 stycznia 13
  23. 23. Dynamic Binding   and Cache Windows::UI::Xaml::Media::Imaging::BitmapImage^  bitmapSrc  =     ref  new  Windows::UI::Xaml::Media::Imaging::BitmapImage(); bitmapSrc-­‐>CreateOptions  =  BitmapCreateOptions::IgnoreImageCache;   bitmapSrc-­‐>UriSource  =  uri;   img-­‐>CacheMode  =  nullptr;   img-­‐>Source  =  bitmapSrc;   LoadListView-­‐>Items-­‐>Append(img); ...sobota, 5 stycznia 13
  24. 24. Dynamic Binding   and Cache Windows::UI::Xaml::Media::Imaging::BitmapImage^  bitmapSrc  =     ref  new  Windows::UI::Xaml::Media::Imaging::BitmapImage(); bitmapSrc-­‐>CreateOptions  =  BitmapCreateOptions::IgnoreImageCache;   bitmapSrc-­‐>UriSource  =  uri;   img-­‐>CacheMode  =  nullptr;   img-­‐>Source  =  bitmapSrc;   LoadListView-­‐>Items-­‐>Append(img); ...   ... file-­‐>DeleteAsync();   auto  item  =  (Image^)LoadListView-­‐>Items-­‐>GetAt(selected);   auto  src  =  (BitmapImage^)item-­‐>Source;   src-­‐>UriSource  =  nullptr;  //If  you  don’t  clear  it,  cache  stays          //even  if  all  IgnoreCache,  CacheMode  properties            //are  set  well     LoadListView-­‐>Items-­‐>RemoveAt(selected); ...sobota, 5 stycznia 13
  25. 25. Resource Management • BitmapSource <=> DirectX/WIC • Different Resolutions, DPI and Proportions • Xaml based positioning • Renderer’s rescale capabilities • Res/Snap/DPI Detectionsobota, 5 stycznia 13
  26. 26. Direct 2D paths, nice stuff and bad stuff • Nice stuff, it handles ink over bezier curves well! • It lacks of BitmapBrush for Bezier strokes • BitmapBrush can only fill closed paths • Sampling on your own: strokeGeometry-­‐>ComputePointAtLength(  ...  ) • Blending is kind of tricky: • ID2D1Image -> D2D1Bitmap tricks for erasersobota, 5 stycznia 13
  27. 27. Sharing API challenges   RandomAccessStreamReference^  imp  =  nullptr;     ComPtr<IStream>  stream;   StorageFile^  file  =  SaveToFileForSharing();   auto  p  =  file-­‐>Path;   ras  =  RandomAccessStreamReference::CreateFromFile(file);   e-­‐>Request-­‐>Data-­‐>Properties-­‐>Title  =  "Hello  from  Bord  by  Pixle";   //e-­‐>Request-­‐>Data-­‐>SetUri(  ...  );   //e-­‐>Request-­‐>Data-­‐>SetText(  ...  );   //e-­‐>Request-­‐>Data-­‐>SetUri(  ...  );     e-­‐>Request-­‐>Data-­‐>SetBitmap(ras);     e-­‐>Request-­‐>Data-­‐>ResourceMap-­‐>Insert("chalkImage.jpg",  ras);     e-­‐>Request-­‐>Data-­‐>SetHtmlFormat(HtmlFormatHelper::CreateHtmlFormat(L"<p>Look   what  Ive  drawn  with  a  very  cool  app  called  Bord:  <img  src=chalkImage.jpg></ p>"));sobota, 5 stycznia 13
  28. 28. Sharing API challenges • Publisher side has no control: • it exposes as many formats as possible (crazy tactic) • and hopes that consumer will interpret it well • Share JPG through SetBitmap and send it to Mail: • it converts it to PNG and (100kb JPG => 4.5MB PNG) • Messages accepts only URL • if you want to send there Facebook message with picture, you have to publish picture in the cloud first, you cannot upload it from local storage anyhow. • You expose something in a format • App „A” interprets it well, app B screwed the thing around in embarassing way. There is no option that you’d like to keep format exposed to „A” and block to „B”sobota, 5 stycznia 13
  29. 29. Of course there is more • but we have only 30 minutes, so...sobota, 5 stycznia 13
  30. 30. .. to summarize • C++ experience is much better than Win32/MFC/whatever old-school Windows development • Even though WinRT is in C++ (WRL) there is still lot of API inconsequence in projections. • for Xaml only apps, it’s 1st class citizen if the language is the preference, but you have to be patient to mix Cx/ISO and WinRT/ STL routines • (or wrap it well if project is bigger or you’re the architecture junkie) • DirectX 11.1 lacks of good documentation - if you lack experience, you’ll have to experiment a lot! • It integrates great with STL and COM (via WRL) • It has great async support (PPL)sobota, 5 stycznia 13
  31. 31. Thank you daniel.biesiada@ushine.plsobota, 5 stycznia 13

×