C# vs C++/CLI : Is there any reason not to use C# for Windows applications?

Page 3 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

Cogman

Lifer
Sep 19, 2000
10,284
138
106
All I am saying... is that there are plenty of 'insert your own language here' compilers to javascript. So you can write in one language for code maintenance, and then run it in a javascript engine.

That is all. I don't care about, nor am I ignorant of, ASM.js.

I guess I don't get what you were getting at. My point was ASM.js expands the number of "compile to javascript" languages significantly. Pretty much anything that compiles to the LLVM now can be turned into javascript. (well, honestly, emscripten made this happen before asm.js came around. ASM.js is really just the formalizing of emscripten output).
 

Savatar

Senior member
Apr 21, 2009
230
1
76
To answer the original question, why wouldn't you use C#, there are lots of system calls that have no equivalent in C# (at least yet)... so in those cases you have to use C++ (which is what a lot of the Windows System APIs use). Similarly, if there's any application that makes heavy use of COM interops, it may make more sense to use C++ anyway.

C# is a lot more convenient for most things, but it is also easy to disassemble, and it is significantly more difficult to reverse engineer a C++ application as well (though still not impossible). It doesn't take much effort to reverse most of your source code if you write a C# application, even with some obfuscation.

As some people have pointed out, for some time-sensitive programs C# may not be a good solution since it is slower than C++ (because it doesn't compile directly, it has to go through the .NET CLI VM).

Also as some other people pointed out, there could also be some portability reasons to choose C++ over C#, even though Linux does have Mono packages which support most C# features.