Русский New site

Advanced search

[ New messages · Forum rules · Members ]
Page 1 of 11
Forum » SpaceEngine » Development Status » Leveraging .NET with SpaceEngine (My arguments on why SpaceEngine & .NET Should Mix)
Leveraging .NET with SpaceEngine
form_d_kDate: Friday, 23.09.2016, 21:57 | Message # 1
Astronaut
Group: Users
United States
Messages: 68
Status: Offline
Okay, I know this may be dismissed offhand. HOWEVER, there are quite a few valid reasons why SpaceEngine would benefit from .NET.


  • Xamarian: Develop with a .NET language, have your application run natively on Macs, iPhone, Android devices, & Windows phones (err...). And with Xamarian forms, you can abstract the UI so that your UI remains compatible and consistent across platforms. Microsoft bought it last year and now Xamarian is free.
  • There are .NET libraries that allow managed .NET code to interop with unmanaged code. So you can write your codebase in a mixture of .NET languages (Visual C++, C#, F#, etc.) & unmanaged languages (C/C++, COM, etc.).
  • C# & OpenGL interoperability: there are about half-a-dozen libraries available to do just that.
  • LINQ/PLINQ: Allows you to query collections in a fast & cleanly written manner. It adds significant overhead and is non-performant for smaller collections, but for larger ones the improvement can be on an order of magnitude. This can even be improved upon using PLINQ, which allows a collection to be searched in a parallel manner.

    Here's an example C# LINQ query:

    Code
    habitablePlanets = from planet in CurrentQuadrant.Planets
                        where planet.Atmosphere.Contains(Oxygen).Percentage >  20
                        && planet.Atmosphere.Contains(Nitrogen).Percentage > 70
                        && planet.AverageTemperature <= 120 && planet.AverageTemperature > 32
                        && planet.AveragePrecipitation > 10
                        select planet;

    return habitablePlanets;


  • Sandcastle: Autogenerate professional-looking SDK documentation with code comments. I have used it extensively & it is invaluable when generating developer reference.
  • .NET CodeDOM library: Allows you to autogenerate code, including at runtime. Probably not useful to SpaceEngine but cool nonetheless.
  • Easy serialization: The data constract .NET libraries allow easy serialization/deserialization to XML/JSON by just adding an attribute above the classes & properties you want to serialize. This provides a very, very easy way to save program state.
  • C#'s excellent asynchronous programming functionality (using the async & await keywords), built-in event & exception handling, lambda expressions, nameof/typeof keywords, tuple return values, and deconstructors.

    Here's a deconstructor, new in C# 7.0:

    Code
    Atmosphere atmosphere, int averageTemperature, int averagePrecipitation = GeneratePlanet(generationArgs);

    p.s. The performance of code written in C# has improved substantially over the years. Well-written C# can be almost as fast as its C++ analog, and in certain scenarios even faster.


So yeah. I used to write unmanaged C/C++ code, and after using .NET libraries & C#, I never want to go back.


Edited by form_d_k - Friday, 23.09.2016, 21:58
 
SpaceEngineerDate: Saturday, 24.09.2016, 20:51 | Message # 2
Author of Space Engine
Group: Administrators
Russian Federation
Messages: 4795
Status: Offline
So you want to throw out entire SE course code (C++) and write a completely new one using C#? LOL.
And what is a purpose for that? This?

Quote form_d_k ()
Xamarian: Develop with a .NET language, have your application run natively on Macs, iPhone, Android devices, & Windows phones (err...). And with Xamarian forms, you can abstract the UI so that your UI remains compatible and consistent across platforms. Microsoft bought it last year and now Xamarian is free.


SE doesn't needs this because it uses it's own GUI rendering as a part of OpenGL engine.





 
form_d_kDate: Monday, 26.09.2016, 16:44 | Message # 3
Astronaut
Group: Users
United States
Messages: 68
Status: Offline
Quote SpaceEngineer ()
So you want to throw out entire SE course code (C++) and write a completely new one using C#? LOL.
And what is a purpose for that? This?


Oh no! Not at all. That would be a ridiculous suggestion to rewrite the entire engine.

I'm suggesting utilizing .NET in situations where it may be beneficial. And that doesn't mean using C#, just a .NET-enabled language. That would include Visual C++.

One example would be to use CodeDOM to parse your C++ source code & autogenerate SDK shims in Visual C++, C#, F#, JScript .NET, & IronRuby/Python. There is even an open source library to generate Java source code.

You could also use CodeDOM to utilize C++, C#, or another supported language as a scripting language, compiled & run in realtime.

And it's just some ideas I'm throwing out there into the wild. smile


Edited by form_d_k - Monday, 26.09.2016, 17:25
 
form_d_kDate: Monday, 26.09.2016, 17:20 | Message # 4
Astronaut
Group: Users
United States
Messages: 68
Status: Offline
p.s. And developing with .NET doesn't mean throwing any source code out, as .NET interoperability libraries exist for calling into unmanaged libraries.

There is also a compiler switch that can compile standard C++ code into a managed library. And while you may not want your release compiled into managed code, you could have a separate managed build that is only used to autogenerate developer documentation with Sandcastle.


Edited by form_d_k - Monday, 26.09.2016, 17:22
 
Forum » SpaceEngine » Development Status » Leveraging .NET with SpaceEngine (My arguments on why SpaceEngine & .NET Should Mix)
Page 1 of 11
Search: