[.net] C# and C++ in .NET the same?

Started by
7 comments, last by Codeka 15 years, 4 months ago
I read some where that all .NET apps are the same once compiled, so it basically comes down to choice of language. Is this true? I read that C++ was faster, how can it be any faster with .NET? Also, can .NET apps be decompiled?
Advertisement
The Visual C++ compiler does more aggressive optimization than that C# one (simply because it's more mature). When you compile with the /clr switch, the C++ compiler does emit MSIL which is "the same" as what the C# compiler emits.

.NET apps can be decompiled, yes. Reflector is the most well-known tool for doing it. It's even got add-ins that'll generate the complete project file and everything for you. There are also obfuscation tools that will let you obfuscate the generated IL bytecode, but they can only do so much...
Thank you. :)


So, there is now way to keep someone from stealing your code with .NET?
Quote:Original post by Rich76
Thank you. :)


So, there is now way to keep someone from stealing your code with .NET?


I'm no expert but...

Only as much as there is a way to stop someone stealing your C++ code. All code is reversable, it just depends on how much time and effort the hacker is willing to put into it.

There are some really good obsfucation tools for .net that require very crafty hackers to be able to get the MSIL code. It's not impossible, it just reduces the number of average Joe hackers that will actually succeed. But it only takes one to put your app on a torrent site.
Also you have to remember if anyone is going to be using C++ .NET they are most likely going to be mixing it with native C++ code.
Here is a bit more info on why C++ is faster. In a nutshell with more power or speed in this case comes more responsibility as they say!

This topic provides guidelines for reducing the effect of managed/unmanaged interop transitions on run-time performance.

Visual C++ supports the same interoperability mechanisms as other .NET languages such as Visual Basic and C# (P/Invoke), but it also provides interop support that is specific to Visual C++ (C++ interop). For performance-critical applications, it is important to understand the performance implications of each interop technique.
...
In other words, C++ Interop uses the fastest possible method of data marshaling, whereas P/Invoke uses the most robust method. This means that C++ Interop (in a fashion typical for C++) provides optimal performance by default, and the programmer is responsible for addressing cases where this behavior is not safe or appropriate.

[size="2"]Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe
Thank you all. Very helpful responses.
Quote:Original post by Rich76
Thank you. :)


So, there is now way to keep someone from stealing your code with .NET?

Don't protect your code by trying to be clever, protect it with the law. Wins every time :)

Quote:Original post by Jroggy
...protect it with the law. Wins every time :)


Except for the millions of games downloaded via torrents every day.
NetGore - Open source multiplayer RPG engine
Quote:Original post by Spodi
Quote:Original post by Jroggy
...protect it with the law. Wins every time :)


Except for the millions of games downloaded via torrents every day.


That's a different situation. We're talking about protecting the source code by obfuscation, not stopping people making copies of your program.

This topic is closed to new replies.

Advertisement