• Advertisement
Sign in to follow this  

.NET, is it better?

This topic is 4281 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I've noticed that many people program in .net (C++.net or c#). What i was wondering is what is better about C++.net than normal native C++? And is C# not a lot slower than native C++ since games can't afford a loss of performance.

Share this post


Link to post
Share on other sites
Advertisement
.NET (among a few things) provides a very large library of code to draw from, and C# isn't really slow.

Share this post


Link to post
Share on other sites

C# and C++/CLI can be almost as fast as C++ if properly written. I would recommend getting a profiler that will profile your managed code to signal these performance gotchas clearly.

I have a newtork library for C++ that i have written based on the API for C# for sockets and other network realted tasks. IMHO, C# performs very well.

All that said. I still develope games in C++. The number of 3rd Party Libs and C++ is my "native tougue" are my only legit reasons.

FYI and not to gloat. I wrote a gamespy replacement in C# for a multiplayer game written in C++ so I have seen both sides.

Share this post


Link to post
Share on other sites
in short, yes .NET is better.
you only have to worry about speed if you're making a AAA title or you have a VERY VERY intensive Physics, AI, and/or rendering framework going. 98% of people don't. Even though they believe they do.

Share this post


Link to post
Share on other sites
Thanks for all the replies! And what is different between native C++ and managed C++? Is there like a difference in syntax for example?

Share this post


Link to post
Share on other sites
Benchmarks show that MC++ is much slower than anything else, It is not even recommended by MS unless you want to port some C++ code to .NET .

C# is decently fast, but it is not faster than C++ , the difference is not noticeable as long as you handle your memory usage with care.

.NET is not better than native it is not worse either, it is just something different. Different things for different objectives

Share this post


Link to post
Share on other sites
A while ago I took my native C++ game and profiled it and then ported it to Managed C++ and profiled it again, it was about 5%-10% slower, which isn't bad at all considering my development time is significantly decreased with MC++. Granted, if you're making the next Quake 3 then 10% is probably inexcusable, but pretty much everyone here is making amateur or sideline games and 10% isn't a big deal. I also ported and profiled a C# program to MC++ and found no difference. I prefer C# over MC++ since C#'s syntax is a little more clean since it doesn't have to have backwards support for an old syntax, although MC++'s syntax still isn't bad. However, there are some libs that are very useful that only work with C++, so my main game development is with MC++ for the time being.

Quote:
And what is different between native C++ and managed C++? Is there like a difference in syntax for example?

Yes, there are some differences like a class has to be declared with 'ref' or 'value' in front of it and managed pointers have a '^' instead of a '*' and you use gcnew to create memory instead of new. Also namespaces play more of a role. If you already know C++ then learning MC++ or C# won't be too hard and will only take you a couple of days, Google for some tutorials.

Share this post


Link to post
Share on other sites
Managed C++ is a hack. An ugly, ugly hack. If you plan to use .NET and you're writing new code, avoid Managed C++ and just go to C#.

Managed C++ is only useful in big enterprisey applications that would be too expensive to port to another language, so they write Managed extensions to hack the program to work with newer C# and VB.NET code.

Share this post


Link to post
Share on other sites
Quote:
Original post by JBourrie
Managed C++ is a hack. An ugly, ugly hack. If you plan to use .NET and you're writing new code, avoid Managed C++ and just go to C#.

Exactly how is it a hack and how is it ugly? I'm genuinely curious since I quite like it. :)

Share this post


Link to post
Share on other sites
Quote:
Original post by JBourrie
Managed C++ is a hack. An ugly, ugly hack. If you plan to use .NET and you're writing new code, avoid Managed C++ and just go to C#.

Managed C++ is only useful in big enterprisey applications that would be too expensive to port to another language, so they write Managed extensions to hack the program to work with newer C# and VB.NET code.

It's funny that everytime someone mentions C++ the first attribute associated with it is "hack" [lol]

Share this post


Link to post
Share on other sites
Quote:
Original post by pongping
And what is better to use, Java or C#?


Neither. They both have advantages and disadvantages. It really depends what you are trying to do.

Share this post


Link to post
Share on other sites
Quote:
Exactly how is it a hack and how is it ugly? I'm genuinely curious since I quite like it. :)


Well you have managed C++ and C++/CLI which is the improved version of it, personally I don't like either of them however I can see how people could like the C++/CLI syntax. The MC++ syntax on the other hand is just plain ugly.

As for why it's a hack, they just took C++ and bolted on the necessary stuff so that you can use it with the .Net framework and it just feels a little bodged. IMO everything's a lot cleaner and elegant when you build a language based around utilizing the .Net framework from the ground up (See C#). Of course C++/CLI and Managed C++ do have their uses, mainly when you have an existing C++ codebase you want to port to .Net or when you need to do some interop that's a bit more complex than calling C-style functions in DLLs (e.g. if you had an engine written in C++ that was exposed via several C++ style class interfaces you'd probably want to write the interop code for it in C++/CLI as it allows easy mixing of managed and unmanaged code).

Share this post


Link to post
Share on other sites
Quote:
Original post by pongping
And what is better to use, Java or C#?

if you want an intuitive hierarchy when it comes to find libraries and using classes: C#

if you want cross-platform capability and be able to build an app from scratch: Java*

*to every one else: I've seen C# files and I've coded in Java. I can't see myself creating a C# app from scratch especially with all the partials and .resx and eesh. too much.

Share this post


Link to post
Share on other sites
Quote:
Original post by Alpha_ProgDes
I can't see myself creating a C# app from scratch especially with all the partials and .resx and eesh. too much.


The resx and partial stuff isn't required, and you probably only encountered it because that's what the Windows Forms project template makes for you. You can create windows apps from scratch with a single .cs file and nothing else.

Share this post


Link to post
Share on other sites
Quote:
Original post by Alpha_ProgDes
*to every one else: I've seen C# files and I've coded in Java. I can't see myself creating a C# app from scratch especially with all the partials and .resx and eesh. too much.

Or you could, y'know, use the Forms Designer. Unless you think dragging and dropping constitutes "too much".

Share this post


Link to post
Share on other sites
Quote:
Original post by Monder
Quote:
Exactly how is it a hack and how is it ugly? I'm genuinely curious since I quite like it. :)


Well you have managed C++ and C++/CLI which is the improved version of it, personally I don't like either of them however I can see how people could like the C++/CLI syntax. The MC++ syntax on the other hand is just plain ugly.

First I should note that I'm referring to C++ with CLI support with the new syntax as MC++, since it has the same functionality as the old syntax, just cleaner. I personally think just sticking in a few new key words doesn't make make the language ugly. Really, it's almost exactly the same, just the class specifiers and pointers have changed, otherwise, it's exactly the same as native C++ syntax-wise.

Quote:
As for why it's a hack, they just took C++ and bolted on the necessary stuff so that you can use it with the .Net framework and it just feels a little bodged. IMO everything's a lot cleaner and elegant when you build a language based around utilizing the .Net framework from the ground up (See C#). Of course C++/CLI and Managed C++ do have their uses, mainly when you have an existing C++ codebase you want to port to .Net or when you need to do some interop that's a bit more complex than calling C-style functions in DLLs (e.g. if you had an engine written in C++ that was exposed via several C++ style class interfaces you'd probably want to write the interop code for it in C++/CLI as it allows easy mixing of managed and unmanaged code).

I will grant you it technically may be a hack, but a hack implies a shoddy fix to something which I don't think MC++ is at all. I program a lot in C# and MC++ and really the only thing I can think of right now that C# does a better job of, is with delegates and class declarations, IE, you don't have to have header files which can save time, on the other hand, sometimes headers can make browsing large classes easier. But the fact MC++ is totally backward compatible with thousands and thousands of useful libs while C# has very limited support so far, I will gladly give those features up. Also, although you can 'import' DLL's into C#, function by function, it's extremely time consuming and quite hackish if you ask me. Also, MC++ is a tiny bit faster than C# because C++ has a better code optimizer, you'd think if something was hacked in it would run quite a bit slower than a language that was built from the ground up around .NET and CLR.

As I said earlier, I prefer C# overall since it's syntax is a tad bit better and MSVC#'s intellisense works better, I don't think those outweigh the advantages of MC++, which is mainly the support of tons of great libs.

Share this post


Link to post
Share on other sites
Quote:
Original post by Nypyren
Quote:
Original post by Alpha_ProgDes
I can't see myself creating a C# app from scratch especially with all the partials and .resx and eesh. too much.


The resx and partial stuff isn't required, and you probably only encountered it because that's what the Windows Forms project template makes for you. You can create windows apps from scratch with a single .cs file and nothing else.

Ahhh, I see. It's a Designer thing. I thought it was mandatory. Oops. Thanks for the enlightenment. [smile]

Quote:
Original post by kSquared
Quote:
Original post by Alpha_ProgDes
*to every one else: I've seen C# files and I've coded in Java. I can't see myself creating a C# app from scratch especially with all the partials and .resx and eesh. too much.

Or you could, y'know, use the Forms Designer. Unless you think dragging and dropping constitutes "too much".

Silly moderator. I know that. I was strictly talking about building an app from scratch, not building one in general [razz] [grin]

Share this post


Link to post
Share on other sites
Quote:
Original post by Alpha_ProgDes
if you want an intuitive hierarchy when it comes to find libraries and using classes: C#

if you want cross-platform capability and be able to build an app from scratch: Java


OBLIGATORY MONO INFO:

The Mono Project provides a cross platform, open source implementation of the EMCA standards for CLR... .NET is the same thing with some extra MS stuff, but even some of that is being implemented for Mono (development for a Windows.Forms implementation, for example, is well under way and worked when I tried to compile/run a VERY simple .NET app).

Share this post


Link to post
Share on other sites
Quote:
Original post by Alpha_ProgDes
Silly moderator. I know that. I was strictly talking about building an app from scratch, not building one in general [razz] [grin]

So was I! Doesn't your definition of "from scratch" include the tools at hand? If I asked you to "build a house, from scratch", would you start by planting some acorns so that you can grow trees for the wood you'll need later?

Share this post


Link to post
Share on other sites
Quote:
Original post by kSquared
Quote:
Original post by Alpha_ProgDes
Silly moderator. I know that. I was strictly talking about building an app from scratch, not building one in general [razz] [grin]

So was I! Doesn't your definition of "from scratch" include the tools at hand? If I asked you to "build a house, from scratch", would you start by planting some acorns so that you can grow trees for the wood you'll need later?

Ok, ok. I meant not using the Visual IDE (ie. drag and drop). As in straight coding everything by hand. geez [smile]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Alpha_ProgDes
Ok, ok. I meant not using the Visual IDE (ie. drag and drop). As in straight coding everything by hand. geez [smile]


How many Java developers do you know that don't use a Visual IDE? I work with it for about 5 years and I have met so far 0 developers that do it.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by smitty1276.NET is the same thing with some extra MS stuff...


OBLIGATORY MONO INFO:

".NET is the same thing with some extra MS stuff" <

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by smitty1276.NET is the same thing with some extra MS stuff...


OBLIGATORY MONO INFO:

".NET is the same thing with some extra MS stuff" <

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Quote:
Original post by Alpha_ProgDes
Ok, ok. I meant not using the Visual IDE (ie. drag and drop). As in straight coding everything by hand. geez [smile]


How many Java developers do you know that don't use a Visual IDE? I work with it for about 5 years and I have met so far 0 developers that do it.

Really? Academics suck.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement