Sign in to follow this  
hamo32

.net or c++

Recommended Posts

hamo32    122
greetings game comunity! I was wondering on your opinion on .net and c++. Ive never programmed in .net before because im a c++ user, but ive been always wondering wich one is better when programming games. Please share your opinions on this topic. thanks

Share this post


Link to post
Share on other sites
nilkn    960
Alright, before this thread gets out of hand (as it inevitably will) I feel this should be said. C# is only on average 2% less fast than C++. There are quite a few commercial games written in C#, and there is a port of the OGRE engine which often runs faster than it's C++ counterpart. So it doesn't matter which language you use. It's really that simple. The only exception would be if you're writing a literally top of the line 3D renderer (unlikely), and it will power a AAA blockbuster title (also unlikely), so just choose which one you more prefer based on language syntax, that sort of thing.

Share this post


Link to post
Share on other sites
Quote:
Original post by nilkn
Alright, before this thread gets out of hand (as it inevitably will) I feel this should be said. C# is only on average 2% less fast than C++. There are quite a few commercial games written in C#, and there is a port of the OGRE engine which often runs faster than it's C++ counterpart. So it doesn't matter which language you use. It's really that simple. The only exception would be if you're writing a literally top of the line 3D renderer (unlikely), and it will power a AAA blockbuster title (also unlikely), so just choose which one you more prefer based on language syntax, that sort of thing.


you know... posts like this make me wonder, why does it seem like 90% of indy game developers use C++? i mean, is it just out of ignorance? or do these people really enjoy managing memory, finding heap corruptions, finding other bugs that couldnt happen in a managed environment, writing crap loads of code themselves, etc...

Share this post


Link to post
Share on other sites
CodeTitan    258
Quote:
Original post by graveyard filla
Quote:
Original post by nilkn
Alright, before this thread gets out of hand (as it inevitably will) I feel this should be said. C# is only on average 2% less fast than C++. There are quite a few commercial games written in C#, and there is a port of the OGRE engine which often runs faster than it's C++ counterpart. So it doesn't matter which language you use. It's really that simple. The only exception would be if you're writing a literally top of the line 3D renderer (unlikely), and it will power a AAA blockbuster title (also unlikely), so just choose which one you more prefer based on language syntax, that sort of thing.


you know... posts like this make me wonder, why does it seem like 90% of indy game developers use C++? i mean, is it just out of ignorance? or do these people really enjoy managing memory, finding heap corruptions, finding other bugs that couldnt happen in a managed environment, writing crap loads of code themselves, etc...


I suppose, then, that you use a managed environment for your games?

I think that I will also switch to C# for my development. The pros outweigh the cons, and I never intend to go commercial anyway. The development time will decrease so rapidly (apparently) that the slight speed difference in the final executable will be worth the effort saved.

Share this post


Link to post
Share on other sites
nilkn    960
Quote:
Original post by CodeTitan
Quote:
Original post by graveyard filla
Quote:
Original post by nilkn
Alright, before this thread gets out of hand (as it inevitably will) I feel this should be said. C# is only on average 2% less fast than C++. There are quite a few commercial games written in C#, and there is a port of the OGRE engine which often runs faster than it's C++ counterpart. So it doesn't matter which language you use. It's really that simple. The only exception would be if you're writing a literally top of the line 3D renderer (unlikely), and it will power a AAA blockbuster title (also unlikely), so just choose which one you more prefer based on language syntax, that sort of thing.


you know... posts like this make me wonder, why does it seem like 90% of indy game developers use C++? i mean, is it just out of ignorance? or do these people really enjoy managing memory, finding heap corruptions, finding other bugs that couldnt happen in a managed environment, writing crap loads of code themselves, etc...


I suppose, then, that you use a managed environment for your games?

I think that I will also switch to C# for my development. The pros outweigh the cons, and I never intend to go commercial anyway. The development time will decrease so rapidly (apparently) that the slight speed difference in the final executable will be worth the effort saved.


Yep, productivity could potentially go off the charts compared to C++. The problem with most new game programmers today (tho I'm one of them) is that they focus on reimplementing the basic algorithms and data structures. Now, I agree these need to be understood, but rewriting such things is a waste of time. What game programmers need now is not to be able to write a quick sort algorithm, but to be able to piece together all the subsystems that comprise a game to make something bigger.

For example, how many threads do you see around here about things such as message systems, or class hierarchies? Granted there are a few, but still very little compared to how many are asking 'What's wrong with my linked list implementation?' or something similar. People are focusing on the wrong things. This is why so few people here ever finish a game. Everybody is working on their awsome "2D Engine", which they most likely won't finish, and thus will not make any games for quite a while.

Anyways, these are just my thoughts, purely opinion.

Edit: I'm not saying C# is better than C++, nor am I saying it's a better choice. I'm simply saying you will be more productive with it than in C++. But if you need pointer arithmetic, or just want it, then there's absolutely nothing wrong with that. Just know you will probably spend more time fixing bugs than writing a game. The only reason I'm still using C++ is because I have an entire messaging system written in it, and I'm too lazy to port it to C#.

Share this post


Link to post
Share on other sites
Quote:
Original post by CodeTitan
I suppose, then, that you use a managed environment for your games?


hah... ironically enough, no, i use C++ for my game development. however, recently i've had to teach myself C# for business programming, and when i started reading some of the toturials on C#, i guess it was like one of those "oh damn" kind of moments [grin].

personally though, i do not regret going with C++, only because its like getting punched in the face over and over. when you finally stop getting punched, everything feels soooo good [grin]. ok, might have been a bad analogy, but what im saying is, once you can do C++, you can do anything.

Share this post


Link to post
Share on other sites
kaysik    382
Quote:
Original post by graveyard filla
you know... posts like this make me wonder, why does it seem like 90% of indy game developers use C++? i mean, is it just out of ignorance? or do these people really enjoy managing memory, finding heap corruptions, finding other bugs that couldnt happen in a managed environment, writing crap loads of code themselves, etc...


Yes "these people" do enjoy managing our memory, finding random bugs and writing crap loads of code ourselves. I've use VB, Java and a little C# (not too much I'll admit) but I don't find any of them half as enjoyable as C++. Infact I find it kind of insulting sometimes because so much is abstracted away that I could handle myself. I know thats the whole point of such languages, but really they annoy me because I'm used to (and like) doing things myself so when i can't it gets frustrating. For GUI applications that I just want to run then sure high level languages rock. But for games when the whole point is getting your hands dirty it seems kind of pointless.

Lots of people complain heavily about the memory bugs, but its actually not that big a deal once your competant (for learners though its hell). I code in both c and c++ for work, and c++ for my hobby code and very rarely do I come up against any memory management bugs. Infact I've never had a "heap corruption" bug, and its usually only at the start of a project that you get any type of memory bugs at all. It does take more practise than say java/c# but once your used to it putting a delete to match every new just becomes second nature. 90% of my time is always spent on phyics and gameplay code which would still happen in a c# game. True it took me alot longer to get compotent with c++ than it would've if I'd started with c# but that gives me a greater sense of achievement which is why I code for fun in the first place!

Also some people don't like being lock into the MS way of doing things. I for one write my code to be portable and run on linux - so that counts out all of .NET even if I was inclined to use it. Also most people still don't have the .NET framework and I don't want to force it people who'd like to view my work. There is also the fact that MS can chop and change .NET at will without telling anyone. They probably won't because everyone would complain but they can. They can even just stop updating it completely and then your code becomes useless.

So those are just a few of the reasons why "those people" choose not to use .NET

Share this post


Link to post
Share on other sites
kaysik, i agree with you. personally, i feel more comfortable being close to the metal. i feel like i have more control over things... to be honest, i havent even really written anything except basic "hello world" apps in C#. i guess the main problem is, in real life, time == money, so most employers will probably want to go with a higher level language. also, in fake life, e.g. doing your own indy gaming in your spare time, time == reality. the longer it takes you to finish a game, the less likely you will be to finish it. this is why i would consider using something like C# for my next game.

Share this post


Link to post
Share on other sites
noVum    170
Quote:
C# is only on average 2% less fast than C++
All right... The same is said about Java FOR YEARS. And guess what? It still consumes shitloads of memory and the JITC lag is just plain annoying. I would be very astonished if C# would be any different.

Share this post


Link to post
Share on other sites
nilkn    960
Quote:
Original post by noVum
Quote:
C# is only on average 2% less fast than C++
All right... The same is said about Java FOR YEARS. And guess what? It still consumes shitloads of memory and the JITC lag is just plain annoying. I would be very astonished if C# would be any different.


You're probably right, but still, for 90% of us gamedevers, does it matter? Probably not. Nobody here is writing anything anywhere near the scale of FarCry or Doom 3. But also, keep in mind the guys who actually are writing FarCry and Doom 3 are incredibly experienced and skilled, and will therefore probably not have much trouble with C++ at all.

Quote:
Original post by graveyard filla
kaysik, i agree with you. personally, i feel more comfortable being close to the metal. i feel like i have more control over things... to be honest, i havent even really written anything except basic "hello world" apps in C#. i guess the main problem is, in real life, time == money, so most employers will probably want to go with a higher level language. also, in fake life, e.g. doing your own indy gaming in your spare time, time == reality. the longer it takes you to finish a game, the less likely you will be to finish it. this is why i would consider using something like C# for my next game.


These are totally valid points, and I completely understand. I sometimes feel the same way. These are simply some reasons why C++ might be preferable over managed languages. But still, the difference in productivity can't be denied. So I still stand by my point that which language is left totally to personal preference.

Share this post


Link to post
Share on other sites
kaysik    382
Quote:
Original post by nilkn
Now, I agree these need to be understood, but rewriting such things is a waste of time.


No actually its a very fundamental part of learning. People who can't write their own linked list, and don't know the fundamentals of computing will never be good at stiching together those "subsystems" as people who do. Its just like the best coders I know are confident in ASM ... they never use it but they know how stuff works so their code comes out better in the end. Is learning ASM a waste of peoples time? Hell no! It teaches you heaps about how computers work and whats going on inside the CPU. If your just after getting an app to run for a specific purpose then sure you don't need any depth to your knowledge. But if you want to be GOOD at what you do then you definatly DO need to learn the basics and learn them well - and the only way todo that is to practise!

If you want to eat cake then you can just read the back of some packet mix, if you want to be a chef you learn to beat the eggs, sift the flour, cream the butter, mix it together, grease the pan, pre-heat the oven, cook it, get it onto the cooling tray without breaking it and finally serve it on a plate and make it look tasty! Are you a chef or just hungry?

Share this post


Link to post
Share on other sites
kaysik    382
Quote:
Original post by nilkn
But still, the difference in productivity can't be denied.


I never denied it :D Infact I support it. I just said a bunch of reasons why I stick with c++ but none of them were productiviy. If I wanted to get something done, and done quickly then I definatly wouldn't use c++. But for hobby code thats for my own enjoyment c++ all the way!

Share this post


Link to post
Share on other sites
noVum    170
Most of C# and Java increased productivity comes from their huge libs.
You can find almost everything for C++ aswell (boost, etc.)

Memory management is not really that much of a problem if you use autopointers, a memory leak checker and a runtime bounds checker.

I think C#/.NET is much overrated. Don't get me wrong, I love using it for small tools, but I wouldn't write something that I give away with it.

Share this post


Link to post
Share on other sites
phil05    100
C++ isn't meant to replace C#. They're both made to fix a certain set of problems. C++ is to systems as C# is to the internet. THE END. Go on from there.

Share this post


Link to post
Share on other sites
Saruman    4339
Quote:
Original post by noVum
Quote:
C# is only on average 2% less fast than C++
All right... The same is said about Java FOR YEARS. And guess what? It still consumes shitloads of memory and the JITC lag is just plain annoying. I would be very astonished if C# would be any different.


That's a pretty stupid point. Considering Java ran in a VM while C# is compiled to MSIL and when run complied to native. Along with the fact that Java didn't have a graphics library such as MDX when people started using it.



Looks like you should be astonished sir.

And for anybody saying that memory management and bugs, overflows, etc are "not much of a problem in C++ once you know the language" can you please explain to me why over 90% of bugs that exist in commercial software today are memory and overflow errors? I mean sure when I am using C++ at home I very rarely, if ever, run into memory management issues... but with a team < 10 people thats a pretty simple task.

When working in large teams managing memory is not easy and there will most likely always be bugs. ATI's driver team here in Canada has over 1000 guys working on the same source.. you don't think they ever have memory problems?


This thread should be finished. BOTH languages work and are used in indie and commercial development. There is proof that you can write an engine in C++ as well as C# and get good performance. Why argue about any of this junk?

Share this post


Link to post
Share on other sites
noVum    170
Quote:
Considering Java ran in a VM while C# is compiled to MSIL and when run complied to native.
Java also has a JITC. But that doesn't change the "I'll use up all of your system memory" thing and the JITC lag.

Quote:
Along with the fact that Java didn't have a graphics library such as MDX when people started using it.
There are several OpenGL bindings to Java.

Quote:
Looks like you should be astonished sir.
Nope I'm not. There is no indication about the used C++ compiler. Especially since these should be very GPU limited benchmarks the numbers are inexpressively.

The DOT3 benchmark also indicates that something is very wrong with these benchmark results. I checked the demo source and there is NOTHING that could be CPU limited.

Share this post


Link to post
Share on other sites
nilkn    960
Quote:
Original post by Oluseyi
Quote:
Original post by hamo32
Ive never programmed in .net before because im a c++ user, but ive been always wondering wich one is better when programming games.
.NET and C++ are not mutually exclusive: Managed Extensions for C++, C++/CLI.

Don't mind all the idiots arguing above.


There was no argument, simply a very calm discussion. Everything that has been said was perfectly valid. Also, the original post had several implications that it's poster was treating .NET and C++ as seperate entities. Therefore, how can you say we are idiots? Your point that C++ and .NET aren't mutually exclusive is also perfectly valid, but referring to everybody else as idiots because they didn't point it out is totally unjustifiable in this situation.

Also, by saying "Don't mind all the idiots arguing above," you imply that your point is superior to all others previously made, and that yours closes the matter. The fact, though, is that it does not; it merely supplements everything else that has been said.

Share this post


Link to post
Share on other sites
kaysik    382
Quote:
Original post by Saruman
Looks like you should be astonished sir.


Why? Nobody said c# was slow? Infact the only people who've brough up speed as an issue are the ones saying c++ isn't worth the effort :D All the pro c++ posts have been about how its more FUN

Even if C# was 5x faster than c++ i still wouldn't use it because for ME its not as enjoyable.

Quote:
Original post by Saruman
can you please explain to me why over 90% of bugs that exist in commercial software today are memory and overflow errors?


Care to back that up? I'd say most bugs are todo with poor gui design and a lack of usability testing. Its very rary any application I run crashes, but missing menu options and poor gui's are everywhere!

Share this post


Link to post
Share on other sites
BobV    416
My concerns with C# have been the need for the .NET framework. Is it a non issue I've blown out of proportion? For small games, the framework would probably wind up being a larger download then the game itself. The other drawback that comes to mind with C#/.net is it's cloudy future; will it be adopted outside of windows?. Right now you lose out on any ability to be cross platform (I don't believe mono will work for games). Does anyone have any thoughts?

Share this post


Link to post
Share on other sites
c++ stardard can be used to write
PC
XBOX
PLAYSTATION
NINTENDO
GAME BOY
THE CELL PHONE
THE PDA
A REFRIDGERATOR AND MICROWAVE ( ok maybe u cant do this with all fridges )

.NET can be used to write
PC
maybe UNIX/LINUX using MONO and being carefull

this isnt easy and most of theese ports require a few mandatory API calls but...
porting a .NET app to a playstation just isnt possible.
The more you use c# with .NET the more your locking yourself into windows the bigger the program gets.

c++ is also 20+ years old ( more standardized, more portable )
c# and .NET are only a few years old

c++ IS FASTER ( no garbage collection etc.. )
c++ gives you more control over low level details ( pointer arithmatic etc... )

C# is less low level ( can be good and bad )
C# you can write aplications faster ( GOOD )
C# no telling if you will be able to port it ( BAD )

but... Unless your gonna write and app that must port to PS2 and GameCube and PC
and XBOX and must display 100000000000000 polygons on the screen at all times and ....


a big company wont use c# for years because it will mean money lost in difficulty of porting until C# can prove itself capable of running in multiple enviroments.

IF YOUR NOT A BIG COMPANY WHO CARES ??????????????
use what you like.

Share this post


Link to post
Share on other sites
raptorstrike    181
You can bring up 2 topics that will get ALOT of posts, Which API is better and Wich language is better

DISCLAMER:
I have tried to make this post as unintrusive as possible if you are going to have a problem with people saying they prefer to use c++ over c# DONT READ IT cause as a poster i am totally "put-off" by flame wars and usually dont read the topic and i think this is a good topic for people to read so that they can see the pros and cons

Personally i like c++ because I'm more comfortable with it and I like the syntax of it. I also like using c++ because it forces me to invent the wheel (yes thats right i want to do that) i think this is a good thing because im not REinventing the weel if i really dont know how it works in the first place then I do gain somthing from it. After i know how all the diffrent game structures and how they do what they do then i MIGHT switch to somthing like c# (but probibly not because by then i will have written my own classes witch i would understand better anyway) Its sort of like getting a package of cookie dough or making it from scratch, they both turn out great cookies but if you use homemade you know what goes into it and how you might improve it.


Share this post


Link to post
Share on other sites
Thanhda    100
Quote:
Original post by hamo32
greetings game comunity!

I was wondering on your opinion on .net and c++. Ive never programmed in .net before because im a c++ user, but ive been always wondering wich one is better when programming games.
Please share your opinions on this topic.

thanks


use C++, if you mean .net as in msvc 7, then use 7, but you can still programm c++ apps in .net

Share this post


Link to post
Share on other sites
Saruman    4339
What I don't understand is why people try to mention consoles and portability when using C#? Are people really that stupid?

In software engineering you learn to use the right tool for the job. That being said if you are writing a game for PC only like 100% of the other indies out there than it is fair to say that you could use either C# or C++ and it doesn't make a difference whatsoever.

The main purpose of the C# language is to create applications for future Windows platforms and to be the native .NET language. It is just an extra bonus that it will run on other platforms such as Linux, etc... but it is truely not meant for that.

I mean wtf why even mention consoles and anything else because C# is not meant for that.. it is not a general purpose language, it is meant for specific tasks.

ugh no wonder Oluseyi gets so sick of seeing crud like this thread posted.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this