The D Programming Language for Game Development [closed]

Recently I've been bothered because I reached a point in which C++ (even 0x) felt very limited, so I started looking for alternatives.

Forget Java, C#, Python or Ruby. I still like the low-level nature of C++ and I'm not fond of virtual machines. Further, I'm a game engine developer, so I have to develop core routines which must be really fast, and lately I've been hungry for code expressiveness. C++ is an almost-there language for me, but there are many exceptions on how to use templates, and GCC isn't optimizing stuff as well as I'd hoped it would.

So I'm considering to start learning D.

Do you think it will suffice my needs as a game developer? I'm wary because I've never heard of D being used for that.

Thanks!


Solution 1:

I used D 1.x for doing games and demos, some of them are public domain open source (A, B, C, D, E).

D can give you productivity unheard of in C++-land if you are willing to pay the high-price of arguing with everyone about why do you use D.

If you go this route, i advise you to pick D 2.x, Derelict and Visual D (hint for future readers: this is 2011).

As for game development :

  • the D GC is not a real problem. It is if you allocate too much in a frame, but that's about it. The classic methods of pooling, reusing, etc... work.

  • you can write x86 assembly portably across Linux, Mac & Windows. Also static if allows pretty fun templated naked assembly functions.

  • inlining across module boundaries is working without a "link time optimization" switch

  • I find it easier to maintain debug and release version (compared to C++)

  • avoid new features and choose compilers conservatively... just like in C++

Solution 2:

Kenta Cho uses D and Simple DirectMedia Layer(SDL) to develop his Windows games. They're a lot of fun. Take a look for inspiration and source:

  • Titanion
  • Torus Trooper
  • Gunroar

Solution 3:

D is a great language for video games, it has all the features for the rapid development of a performant executable:

  • It compiles fast to native code and runs fast.
  • Has unit testing, profiling and code coverage out of the box.
  • Garbage collection is the default, but you can use your own memory allocators.
  • ABI-compatible with C, there's no marshalling cost to pay to call native libraries.
  • Thread-safety in the type-system: shared, pure and immutable qualifiers.
  • Memory-safety in the type-system: @safe, @trusted, @system.
  • Compile-time function evaluation, code generation, and more.

You don't need a separate scripting language, no additional compilation steps to generate code, you're not limited to the memory model of a virtual machine when performance matters for low-level systems yet you get all the productivity and safety of scripting and managed languages for your game logic. You're even free to choose between procedural, object-oriented, functional, generic or meta programming paradigms for the problem at hand.

Solution 4:

Well, it's not like if You're using D you have to build everything completely from scratch. For example, You can use:

  • GLFW for input/output
  • Horde3D as rendering engine
  • OpenAL for sound
  • Bullet for physics
  • Lua for scripting
  • lzo for fast decompression
  • maybe Orange for serialization

I'm not sure about overlays though. It's a pretty solid base which hopefully will work for me :)

Good luck man!