Coffeehouse Thread

38 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Native code development coming to Windows Phone?

Back to Forum: Coffeehouse
  • User profile image
    cbae
  • User profile image
    Blue Ink

    @cbae: if that's true, it would be interesting to know what kind of API would be exposed. A subset of WinRT, maybe?

  • User profile image
    magicalclick

    Does winRT count? To my understanding , winRT is managed environment with unsafe backend. I haven't done c++ on winRT, but, it should be managed. Just my assumptions.

    Leaving WM on 5/2018 if no apps, no dedicated billboards where I drive, no Store name.
    Last modified
  • User profile image
    felix9

    @magicalclick: No, WinRT is not a managed tech, its just COM ABI, WinRT components can be created in native or managed code, and consumed in native, managed or js code. If you consume a native code WinRT component with native code, then its purely native, no CLR at all.
    Just rewatch those BUILD videos Smiley

  • User profile image
    magicalclick

    @felix9:

    I didn't watch it Tongue Out. Not sure why they want to do that. This means app could be unsafe.

    Leaving WM on 5/2018 if no apps, no dedicated billboards where I drive, no Store name.
    Last modified
  • User profile image
    cbae

    , magicalclick wrote

    @felix9:

    I didn't watch it Tongue Out. Not sure why they want to do that. This means app could be unsafe.

    That's fine by me. I like to live on the edge.

  • User profile image
    Charles

    , magicalclick wrote

    To my understanding , winRT is managed environment with unsafe backend. I haven't done c++ on winRT, but, it should be managed. Just my assumptions.



    WinRT is not managed (other than, say, by the operating system...). Please see the detailed information from BUILD to learn more.

    C

  • User profile image
    felix9

    Why C++? or, Why Going Native ? or, Why on WP ? Smiley

    For raw performance apparently, and reusing existing code maybe.

    Plus, immersive apps runs in an AppContainer sandbox, only have access to a limited set of API, so at least its 'safe' to the system environment, your code can only break yourself.

  • User profile image
    Maddus Mattus

    Ugh, time to learn C++ I see,..

    I've been spoiled rotten with .Net anyways Wink

  • User profile image
    magicalclick

    How much performance you can get by moving from C# to C++ in WinRT? I thought WinRT makes C# much faster by using unsafe backend? What about 3D acceleration comparison between C# and C++ where real intense calculation is needed in typical apps?

    Just want to see if I should consider C++ in favor of enough performance gains. Thank you.

    Leaving WM on 5/2018 if no apps, no dedicated billboards where I drive, no Store name.
    Last modified
  • User profile image
    Maddus Mattus

    @magicalclick: well,.. ofcourse C++ is faster then C# because it eliminates a layer and no need to do garbage collection. But how much faster, really can't tell.

    More importantly, how much more time am I going to spend on writing C++ applications compared to C# applications? Can we still hack together a phone app in 6 hours like Hanselmann? Or am I going to spend a gazillion hours writing low level stuff?

     

  • User profile image
    wkempf

    , Maddus Mattus wrote

    @magicalclick: well,.. ofcourse C++ is faster then C# because it eliminates a layer and no need to do garbage collection. But how much faster, really can't tell. 

    Sorry, it's not "of course C++ is faster", nor does garbage collection automatically mean a performance hit. In fact, in many scenarios GC means a performance benefit. A really great series of articles highlighting the performance differences between C++ and C# can be found here:

    http://blogs.msdn.com/b/ricom/archive/2005/05/10/416151.aspx

    Raymond had to do some wild optimizations that you're normal C++ developer simply isn't going to do to win this shoot out.

    Like most language comparisons, you can't draw any conclusions. One language may beat out another in one class of programs and get it's lunch handed to them in another, so most of these shootouts are pointless. However, the belief that C++ is automatically faster is obviously false. Further, the belief that GC automatically causes performance problems is also false. That being said, C++ being so low level does mean that with effort you should always be able to get the most performance out of an application. The question is, is the amount of effort worth it, and there's no universal answer to that question.

  • User profile image
    Dr Herbie

    @wkempf: +1

    I remember reading an article years ago showing how under certain circumstances VB6 was faster than C++ (mainly because the VB code simply interfaced to VB runtime libraries that were written in hand-optimised assembly).

    I don't think we can ever assume that one specific language is automatically faster than any other.

    Herbie

  • User profile image
    TexasToast

    I dont get why anyone would now all of a sudden go to C++.  Wait till you see some of the ugly syntax that will be exposed to do references and memory management.   C# is here to stay.   In fact it gets better because the .Net layer goes away and you program in C# calling WinRT.   WinRT is just a layer of a type of Pinvoke to make C# calls look native.   I was a C++ programmer for 20 years and I am not going back to it.   We need to move forward not backwards folks.

  • User profile image
    felix9

    Ah... the C# vs. C++ thread again, sigh Devil

    OK, if you are already a C# guy now, you probably dont need to 'go to C++', C# is fine.

    But for those C++ guys its the opportunity to look at WP platform, right ?

    GC maybe good for 99% of scenarios, but for some games where everything runs at 25-30 fps with no tolerance to pauses or frame-droppings, GC is not so good, especially on a portable device, XNA developers are doing their best to avoid GCs.

  • User profile image
    Maddus Mattus

    @wkempf: I stand corrected.

    Thanks for the info!

  • User profile image
    BitFlipper

    I don't think going back to C++ is the right thing to do. Instead of wasting resources adding C++ support to WP, do the following instead:

    • Improve C# performance by focusing on areas that contain a lot of math. This could be DSP, graphics intensive algorithms, AI etc. When I say improve performance, I mean that it is possible for a human to create very fast hand crafted low-level assembly from the IL itself, so why can't an IL->native code compiler do it? However the JIT/AOT compiler is not optimized for that, instead it is a compromise between fast compilation and fast resulting code. And AFAIK, it does not currently make use of features like SIMD etc. My point is that I think there is a lot of room to optimize the JIT/AOT compilers to create faster code. There should be a special AOT compiler that could potentially take a long time to copile the code to native code for the selected target CPU. Basically a special Release build that creates highly optimized precompiled native code.
    • Improve the ability to run "unsafe" code on WP so that certain algorithms can be sped up more by foregoing bounds checks etc. Better yet, improve the compiler's ability to automatically detect when certain checks can be removed and therefore speeding up array access etc.
    • Do more method inlining. AFAIK, right now only trivial methods are inlined. Yes you need the actual method when you want to do reflection, but there is no reason why you can't still keep the original method around for reflection purposes while also inlining it at the same time in other places. Of course it affects things like exception handling (you'd get a wrong call stack when an exception gets thrown while inside inlined code, but it is a small price to pay).
    • Improve the GC by making it (more) concurrent/incremental so that there are no large GC cycles that could cause unexpected freezes. Also add features to the GC such that the developer can fine-tune it based on the particular application. For instance, in a 3D game, it is more important to have no long GC cycles, but it is OK to lose 5% performance to a concurrent/incremental GC. Java has a more flexible GC and I don't see why .Net can't also have a more scalable/tweakable GC.

    As far as the problem with having to port existing C++ libraries to C#, yes it is true but I don't think it is such a big problem. For instance, the excuse used for why the Unreal 3D engine has not been ported to WP is that it is C++ code. However Epic had no problem porting it to iPhone, and I'm sure converting it to Objective-C wasn't trivial. They will do a WP version if there is enough demand.

  • User profile image
    Charles

    It's not about OR. It's about AND. Use the tool that best suits your needs and skillset. Nobody's saying "you have to learn C++"... We've never stated this. 

    Of course, there's nothing wrong with learning a new language, especially if you need to program at the infrastructure level, close to the underlying hardware; to push computational boundaries without having to work through (if even possible) the boundaries of some higher level virtual machine runtime environment (like the CLR). With C++, you get to use modern, high level programming abstractions to generate very efficient machine code. That's a very good thing for hopefully obvious reasons. It's a tool. It's one programming language. It's not everything... It also happens to be a great tool for writing native code. It's very powerful, but with power comes complexity (and some warts). C++11 pushes C++ into modern times. I highly recommend you watch Herb's "Why C++?" talk from C++ And Beyond 2011. It's well worth your time and should clear up this OR confusion...

    You'll learn all about what this actually means - "modern C++" - in Bjarne's keynote and in several of the other GoingNative 2012 sessions.

    C

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.