Jump to content

  • Log In with Google      Sign In   
  • Create Account

C++ or C#?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
34 replies to this topic

#1 Cyb3rGlitch   Members   -  Reputation: 142

Like
0Likes
Like

Posted 24 April 2007 - 04:34 PM

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?

Sponsor:

#2 Driv3MeFar   GDNet+   -  Reputation: 1076

Like
0Likes
Like

Posted 24 April 2007 - 04:40 PM

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#?




#3 Cyb3rGlitch   Members   -  Reputation: 142

Like
0Likes
Like

Posted 24 April 2007 - 04:48 PM

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)?

#4 Telastyn   Crossbones+   -  Reputation: 3730

Like
0Likes
Like

Posted 24 April 2007 - 05:00 PM

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#.

#5 Scet   Members   -  Reputation: 960

Like
0Likes
Like

Posted 24 April 2007 - 05:09 PM

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.

#6 Cyb3rGlitch   Members   -  Reputation: 142

Like
0Likes
Like

Posted 24 April 2007 - 05:40 PM

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?

#7 Chaotic_Attractor   Members   -  Reputation: 152

Like
0Likes
Like

Posted 24 April 2007 - 05:53 PM

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.

#8 AIDev   Members   -  Reputation: 190

Like
0Likes
Like

Posted 24 April 2007 - 05:53 PM

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.

#9 _goat   Members   -  Reputation: 804

Like
0Likes
Like

Posted 24 April 2007 - 06:13 PM

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 ]

#10 chillypacman   Members   -  Reputation: 100

Like
0Likes
Like

Posted 24 April 2007 - 11:13 PM

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!

#11 Cyb3rGlitch   Members   -  Reputation: 142

Like
0Likes
Like

Posted 24 April 2007 - 11:17 PM

Wow! A week. How much have you learnt in C++? I'm up to classes and pointers etc.

EDIT: Oh, and do you need to learn Windows programming to use that book?

#12 Hacy   Members   -  Reputation: 122

Like
0Likes
Like

Posted 25 April 2007 - 12:02 AM

C# is indeed a lot easer, but ot was never ment to be a game programming language. .NET platform is too slow ( at least now, maybe some day... ) to be used in proffesional game programming other than 2D windows games ( like saper ). If you want to use directx, then your obvious choice schould be C++

#13 _neutrin0_   Members   -  Reputation: 241

Like
0Likes
Like

Posted 25 April 2007 - 12:31 AM

Quote:
Original post by Hacy
C# is indeed a lot easer, but ot was never ment to be a game programming language.

Why is that? I really would like to know.

#14 benryves   Members   -  Reputation: 1998

Like
0Likes
Like

Posted 25 April 2007 - 12:37 AM

Quote:
Original post by Hacy
C# is indeed a lot easer, but ot was never ment to be a game programming language.
In the same way that C++ is a systems programming language, and so only good for OS/driver development? [wink]

Quote:
.NET platform is too slow ( at least now, maybe some day... ) to be used in proffesional game programming other than 2D windows games ( like saper ). If you want to use directx, then your obvious choice schould be C++
.NET applications are not slow in the slightest. Badly written code, or code that fights against the framework and runtimes is going to perform badly - but that's the same for any environment or language.
[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

#15 Emmanuel Deloget   Members   -  Reputation: 1381

Like
0Likes
Like

Posted 25 April 2007 - 04:02 AM

Quote:
Original post by Hacy
C# is indeed a lot easer, but ot was never ment to be a game programming language. .NET platform is too slow ( at least now, maybe some day... ) to be used in proffesional game programming other than 2D windows games ( like saper ). If you want to use directx, then your obvious choice schould be C++


Uh?

I guess that schizoid on the XBox360 will be really slow. And that it was not made by proffessional game developers.

Not to mention Tin Soldiers or Arena Wars, which is using an OpenGL wrapper IIRC.

Concerning the "speed problems" of the .NET framework, I'm pretty sure that a lot of people around there are able to write C# code which will be as fast (or faster) than your C++ code. Today.

Quote:
I would recommend you learn C++ first, especially if you don't have prior programming experience, so you can start with structured programming.

That's really not a good advice IMHO. C++ is a very convoluted language, and C# is a lot simpler, so why should I learn the most complex language first, the procedural programming paradigm, then learn the object oriented programming paradigm (ie loose a lot of time by trying to understand concepts that are radically different from what I just learn), then , finally, a simple, modern and neat language like C#?

Regards,

#16 Todo   Members   -  Reputation: 451

Like
0Likes
Like

Posted 25 April 2007 - 04:31 AM

Quote:
Original post by Emmanuel Deloget
Quote:
Original post by Hacy
C# is indeed a lot easer, but ot was never ment to be a game programming language. .NET platform is too slow ( at least now, maybe some day... ) to be used in proffesional game programming other than 2D windows games ( like saper ). If you want to use directx, then your obvious choice schould be C++


Uh?

I guess that schizoid on the XBox360 will be really slow. And that it was not made by proffessional game developers.

Not to mention Tin Soldiers or Arena Wars, which is using an OpenGL wrapper IIRC.

Concerning the "speed problems" of the .NET framework, I'm pretty sure that a lot of people around there are able to write C# code which will be as fast (or faster) than your C++ code. Today.


I agree. Managed code compiled JIT can easily keep up with unmanaged code. Last I heard, there's about 4% difference in performance (and that's just because we're talking about managed code).

Quote:
Original post by Emmanuel Deloget
Quote:
I would recommend you learn C++ first, especially if you don't have prior programming experience, so you can start with structured programming.

That's really not a good advice IMHO. C++ is a very convoluted language, and C# is a lot simpler, so why should I learn the most complex language first, the procedural programming paradigm, then learn the object oriented programming paradigm (ie loose a lot of time by trying to understand concepts that are radically different from what I just learn), then , finally, a simple, modern and neat language like C#?

Regards,


Again, I agree. If someone wants to program a game, give him toys and let him play. C# is easier to begin with, there's no denying that. In that respect, I'd advice him to go and learn XNA.

#17 CTar   Members   -  Reputation: 1134

Like
0Likes
Like

Posted 25 April 2007 - 04:42 AM

Quote:
Original post by _neutrin0_
Quote:
Original post by Hacy
C# is indeed a lot easer, but ot was never ment to be a game programming language.

Why is that? I really would like to know.


Which of his statements are you referring to? He claims both that C# is easy and that it was never meant for game programming.

C# is generally considered easier for various reasons. The normal example is memory management. C# pretty much manages it for you (with GC) while in C++ it can be very complicated to manually manage it. Of course if you need good performance you need to understand the garbage collection which can be quite complicated, especially when different platforms (Windows and XBox) have different GC algorithms (at least that is what I've heard). However if you know how it works it's still much easier to use and just as fast (faster in many cases).

It also protects you against all kind of things, especially beginner mistakes like forgetting a break in a switch statement, making an assignment instead of a comparison, etc. It provides a lot of useful features which can help you to develop applications more easily. These are things like a big standard library, events, interfaces, reflection, slightly smarter templates/generics, etc.

It also makes sure you don't make certain common design errors by restricting certain features (inheriting from multiple classes, global variables, etc.)

Also the fact that it doesn't have to have as much backwards-compatibility as C++. Therefore it have a proper module system, no evil preprocessor (and no need for it), etc.

C# have never been promoted as a pure game programming, but I think it would be incorrect to say Microsoft never meant it to be a game programming language. The actual "game programming" languages are either too basic (e.g. DarkBasic) or just some secondary scripting language (e.g. QuakeC).

Microsoft have indeed put quite some focus on C# game programming. More than anyone ever put on C++ in the first three decades. I remember an initiative called Coding4Fun started by them which tried to teach some basic game/graphics programming with C#. It also has a C# game programming competition running and they have been putting a major focus on XNA in the last half year. Also why do you think Managed DX developed so quickly? Because C# game programmers needed it.

Saying that it wasn't meant as a game programming language is misleading IMO.

[Edited by - CTar on April 25, 2007 10:42:32 AM]

#18 chillypacman   Members   -  Reputation: 100

Like
0Likes
Like

Posted 25 April 2007 - 01:12 PM

Quote:
Original post by Cyb3rGlitch
Wow! A week. How much have you learnt in C++? I'm up to classes and pointers etc.

EDIT: Oh, and do you need to learn Windows programming to use that book?


nah I was already fairly competant with C++ beforehand, that book isn't meant for people who don't know anything about C++.

You don't have to know, the code for all that is supplied so you can just get to the fun stuff straight away and build on top of their sample applications.

#19 ZQJ   Members   -  Reputation: 496

Like
0Likes
Like

Posted 25 April 2007 - 02:01 PM

Quote:
Original post by Cyb3rGlitch
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?


Well, I've never so much as written a C# program, but the first thing that comes in to my head is "if you don't know enough to make the choice yourself, use C#"

I've been programming in C++ for quite a long time now (although I only really got my head down and learnt how to use it properly a year or two ago - I used to use C a lot and I still think it's a more elegant and consistent language than C++ despite being pretty short on features compared to pretty much every other language out there - and no, that isn't suggesting you use C), and I still think C++ is a bastard of a language (quite literally - its heritage causes a number of problems), and the only reason I use it is because I'm too lazy to learn anything else right now (that, and the fact that I haven't seen a language that really seems like a step forward yet - apart from garbage collection, most language features are basically window dressing).

On the API front: OpenGL vs. Direct3D. I've never written a program in DX, but as far as ease of coding goes there's probably not much in it. OpenGL gives you portability (to MacOS X and Linux, if you care), although with XNA/D3D you could also target Xbox 360, which you won't get with GL. Sony have been dropping hints about homebrew again, so maybe PS3 will be a consideration, and that would be OpenGL. Take your pick. OpenGL also gives you extensions - very annoying to work with if you don't have a wrapper library like GLEW (I'm not sure if there's one available for C# but I'd be surprised if there wasn't), but they do let manufacturers expose new functionality in their graphics cards before MS goes through another DX release cycle which usually means you get to use it sooner - the notable exception of the last few years being EXT_framebuffer_object.

You know, I think that's the first time I've ever written a paragraph that has more text in brackets than out of them.

#20 JBS103   Members   -  Reputation: 168

Like
0Likes
Like

Posted 25 April 2007 - 02:23 PM

I think the bottom line to most of these discussions is that you as a beginning programmer (and please don't take offense as it this is very general) will limit the language more than the language will limit the language. For example, as said, a program is only as good as the code that is created for it. If it is poorly written, slow, and bulky then the only limitations come from the programmer's skill (or lack there of) and not the actual language's capabilities. If that makes any sense...

Its one thing for someone with absolutely control and mastery of concepts to begin to nit-pick every little feature of each language. Its another story for someone brand new, or with little experience.

Therefore, my best advice, and take it as you wish, is to look past as much of the extra "fluff" (I couldn't find a better word) and just get down into the actual programming. Pick something and run with it. I personally wouldn't chose a programming language on the basis of making it work with a project that is just a goal for the future. Regardless, you can create whatever you want in either of the languages. We know that C++ is proven for the purpose of game making and further C# is also capable of things very similar. Again, whatever you pick, many can assure you, you will be fine with.

Anyway, if you decide you would like to switch to the other language, it isn't the end of the world. While on a professional level, this "philosophy" might not hold water, I personally think that for someone trying to get their feet wet, this is a valid approach, especially if all of these details are getting to you.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS