Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

C# for systems programming

Discussion in 'General Discussion' started by snoopbaron, Apr 28, 2014.

  1. snoopbaron

    snoopbaron

    Joined:
    Mar 21, 2009
    Posts:
    88
    Just came across this article about Microsoft's research project to extend C# for systems programming. If this ever sees the light of day, and Unity can take advantage of it, then it would be a perfect fit and a nice upgrade path for Unity games needing an extra boost. In the long term it would even be possible to have all of Unity written in this new extended dialect of C# without any of the overhead or unpredictability of managed C# and in a modern language that doesn't have to deal with all the legacy that modern C++ has inherited. If only it was already available :D

    http://joeduffyblog.com/2013/12/27/csharp-for-systems-programming/
     
  2. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    What's systems programming? You mean C# would use native libraries instead of .net ones? Like stdlib and stuff like that?
     
  3. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    Systems programming is the kind of low level programming that is close to the hardware, like kernel-code and device drivers. It's the kind of stuff where you would use C or C++ (or even D or Rust).

    The article the OP linked to talks about an experiment at Microsoft to make a flavor of C# that is suitable for systems programming. Starting by taking away garbage collection and replacing it with manual and deterministic memory management. It's been a while since I read that article, but I also believe it mentioned that they will attempt to keep as much as they can of the .NET library where it makes sense to do so.

    It's fascinating work, but I think us Unity devs would benefit more from something like .NET Native and a better garbage collector.
     
  4. SmellyDogs

    SmellyDogs

    Joined:
    Jul 16, 2013
    Posts:
    387
    I've thought about this before and would like to see something syntactically similar to c# but with manual memory management that runs straight on the CPU. Keep most things the same but include a delete keyword. Probably not as simple as all that to make though.
     
  5. thxfoo

    thxfoo

    Joined:
    Apr 4, 2014
    Posts:
    515
    This article https://nplusonemag.com/issue-19/essays/chat-wars/ states something I did not know: MS tried to implement Vista in C#, that is why it was 3 years late. (Interesting article about the "chat wars", MS vs AOL with ugly tricks like AOL using buffer overflows in their own product to lock out MS)

    I prefer my systems and drivers written in C++.
     
  6. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Personally, I definitely do not want Unity to switch to an unmanaged C#/C++ hybrid that requires twiddling with memory for everything. People who are obsessed with being "closer to the metal" can write C++ plugins already. I think it's kind of silly, but maybe it's because I'm old enough to remember when everyone said C++ was too slow and that we should all be using C to be closer to the metal, and when people thought C was too slow, and that we should all use ASM to be closer to the metal. I prefer to leave the metal inside my computer case under my desk.
     
    JesOb likes this.
  7. snoopbaron

    snoopbaron

    Joined:
    Mar 21, 2009
    Posts:
    88
    I think Microsoft knows that better than anyone. But you cannot compare using C# that has not been extended for systems work with one that has. This new project would allow them to have the same control as with C++ but in a better designed and more modern language. If done right drivers in this new extended variant of C# could perform as well as their C++ counter parts but suffer from fewer segfaults thanks to a much better type system.

    Manage code still has its advantages so ideally they would provide both and since both languages would largely overlap supporting both might be quite feasible. Personally, for my current and past projects even the old version of mono we currently have has met all my needs, but I thought I'd share this since there has been so much talk about what Unity might do going forward.