Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How easy is it gonna be to port my engine in .net?  (Read 5106 times)

0 Members and 1 Guest are viewing this topic.

ILostMyAccount

  • Newbie
  • *
  • Posts: 22
    • View Profile
How easy is it gonna be to port my engine in .net?
« on: November 01, 2015, 10:58:10 am »
Do you think is going to be difficult porting my C++/SFML engine to C#/SFML?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: How easy is it gonna be to port my engine in .net?
« Reply #1 on: November 01, 2015, 11:16:38 am »
Strictly speaking of SFML, no, the API is exactly the same. For the rest... it all depends on your skills ;)
Laurent Gomila - SFML developer

ILostMyAccount

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: How easy is it gonna be to port my engine in .net?
« Reply #2 on: November 01, 2015, 11:41:31 am »
Strictly speaking of SFML, no, the API is exactly the same. For the rest... it all depends on your skills ;)
Ok, thank you.

Do you think I'm gonna lose a lot as far as performance goes?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: How easy is it gonna be to port my engine in .net?
« Reply #3 on: November 01, 2015, 12:28:47 pm »
Nop. Time will be spent mostly in the OpenGL driver and in your engine's logic.
Laurent Gomila - SFML developer

mkalex777

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: How easy is it gonna be to port my engine in .net?
« Reply #4 on: November 01, 2015, 08:43:59 pm »
Strictly speaking of SFML, no, the API is exactly the same. For the rest... it all depends on your skills ;)
Ok, thank you.

Do you think I'm gonna lose a lot as far as performance goes?

I don't think that you will loss performance, at least you will not lose it significantly.
I'm using sfml.net and it works just fine, it shows up to 800-1400 fps for simple scenes. I even think that c++ version will works much worse, because c++ doesn't provides so simple and useful features.

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: How easy is it gonna be to port my engine in .net?
« Reply #5 on: November 01, 2015, 09:08:51 pm »
lolwut.

They provide the same exact functionality.

If we're going to attempt to be that pedantic, C# will be a tiny bit slower, due to running in a VM.

But that's being extremely pedantic. And depends on the code written. And a lot more things. And not really worth discussing. Because, for anything written at the level of SFML, speed shouldn't really be an issue.

mkalex777

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: How easy is it gonna be to port my engine in .net?
« Reply #6 on: November 01, 2015, 11:38:59 pm »
lolwut.

They provide the same exact functionality.

If we're going to attempt to be that pedantic, C# will be a tiny bit slower, due to running in a VM.

But that's being extremely pedantic. And depends on the code written. And a lot more things. And not really worth discussing. Because, for anything written at the level of SFML, speed shouldn't really be an issue.

I mean features provided with c# language and libraries. sfml api is the same of course.

And If we're going to be pedantic, both languages has it's own strong and weak areas. You're wrong that c# is a bit slower. Actually it depends on the code. Large array processing with simple operations is really a little slowly, because c# has runtime checks to prevent access out of memory index. But c# uses better memory allocation, so it works much faster than c++ when you make a lot of small size memory allocations.
And there are tricks that allows to eliminate index check overhead by using memory pointers in c#. But it's unsafe (like in c++).

And If we're going to be pedantic, c# is not running in VM. At least on windows it uses JIT (just-in-time) compiller to native code. The difference with c++ is that c++ compiled into code at the development stage. And c# compiled into code at runtim. So, JIT compiller knows exact type of target processor and can make optimizations which is impossible with c++.

JIT works in the following way. At the beginning all method pointers redirected to JIT, so if you call some method which is still not compiled, the execution will be passed to JIT compiller, it compile method into x86 (or x64 - depends on processor) opcodes and replace method pointer to compiled code, so next time it will be executed with no need for second compilation.
You can bypass JIT compilation at runtime by compile assembly with ngen tool. It compiles all code and place it into system cache, so it will startup with no need for compilation. It will reduce startup time.


C# provides more flexibility, it allows to write simple, clean and easy readable code with beautiful syntax. and on the other hand, it allows manipulations with pointers, and p/invoke to unmanaged code, it's unsafe, but you have option to eliminate bottlenecks.

Working with pointers in c# is little bit more complicated than in c++, because CLR performs memory defragmentation and your object may be mooved to another address. So there is need for object pinning. But acually using pointers is so rare case, you just don't need it in the most of the cases.

And the magic is that yo can run the same executable on windows and linux, on x86 and x64 system with no need to rebuild the application.

For example, I written a small game which works on windows and linux from the same executable file. And there is no any #if for specific platform
« Last Edit: November 02, 2015, 12:33:08 am by mkalex777 »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: How easy is it gonna be to port my engine in .net?
« Reply #7 on: November 02, 2015, 09:16:25 am »
Let's not turn this into a "C++ vs C#" thread please...
Laurent Gomila - SFML developer