C# to std C++ - linux

Red Squirrel

No Lifer
May 24, 2003
67,912
12,379
126
www.anyf.ca
I have this program that has a couple thousand separate C# scripts to it, and I've been pondering on how sweet it would be to be able to run it in Linux as C++ code. The languages are fairly similar and I think it could be converted. Just wondering if anyone has ever done this before, and what type of issues arrose?

I've also been looking at just making the app work in mono, but how bad is the overhead when using such emulation?
 

Tencntraze

Senior member
Aug 7, 2006
570
0
0
IIRC, Mono isn't emulation, but rather a port of the .NET framework itself, so theoretically shouldn't have any additional overhead than running it on Windows.

As for trying to port C# to unmanaged C++, that can definitely be quite a chore, as you will not be able to depend on the same libraries and may have to convert certain aspects of the code to the unmanaged equivalents (hard to say since I don't know what your scripts do/use)
 

Red Squirrel

No Lifer
May 24, 2003
67,912
12,379
126
www.anyf.ca
Yeah stuff like TimeSpan and Utility.Random would be different.

And what is managed/unmanaged code? I've heard these terms before but never really knew what they meant.

Also good to know mono is not emulation, figured it was just like using wine. So mono actually compiles the code as if it was native to that platform?
 

Tencntraze

Senior member
Aug 7, 2006
570
0
0
I haven't looked into Mono in quite a while, but I'd imagine that it does what the .NET framework does in that it compiles code into IL (so that VB, C#, etc) are essentially compiled into the same pseudo-machine code, and then compiled when run (JIT).

Managed code means that you don't have to worry about memory management as it is handled by the internal garbage collection mechanisms. Standard C++ you have to allocate the memory yourself and release it as necessary. It's hard to say specifically what you may need to do without more information, but don't expect this to be a trivial undertaking unless all the scripts are very straightforward.
 

Red Squirrel

No Lifer
May 24, 2003
67,912
12,379
126
www.anyf.ca
Ohh I see so having to use new/delete etc would be unmanaged as I'm responsible for making sure I don't leak memory, as oposed to the language/compiler doing it.

And yeah I would expect this to be a hard enough task. The hardest is porting the networking and multithreading stuff. Stuff like built in functions could simply just be rewritten or aliased. Some things like C# built in array lists would also have to be coded as add ons. Things like dictionary or hash tables would get more complicated, as I'm not sure if C++ even has those.
 

postmortemIA

Diamond Member
Jul 11, 2006
7,721
40
91
Originally posted by: RedSquirrel
Ohh I see so having to use new/delete etc would be unmanaged as I'm responsible for making sure I don't leak memory, as oposed to the language/compiler doing it.

And yeah I would expect this to be a hard enough task. The hardest is porting the networking and multithreading stuff. Stuff like built in functions could simply just be rewritten or aliased. Some things like C# built in array lists would also have to be coded as add ons. Things like dictionary or hash tables would get more complicated, as I'm not sure if C++ even has those.

Well STL for C++ has most of these, but format is different. I agree about memory management.

OP, you are looking at impossible task, and better approach would be to convert it to Java code. C++ and C# semantics are quite different, but C# and Java are similar.
 

Cooler

Diamond Member
Mar 31, 2005
3,835
0
0
If you?re writing it for cross platform it is best to stay away from MFC /.net if possible. When I write crossplatorm software that needs a GUI I use then GTKmm libraries for C++.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: Tencntraze
Managed code means that you don't have to worry about memory management as it is handled by the internal garbage collection mechanisms.
What you're describing is not "managed code", it's just garbage collection. Managed code is where you compile to byte code instead of machine code and a software runtime system like the clr or the jvm runs the byte code for you and makes sure you don't do anything nasty like accessing memory you shouldn't.

Originally posted by: Tencntraze
IIRC, Mono isn't emulation, but rather a port of the .NET framework itself
Technically it's a rewrite, not a port, but the difference isn't too relevant unless you're interesting in licensing.

Originally posted by: RedSquirrel
So mono actually compiles the code as if it was native to that platform?
Close. It compiles it to machine independent byte-code which, in theory should run on linux or windows on any hardware platform that has a working .net implementation, provided of course that you don't mix in unmanaged code or use platform specific libraries.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |