• Advertisement
Sign in to follow this  

.NET vs clear C++ with WinAPI in game programming

This topic is 3953 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

Hi everyone, could you tell me what is better - programming in .NET or in clear C++ using WinAPI and DirectX/OpenGL? I heard that many people are migrating to .NET but why? C++ is faster than .NET library. Are there some new libraries for game programming?

Share this post


Link to post
Share on other sites
Advertisement
.NET has something like 98, or 99% of the speed of C++, so for most programming tasks, including most game development, the speed is not much of an issue at all. Also, I hear that the DirectX interface for Managed (.NET) programs is much cleaner.

C++ can be run as a .NET, managed, program, by the way.
Edit: never mind that last statement, you already know that, judging by your use of the word 'clear'.

Share this post


Link to post
Share on other sites
Because C# is a joy to work with. The IDE is leaps and bounds better. You spend far less time fighting the language and more time writing the game.

Share this post


Link to post
Share on other sites
The .Net languages are much, much more productive in general, for a few reasons: no manual memory management, a very rich library, and certain languages (notably C#) have support for first-class functions, which makes certain kinds of programming problems much easier to solve.

I prefer C# for almost all of my utilities and tools these days, unless it's some bit-twiddling or something that I can more comfortably do in C++.

Share this post


Link to post
Share on other sites
I second the C#-praising, but for completeness, .NET comes with a few considerations.

If your target audience is today's Windows user, then there's no contest. However, if you need to accommodate older versions of Windows (pre .NET framework) or other operating systems, then these managed languages will be of no use to you. In particular, for true cross-platformity, the most popular choice is C++ with OpenGL.

Admiral

Share this post


Link to post
Share on other sites
IMHO from a marketing perspective until most of your target audience have the .NET framework already installed by default (i.e. All running Windows Vista) then it's a question of whether you'd like to slap a .NET Framework 2.0 requirement on your product (Though you could mitigate this by installing the framework alongside your game's installation).

As for performance (not to be confused with productivity), if it's a big issue for your game genre then go for C++, otherwise, perhaps you can raise the bar on your game's hardware requirements? :)




Share this post


Link to post
Share on other sites
What has .NET specially that C++ doesn’t have - I have some kind of libraries in mind. What library has .NET which can help in game programming?

Share this post


Link to post
Share on other sites
XNA

Generally both C# and C++ have lots of existing libraries you can pick from for just about anything. You can write games in both languages. You'll just save lots of time if you use C#. I've made the switch in last december and I won't ever go back to C++ unless I get paid lots of money for it ;)

Share this post


Link to post
Share on other sites
Quote:
Original post by Eternal
XNA

Generally both C# and C++ have lots of existing libraries you can pick from for just about anything. You can write games in both languages. You'll just save lots of time if you use C#. I've made the switch in last december and I won't ever go back to C++ unless I get paid lots of money for it ;)


I switched to C# too since January. I really don't understand why I didn't do that earlier on. The advantage you gain against keeping up with C++ is just to big to ignore. The speed advantage you lose using C# + .NET is just trivial now, especially with the incoming Multi-core technologies.

There are some cases which I still need to use C++ to gain access to certain libraries only available to C++, but then I just write a wrapper and make it another CLR assembly :D (Reusability FTW).

Let even alone the advantage which let you work together with people who only program in Visual Basic for example.

Regards,

Xeile

Share this post


Link to post
Share on other sites
Quote:
Original post by TheAdmiral
I second the C#-praising, but for completeness, .NET comes with a few considerations.

If your target audience is today's Windows user, then there's no contest. However, if you need to accommodate older versions of Windows (pre .NET framework) or other operating systems, then these managed languages will be of no use to you. In particular, for true cross-platformity, the most popular choice is C++ with OpenGL.

Admiral


Someone's never heard of mono :)

I've had great success using SDL and OpenGL in c# on linux and mac os x.

At the moment, if you really plan things carefully, you can write games that work in windows xp (and whatever versions support .net 2.0), linux, mac os x, and the xbox 360.

Share this post


Link to post
Share on other sites
I agree with TheAdmiral if your target operating system is windows xp or newer than, C# is clearly the way to go. However, if you want to create at code base that can easily be ported or can support other platforms (win 98 ,95,Linux,Mac, PS2,etc...) then c++ is the way to go. There is a reason why the majority of professional games and graphics engines are written in C++.

And yes I have herd of MONO but that is like saying DirectX/Windows API is portable because WINE exists

Share this post


Link to post
Share on other sites
Quote:
Original post by blackcloak
I agree with TheAdmiral if your target operating system is windows xp or newer than, C# is clearly the way to go. However, if you want to create at code base that can easily be ported or can support other platforms (win 98 ,95,Linux,Mac, PS2,etc...) then c++ is the way to go.


The .Net framework 2.0 runs on windows 98 and up. It's just vs.net 2005 that's restricted to a few platforms. So, sure, if you're going to develop with vs.net you're limited to xp sp2, but your final game will still run on most versions of windows. But who the heck still runs windows 98 these days anyways? :P . Can't say I've seen many games support that platform lately either. Mentioning consoles is pointless as 99% of people here will never get to develop for them, not counting the xbox 360 and xna of course (which is a point in favor of c# :P ).

Quote:
Original post by blackcloak
There is a reason why the majority of professional games and graphics engines are written in C++.


Yeah, the mistaken tradition some people have that c++ is the only REAL language. And because professional studios can afford to hire people that can optimize the c++ code.

Quote:
Original post by blackcloak
And yes I have herd of MONO but that is like saying DirectX/Windows API is portable because WINE exists


I don't get the point of this argument. When using mono in linux, you're not running inside an emulator, any more than running the .net framework in windows is. You're pinvoking calls directly to the appropriate libraries (libSDL.so, libGL.so, etc), except in c# instead of c++. This is totally different from running inside wine. When running under the mono runtime, you're still low level enough that you need to account for differences between platforms. Unlike wine, which is designed to 100% emulate windows (yeah yeah, I know what wine stands for, but if it looks like a duck, and quacks like a duck, it's a duck :P ).

Regardless, here's some thoughts directed at the OP:

Yes, TheAdmiral and blackcloak are correct that major developers don't use c# for their games (though a rapidly growing number of them are using it for tools). But I don't work for a major developer, I suspect you don't work for a major developer, and I'm sure 99% of the other people here don't either.

I'm always the first to admit that you probably wouldn't want to write Half Life 3 in c#. But most people here are hobbyists or writing relatively simple indie games. If you're just learning, or just want a new hobby, or to write a simple game for profit, speed should be one of your last concerns when choosing c#.

As a hobbiest, the speed will never be an issue for you, you'll be able to crank out code more efficiently and easily, and if you're carefull to abstract away your rendering and windowing code your game will run on several platforms. Sounds pretty reasonable to me.

[Edited by - gharen2 on March 29, 2007 7:05:30 PM]

Share this post


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

  • Advertisement