r/programming • • Oct 18 '09

Frequently Asked Questions for prog.reddit

I've been thinking we need a prog.reddit FAQ (or FQA :-) for self.programming questions people seem to ask a lot, so here is my attempt. Any top-level comments should be questions people ask often. I think it'd be best if replies are (well-titled) links to existing answers or topics on prog.reddit, but feel free to add original comments too. Hopefully reddit's voting system will take care of the rest...

Update: This is now a wiki page -- spez let me know he'll link to the wiki page when it's "ready".

245 Upvotes

276 comments sorted by

View all comments

20

u/benhoyt Oct 18 '09

What programming language should I use for my new game?

23

u/SquashMonster Oct 19 '09 edited Oct 19 '09

Speaking as someone who's been mentoring a class on experimental game design for the last three years, so please take this advice over the kneejerk "C++/C/not Java":

Language rarely matters, instead worry about what libraries you want to use, what languages they can easily be used in, and which of these languages works for all your libraries. The only major exception to this is if you're targeting a restrictive platform. If you're making a web game, you have to use Flash, Java, or JavaScript. If you're making a console game, you can't use any of those.

Almost every game needs graphics, audio, and input libraries. There are libraries specifically designed for games that wrap all of these functions, and as a beginner it's probably best if you start with one of these. The most commonly recommended ones are SDL, Ogre, Pygame, Slick, JMonkey, and XNA. Ogre and Pygame suck: don't use these. XNA is great, and I hate C# so trust that I say so begrudgingly. Slick and JMonkey are also great, and, being Java libraries, you can access them through Python (Jython), Lisp (Clojure), or Java (duh). If you're dead set on using a language that isn't one of the ones easily supported by these libraries, you can use SDL because there are SDL bindings for everything.

Now, a note on speed, because somebody is going to bring it up. Don't use Ruby. Excluding Ruby, the harshest performance difference you'll ever see is Python versus C++: Python is roughly 100x slower than C++. 100x sounds like a lot: however, say you have a O(n2) algorithm. Once n>100, the difference caused by a 100x performance boost is too small to allow you to afford increasing n by one. Why is this important? Object interaction is by nature an O(n2 )algorithm[1]. If you can handle over 100 objects on-screen in C++ without a dip in framerate, then any language switch (except Ruby) will have almost no performance impact.

Finally, what do professionals use? Traditionally, C++. Now, increasing amounts of Flash, Objective C, and Java. Sky-rocketing amounts of C#. C++ is still the single most common, especially for AAA titles. However, most big-budget titles are made by buying a bunch of professional-grade middleware libraries (which are in C++), gluing it together with a small amount of C++ code, then writing the rest in a scripting language. The most common scripting language here is Lua, but by a tiny margin.

[1] Yes, you can trim the hell out of this using a region grid or a quad tree. Both of these blow up in the asymptote due to finite memory. Segregation can drop you to O(n) with no memory overhead, but that imposes restrictions on your game design.

EDIT: Typo.

3

u/[deleted] Oct 19 '09

I'm curious. Why do you think Ogre sucks? I've seen and heard nothing but good things about it. Though, recently I've been really liking Panda3D using Python and C++.

1

u/SquashMonster Oct 19 '09

Every project I've mentored that used Ogre had a had problems with simple things like cameras and collisions, and had to struggle with object interaction. And, most importantly, apparently the toolchain is a nightmare. The only project I've seen have a worse time importing art assets was trying to use the Source engine.

Panda3D is okay, I just forgot about it when making that list. None of my students have ever had trouble with it, although the Panda3D projects are never that visually impressive. I don't know if that's some limitation of the engine or just a coincidence.

→ More replies (2)

2

u/[deleted] Oct 19 '09

LÖVE is a rather nice framework for games as well.

1

u/SquashMonster Oct 19 '09

I'll try it out next class and get back to you.

2

u/fearimas Oct 19 '09

Very informative post

2

u/Coffee2theorems Oct 19 '09

however, say you have a O(n2) algorithm. Once n>100, the difference caused by a 100x performance boost is too small to allow you to afford increasing n by one.

So you can do 1002 = 10,000 units of work just fine, but a 100-fold speedup is too small to let you do 1012 = 10,201 units of work?!

→ More replies (2)
→ More replies (9)

6

u/danijel3 Oct 18 '09

This question isn't specific enough, I think. Depends on the game really...

7

u/benhoyt Oct 18 '09

Yes, that's part of the problem when people ask these questions on self.programming -- and I think the FAQ could help point them in the right direction for different specifics.

→ More replies (1)

4

u/micropenis Oct 19 '09

Java/GTGE, Python/cocos2d are two good language/engine combos for beginners in 2d, at least.

1

u/SquashMonster Oct 19 '09 edited Oct 19 '09

Upvoted for libraries I've never heard of.

I've only had a few minutes to look at this, so my conclusions may be wildly inaccurate:

GTGE doesn't look that good: the documentation is weak, the code is old, and I'm biased against things that don't use Java5 features. The set up looks similar to Slick, which has a wider following, so I'd lean towards Slick.

Cocos2D looks more promising. The stuff it does with transitions and wobbling are things that Slick can't do, although just glancing at it seems like those were hard coded. If they're not, Cocos2D is very impressive. The documentation is incomplete, though. I don't think I can really make a conclusion without convincing someone to write a game in it while close enough that I can hear if they start swearing.

1

u/micropenis Oct 19 '09

Oh yeah, there's also an iphone version of Cocos2D, forgot to mention that.

Slick looks cool, thanks for bringing it onto my radar.

2

u/lief79 Oct 18 '09

What programming language should I use for .... what programming language should I use, should be generic headers, with the comments beneath.

Honestly, this would work better as a wiki, there is no good way to make edits.

12

u/pr1mu5 Oct 18 '09

Not Java.

Saying Java is a good programming language because it runs on all systems / hardware is like saying anal sex is good because it works on all sexes.

16

u/JadeNB Oct 18 '09

Saying Java is a good programming language because it runs on all systems / hardware is like saying anal sex is good because it works on all sexes.

Wow, you're one of the first 35,400 to think of that.

7

u/seyfodayi Oct 19 '09

nice try, bisexual coder.

→ More replies (2)

7

u/[deleted] Oct 19 '09 edited Oct 19 '09

That's precisely why anal sex is good. Well it's not the hole story, but that's part of the appeal.

→ More replies (2)

2

u/artsrc Oct 18 '09

I knew someone who had a success business writing Java games for (specific) phones.

→ More replies (1)

2

u/magikasheep Oct 18 '09

Depends how difficult you want it to be (and as a result, how awesome you are)

Easy: Flash

Medium: Java Applet

Hard: C# For 360 game

8

u/hs5x Oct 19 '09

I'd wager C# via http://creators.xna.com would qualify as "Medium".

4

u/[deleted] Oct 19 '09

I ♥ Garbage Collection. :3

4

u/[deleted] Oct 18 '09

Extreme: C for multi-platform (or C++ to give yourself an extra pain in the ass)

4

u/jevon Oct 19 '09

Ultimate Extreme: Butterflies

→ More replies (2)