C
C#ā€¢15mo ago
MadMan

ā” Is it efficient and worth doing?

[newb alert. Please explain everything so that newb a.k.a. me understand lol] Is it efficent I to write all the window and renderer code in C++/C, compile it into dll library and use dllimport/LibraryImport to import and use the methods? How would I make it so C# code interacts with the window generated/made by the C code?
10 Replies
MadMan
MadManOPā€¢15mo ago
Also If its not efficent is there more efficent way to do something like this? And yes I'm aware that things like Silk.NET exist but I wanna do it for fun
Will
Willā€¢15mo ago
this is basically what Unity does I believe, so yes it's possible and i think the only way of interacting with a C/C++ library for window interaction it's likely you could pass a handle to the C# side and do things with it there, but I don't know what you want to do specifically
MadMan
MadManOPā€¢15mo ago
But the main question is, is that the most efficent and easy way? Is there more efficent way of doing it which will not take too long?
Will
Willā€¢15mo ago
pinvoke/dllimport would be the easiest & simplest way yes
Angius
Angiusā€¢15mo ago
I mean, sure, you can do it, but... why? You might save a few CPU cycles here and there by using C++ or C instead of C#, but is it worth it? Are you running into some actual bottlenecks?
Will
Willā€¢15mo ago
but I wanna do it for fun
šŸ¤·ā€ā™‚ļø
SWR
SWRā€¢15mo ago
For window interaction, C# doesn't add enough of a significant extra cost to warrant doing this. However, yes it is possible. If you're doing it for fun, go ahead, but the practicality of this is questionable, and I believe the technical debt to your app that you are introducing would be higher than the invisible gains you are receiving.
MadMan
MadManOPā€¢15mo ago
Or would it be better I to build all the graphic and rendering framework on C++ and use C# only for program logic and calls?
SWR
SWRā€¢15mo ago
That's a reasonable choice imo
Accord
Accordā€¢15mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity. Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server