C++ or C#?

Started by
33 comments, last by CTar 16 years, 11 months ago
I am willing to get into 3D game programming. My problem is, I don't know what language to use. I have the C++ book 'Sam's teach yourself in 24 hours'. But in another forum I was told that C++ is getting out of date, and C# is better. Another question is, what API should I use? OpenGL or DirectX? I want to get the most realism out of my game (when I get to making it). I will first learn C++/C# (depends on what you guys recommend) then I'll learn Windows programming and finally DirectX or OpenGL. Any suggestions? What books/tutorials should I get?
Advertisement
Quote:Original post by Promit
Here's some reading material.
1) Professional Games Made In C#?
2) Java for game development?
3) Java----C/C++
4) c++ or c#
5) Question about Java Vs. C# Vs. C++
6) Java Games?
7) Java is fast?
8) Secondary Language:VB or Java?
9) What makes C++ so powerful?
10) C# games and cheating...
11) Is C# good enough for system utility programming
12) MC++ vs. C#
13) Which language is best for a 3d Games Engine?
14) C# vs C++ as a choice for development
15) Is Java the Future?
16) why C# and not Java?
17) What do you think of the D language?
18) my c++ d c# benchmark!
19) The Definitive Guide to Language Selection
20) Sharp Java
21) C++ or C#?


Those links just confused me... One opts for C++, another for C#...

What would be the best for creating a game from scratch (with a pre-made open source game engine)?
Quote:Original post by Cyb3rGlitch
Those links just confused me... One opts for C++, another for C#...

What would be the best for creating a game from scratch (with a pre-made open source game engine)?


Depends on who you listen to... some opt for C++, some for C#.
It doesn't really matter, try them both out. Download an IDE and create a few small programs.

As for D3D vs OGL, you aren't ready for either yet. When you are though, the same thing applys, both can do the same thing so it doesn't really matter.
Quote:Original post by Scet
It doesn't really matter, try them both out. Download an IDE and create a few small programs.

As for D3D vs OGL, you aren't ready for either yet. When you are though, the same thing applys, both can do the same thing so it doesn't really matter.

I'll probably go for C++ then.

So what is essential to learn how to develop 3D games?
I have programmed in both and each has its own strengths and weaknesses. I don't know who told you that C++ is getting out of date, but I couldn't disagree more. Many, many applications are written in C++ and it is an extremely powerful language. What you should know is that once you know C++, you can easily learn C# and vice-versa. I originally learned C++, but was able to pick up C# in about 2 weeks.

I have never used OpenGL, so I can't comment much on it, but I have programmed in DirectX w/C++ and in Managed DirectX w/C# (I hope to get into XNA soon), and I can say that they are both equally powerful (despite what some here might say otherwise). From what I have read, OpenGL and DirectX are both very powerful APIs and both are used by professional game developers.

I would recommend you learn C++ first, especially if you don't have prior programming experience, so you can start with structured programming. Then, once you move on to object-oriented programming, you can easily switch to C# with no trouble.

For windows programming, there are plenty of good tutorials out there. However, I found that "Programming Windows" by Charles Petzold was an excellent, albeit now outdated, introduction to the Win32 API. I haven't even hardly scratch the surface of this book (it's 1500 pages, more like a doorstop than a book), but the first few chapters are extremely helpful to the beginning windows programmer. Windows programs have a very different structure than "console" programs, so a firm understanding of that structure is essential to any OpenGL/DirectX programmer. Don't make the same mistake that I made by thinking that you can learn windows programming while learning a graphics API.

I found that "Programming Role Playing Games with DirectX, Second Edition" by Jim Adams was a good introduction to DirectX in C++. It isn't always perfectly clear at times, but the sample code is good and usually error-free. The game engine that comes with the book is good for beginners (not a professional game engine, though) but is definitely powerful enough to be used to create your own games. Just be sure to get the second edition (the first edition uses DirectX 8.1, the second uses 9.0b).

For managed DirectX (in C#), "Managed DirectX 9 Kick Start: Graphics and Game Programming" by Tom Miller is an excellent introduction. This book will not teach you how to create an entire game but will give you the tools you need to do so.

Personally, I have found that Managed DirectX is easier to program in. Unmanaged DirectX with C++ is straining to the eyes. MDX is much cleaner looking code and is simpler to start an application from scratch in. The disadvantage to using MDX is that the majority of documentation and tutorials are written for unmanaged DX.
Strength without justice is no vice; justice without strength is no virtue.
Quote:Original post by Cyb3rGlitch
So what is essential to learn how to develop 3D games?


The most essential thing is to learn how to program well in your choice of language.
Quote:Original post by AIDev
Quote:Original post by Cyb3rGlitch
So what is essential to learn how to develop 3D games?


The most essential thing is to learn how to program well in your choice of language.


QFE, although you may want to generalise it to "the most essential thing is to learn how to program well". After you've used more than two languages, you'll find that most of the concepts you learn (especially in any multi-paradigm language, of which C++ is an example) can be easily applied to others, be it Java, Python, C#, etc*. If you feel comfortable enough going ahead with C++, which is a tad trickier than C# and other managed languages, feel free. At some point in your programming life, you're going to have to learn about the low-levels (pointers, heap vs. stack allocation, etc), and you may as well do it now. Don't forget, before Java, C and C++ (and Assembler) were the primary languages taught in university, and many programmers somehow graduated. Just make sure you find a good book/tutorial. There are many bad ones out there about C++ - mainly written by old C programmers who apply C solutions to C++ problems, which is wrong. Hope that helps!


*But not Lisp. Never Lisp. [grin]
[ search: google ][ programming: msdn | boost | opengl ][ languages: nihongo ]
You should use whichever API you think is better, though first things first, you should learn some C++ ;)

C# is a lot easier to learn than C++, it is like the best parts of Java and C++ combined and compressed intot his really awesome package, the only reason I'm not learning Directx through C# (just yet) and instead am learning C++ with Directx is because of my course at uni :p

So I'd recommend C# with Directx, but thats just my opinion.

If you do want to go C++ 'Introduction to 3D Game Programming with Directx' is the best book to get a hang of Directx, I'm building my first 3D game engine on top of a lot of the source code and principles I learned from that book, in the space of a week!

This topic is closed to new replies.

Advertisement