Live data from Hacker News

Ask HN: If C++ is so bad, what should game developers use?

news.ycombinator.com

71–80 of 127 posts

Re: Ask HN: If C++ is so bad, what should game developers use?

#71
post #62
post #60

C++ violates the Zen of Python's axiom that "explicit is better than implicit" all over the place. C does not; it is very explicit. I would write as much as possible in Python and use C for the performance critical stuff (which, for a game, is a large portion).

I see that you would, but have you? Or did anybody ?

I have worked on major console games and written games in both C and C++. I also maintain an open source raytracer which I've implemented in C, C++, D, and python. So yes, I speak from experience.

Eve online is a great example of a game for which almost all game logic is in python (stackless). The "engine" is in C++, I think (not sure on that one). So I would adopt their model but use C instead of C++.

Re: Ask HN: If C++ is so bad, what should game developers use?

#72

I am under the impression that Lua is widely used for video games.

Lua is often used as an embedded scripting language within level editors, for example to keep track of the progress made on a quest or to trigger an event when the character reaches a certain point. Lua isn't used to code the game engine itself (in the vast majority of cases, there may be some obscure examples of game engines written in Lua)

Right - The stuff that needs high performance or low-level access (e.g. graphics code) is written in C or C++, but most of the "soft layer" is scripted in Lua.

See: http://www.c2.com/cgi/wiki?AlternateHardAndSoftLayers

Re: Ask HN: If C++ is so bad, what should game developers use?

#73
post #71
post #62

Earlier quoted context omitted.

I see that you would, but have you? Or did anybody ?

I have worked on major console games and written games in both C and C++. I also maintain an open source raytracer which I've implemented in C, C++, D, and python. So yes, I speak from experience. Eve online is a great example of a game for which almost all game logic is in python (stackless). The "engine" is in C++, I think (not sure on that one). So I would adopt their model but use C instead of C++.

Also Civilization 4 used Python extensively:

http://www.python.org/about/quotes/ (look for "Firaxis Games")

Re: Ask HN: If C++ is so bad, what should game developers use?

#74
post #35
post #25

Earlier quoted context omitted.

I didn't say I wanted to use Ruby or Lisp--I was simply denying the parent's point that one would have to "write the graphics libraries from scratch." Besides, isn't the advice for optimizing every other kind of project: 1. Start in a high-level language 2. Port any bits that profile as slow to a low-level language, and then interface them into your HLL code Why, all of the sudden, when you're coding a game, is it a…

That advice never works. The problem is data structures . If your high-level prototype uses complex data structures of e.g. Python, you will not be able to access them from C++. You will need to rewrite the whole thing anyway. The only way you might get away with this approach is if your application is essentially a number of separate scripts that communicate through files. Then you can rewrite the key scripts in C++…

While rather similar to Python, Lua has a simple stack-based C API that makes this far less of a problem. OTOH, Lua was designed for embedded use from the start, and its stand-alone interpreter comes second.

Re: Ask HN: If C++ is so bad, what should game developers use?

#75

I am under the impression that Lua is widely used for video games.

Lua is pretty popular because it is a simple scripting language that you can either run in an interpreter, or compile to C. The interpreter is easily embeddable, and you can call C functions from it. All of this makes for pretty rapid development without sacrificing speed for the things that it is suitable for.

Just a nitpick - Lua doesn't compile to C, but rather to Lua VM bytecodes that can be embedded as data in C code.

Lua strikes me as a much nicer interface to C libraries.

Re: Ask HN: If C++ is so bad, what should game developers use?

#76

Don't let them scare you away... C++ is fine if you use what you need and take the time to actually understand the tools you're using.

Language X is fine if you use what you need and take the time to actually understand the tools you're using.

You can justify using any language by saying that. Such a vague statement.

Re: Ask HN: If C++ is so bad, what should game developers use?

#77
I'm not sure how ready it is now, but Haskell's nested data parallelism might be worth looking into as a forward strategy for things like physics and in-CPU graphics engines, since it should make very effective use of many-core processors and is expected to later (transparently) gain the ability to distribute work onto the GPU. This is if you want to do something more fancy than OpenGL, such as ray-trace or use splines.

Haskell's extreme facility with small light threads and its implicit parallel "strategies" could also make updating a rule based game board an almost mathematical, rather than detail-grovelling exercise.

You will not be able to get monkeys to program in Haskell. Whether this is a problem depends on your plans.

Re: Ask HN: If C++ is so bad, what should game developers use?

#78
post #12
post #9

I'm with you. Whatever you use, don't choose C++. Sure, everyone on your programming team knows C++ already. Yeah, your libraries are all written in it. And successful games have used it again and again. But if it's not one of the "cool" languages, you shouldn't be using it. Modern game developers should code in Ruby/Lisp. By the time you've finished coding all of your graphics libraries from scratch, Moore's law wil…

Wait, so why can't you use the C++ libraries from Ruby/Lisp?

[deleted]

Re: Ask HN: If C++ is so bad, what should game developers use?

#79
post #62
post #60

C++ violates the Zen of Python's axiom that "explicit is better than implicit" all over the place. C does not; it is very explicit. I would write as much as possible in Python and use C for the performance critical stuff (which, for a game, is a large portion).

I see that you would, but have you? Or did anybody ?

I saw a game that used Python (I think, maybe it was Ruby) and then dropped down to C for the high-performance bits and it was still slow as shit because of the Python code.

Re: Ask HN: If C++ is so bad, what should game developers use?

#80
post #76

Don't let them scare you away... C++ is fine if you use what you need and take the time to actually understand the tools you're using.

Language X is fine if you use what you need and take the time to actually understand the tools you're using. You can justify using any language by saying that. Such a vague statement.

Precisely!

That's kind of the point, isn't it? I use the languages that I am most familiar with, because I am far more effective with them than I am with whatever this year's new awesome language is.

If I had been doing Ruby from the beginning, then I should continue doing Ruby, and not use C++ just because someone else says so. Likewise, if I've been doing C++ for as long, it doesn't make sense for me to switch to Ruby just because someone else doesn't like C++.

This stuff is so much nonsense. I think I will start using programming language evangelism as a reliable marker of a less experienced programmer.

Post reply on HN