Live data from Hacker News

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

news.ycombinator.com

51–60 of 127 posts

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

#52
post #29
post #14

Earlier quoted context omitted.

Well, for once, it's not particulary fast, but that's not a concern for all games(it's not slow either, but it's quite hard to optimize). The real deal is that it's a completely functional language with not much support, as far as games go. You won't find any graphics libraries, so you'll have to make them from scratch. Unless you have been programing in funcitonal languages for a long time, this will take an absurd…

You won't find any graphics libraries, so you'll have to make them from scratch Haskell has OpenGL bindings: http://www.haskell.org/haskellwiki/Opengl So does OCaml: http://glcaml.sourceforge.net/

I've used Haskell's OpenGL libraries some, and definitely recommend them over C++. OpenGL's callbacks feel much more natural in a functional language and the monadic do notation works very well at managing nested matrix transformations. Also, having an interpretive shell to play around with the types of functions is very useful.

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

#53
post #45

Earlier quoted context omitted.

Type-inference is needed in C++ (and is already part of the next standard, you can enable the auto keyword with gnu gcc already). But it's needed for entirely different purposes than what scripting languages use it for: it's a feature for writing better templates. It's confusing because there are two types of type-inference (run-time and compile-time). You do lose performance with run-time type-inference, which is wh…

Err, by "runtime type inference", you actually mean runtime type checking , right? The pipe dream you are talking about has a tiny hope of coming true here: http://www.bitc-lang.org/ EDIT: replying to thras, below. According to the very Wikipedia article you cited, there is no such thing as "runtime type inference". What you described as such is a way of implementing dynamic type checking: checking at runtime that th…

Hmm. Check this out: http://en.wikipedia.org/wiki/Type_inference

Type checking is a little different, and refers to some safety measures done at compile time that theoretically guard against certain types of errors. Scripting languages don't do them, and don't miss out on much programming correctness as far as I can tell.

Full run time type inference in C++ is about having a container of something -- let's say void pointers that just point to memory locations, and figuring out what sort of thing they're pointing at. Or similarly, you have a base-class pointer and want to figure out which derived version of the object is being pointed at.

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

#54

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)

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

#55
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++…

Part of Civ IV (mostly gui stuff) is in python. They seem to be able to communicate with the C++ core fine.

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

#56
post #23

There is a very interesting talk by Tim Sweeney to this topic: http://lambda-the-ultimate.org/node/1277

His point about fp appears to get no traction in video game developers around me. I heard some iPhone app developers are trying to use Haskell to create games, though.

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

#58
post #45
post #38

Earlier quoted context omitted.

The complexity is "baroque" because, in modern times, we've invented ways around it. Type inference would kill half of the pain involved in C++ without sacrificing performance. Cleaning up the syntax enough that definitions could be found context-free would eliminate the need for declarations, and in most cases .h/hpp files. The complexity is redundant because they included features of C that they should have depreca…

Type-inference is needed in C++ (and is already part of the next standard, you can enable the auto keyword with gnu gcc already). But it's needed for entirely different purposes than what scripting languages use it for: it's a feature for writing better templates. It's confusing because there are two types of type-inference (run-time and compile-time). You do lose performance with run-time type-inference, which is wh…

By "type inference," I just meant "that clever stuff Haskell does." :)

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

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

Post reply on HN