17
\$\begingroup\$

I am a 2D Game Programmer.Some programming languages which I am good at are C,Java ,C#. I also know Actionscript 2.0,3.0 and some javascript. I'm interested in learning 3D Game programming. So far from the research I have accumulated by googling and reading different game development forums and articles. I've noticed that most programmers tend to prefer C++.Also in an online game programming teaching course I noticed they prefer to teach C++ and Visual C++ as the starting course. The reason I am asking this question since I would like to know the "strength" difference of C++, C# and Java for 3d game programming.

Also include links to good 3d game programming articles for the already 2d game programmer.

P.S : IMHO , I also find C++ to be cryptic.

\$\endgroup\$
12
  • \$\begingroup\$ I also get that a lot. So asked a question in the community as to what skills a professional game programmer should have. Got some nice answers focussing on C++ as better language for developing games. check.. gamedev.stackexchange.com/questions/5552/… \$\endgroup\$
    – GamDroid
    Nov 17, 2010 at 10:16
  • \$\begingroup\$ @GamDroid: I am not interested in knowing what makes a professional 2d game programmer. I am interested in knowing about Visual C++ and why is it so talked about on. \$\endgroup\$
    – Vishnu
    Nov 17, 2010 at 10:34
  • 2
    \$\begingroup\$ Btw: Visual C++? Not just plain C++? \$\endgroup\$
    – speeder
    Nov 17, 2010 at 12:59
  • \$\begingroup\$ The Visual C++ editor is cool, but the language Visual C++ (that is: C++ with Win32 GUI API and stuff like that, both with MS Visual C++ or Borland C++ Builder) is pretty confusing and should not be used for games (it is too bloated, and using GDI is slower than using say, SDL, to control the window) \$\endgroup\$
    – speeder
    Nov 17, 2010 at 13:00
  • 1
    \$\begingroup\$ @Vish, apologies then, feel free to edit it to be more precise keeping in mind the comments thus far. If you mean Win32 programming is confusing, then say that. \$\endgroup\$
    – Tetrad
    Dec 1, 2010 at 6:03

3 Answers 3

30
\$\begingroup\$

Yes, C++ is the language used most often (though some people do still use C).

There are numerous reasons for this. Sheer momentum is one - it's simply the language that has been used for years, a lot of tech already exists and people are comfortable with it, so changing is not going to happen overnight.

Then there is the issue of control. Game developers are control freaks, and we like to know everything that is going on in our code. C++ gives us that control, C# and Java (to pick on the two alternatives you mention) take control away. In many ways that might be a good thing, but game coders don't like it :)

Finally there's the simple practical issue that the SDKs for various platforms are very C++ centric. Using another language inevitably involves writing wrappers, cross-compiling down to VMs, and possibly (in the case of some console development) it's not allowed by the platform holder (they really don't like people doing JIT compiling, for a start).

\$\endgroup\$
8
  • 2
    \$\begingroup\$ In the mainstream development industry, yes. \$\endgroup\$
    – JasonD
    Nov 17, 2010 at 10:56
  • 2
    \$\begingroup\$ In terms of languages, C++, primarily - it's not going anywhere any time soon. I'd suggest it also wouldn't hurt to be familiar with scripting languages - Lua, Python, etc. \$\endgroup\$
    – JasonD
    Nov 17, 2010 at 11:05
  • 8
    \$\begingroup\$ Visual C++ is not a language, it's an IDE. \$\endgroup\$ Nov 17, 2010 at 11:43
  • 2
    \$\begingroup\$ Yes, though it's probably the most used IDE, so it's worth getting to know that at the same time as learning C++. \$\endgroup\$
    – JasonD
    Nov 17, 2010 at 11:52
  • 1
    \$\begingroup\$ @SurvivalMachine Well technically it's a dialect (there are plenty of MSVC++ extensions that don't exist in the standard) \$\endgroup\$
    – bobobobo
    Nov 21, 2012 at 20:02
4
\$\begingroup\$

C++ is still preferred as you can see on pretty much any publication on the topic of game development. I personally am currently using C for my diving into game development for the simple reason that the C++ code I write abuses templating features, uses RAII extensively, dynamic memory allocation and other things that you just should not do in game code from what I have seen so far.

Sticking to C forces me to be minimalistic and think about what I'm doing. It can be harder at times when you have to reimplement something the STL gives you for free, but on the upside I feel I write cleaner code and have a better time debugging that thing.

\$\endgroup\$
4
  • 3
    \$\begingroup\$ RAII is perfectly acceptable(and should be encouraged) in game code. \$\endgroup\$
    – stonemetal
    Nov 18, 2010 at 15:52
  • 1
    \$\begingroup\$ @stonemetal: RAII encourages delayed and therefore unpredictable resource allocation. Whether that should be encouraged or not depends on the size of your game and your target platforms (and the resource in question); on average I would not encourage it. Furthermore, RAII in C++ is most commonly used with heap allocation, because C++'s OO makes stack allocation too hard. \$\endgroup\$
    – user744
    Nov 19, 2010 at 12:05
  • 3
    \$\begingroup\$ In what way does RAII encourage delayed resource allocation? When I use GLFW I make a class called GLFWRAII that calls GLFW's init function in the constructor and calls GLFW's clean up routine in the destructor. I allocate it on the stack at the beginning of main, it in no way delays anything nor does anything unpredictable. Other uses might be to allocate at the beginning of a level and clean up at the end of a level. Poorly using a technique doesn't make it a poor technique. Nothing about RAII suggest unpredictable resource allocation other than poor use. \$\endgroup\$
    – stonemetal
    Nov 19, 2010 at 14:38
  • \$\begingroup\$ You just have to avoid using those features. I use C++ and I never use templates in my code nor have objects throwing exceptions in their constructors. In C you can still use dynamic allocation (and you must for a 3D game). Besides, you should code in a way that also someone else find it easy to understand--a big project in pure C code can be a hell, even if you understand it. If you learn to think about what you're doing even if the language doesn't force you to, you will be able to write clean code in many other languages too. \$\endgroup\$ Sep 3, 2011 at 19:49
1
\$\begingroup\$

I'm personally not a fan of C++, and I prefer Java. However, most people in the industry do use it and it's the easiest language to convert to other platforms without wrappers and virtual machines.

However, sometimes other languages work out pretty good for game development. I use Java with LWJGL and it is amazing. So if you want to start with 3D programming and OpenGL without having to learn C++, try out LWJGL with Java, because it's very lightweight and I think it's actually C++ code running through JNI.

Maybe in the long run you might want to switch to C++, but you can start and practice with C# or Java. Because most game code comes from experience with the language, but you should try and practice OpenGL with a language you're comfortable with. Also, while you're practicing graphics, you should also try out GLSL with OpenGL, it has very C-like syntax

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged .