C++ or C#?

Started by
33 comments, last by CTar 17 years ago
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?
Advertisement
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++
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.
++ My::Game ++
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 +++]

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,
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.
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]
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.
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.
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.
James

This topic is closed to new replies.

Advertisement