55

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!

Aaron Novstrup
  • 20,967
  • 7
  • 70
  • 108
Gui Prá
  • 5,559
  • 4
  • 34
  • 59
  • 30
    D is a jungle, C++ is a 5-lane motorway, when it comes to how many people have been there before you. I think that's a very telling picture of what working in either language will be like, in terms of bugs with the compiler and libs, changing syntax etc. Me? I _like_ the jungle :) – 0scar Dec 23 '10 at 17:52
  • 8
    No, no, jungle is full of life. D is more like desert. – Honza Jul 10 '12 at 19:05

10 Answers10

24

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++

ponce
  • 919
  • 5
  • 15
16

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:

Corbin March
  • 25,526
  • 6
  • 73
  • 100
9

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.

  • and you don't still have a GL3 wrappre yet :/! – CoffeDeveloper Jan 06 '16 at 01:15
  • 2
    https://github.com/DerelictOrg/DerelictGL3 have been around for a while. Easy to add more as well; there's even a whole repository of packages and a build manager (called dub) which automatically fetches and builds dependencies. – Jeremie Pelletier Jan 06 '16 at 02:19
7

In D proramming they are:

  • derelict who support opengl 3 and opengl 4

most often in a language programming opengl 3 and 4 is not supported

  • yage free 3D game engine, your are welcome to help

A little how-to: http://blog.fedora-fr.org/bioinfornatics/post/D-programming-OpenGL-and-MVC-Pattern

For use RAII in D they are the keyword scope it is very powerfull

bioinfornatics
  • 1,749
  • 3
  • 17
  • 36
7

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!

shd
  • 133
  • 7
5

Welcome to 2014!

The latest version of D is 2.067 as of writing this. D is slightly unstable in regards to auto, but other than that, I don't see why not to use D. The compilers are what have greatly improved.

D in my opinion is easier to read than C++, and easier to learn. It contains an interface to C and a partial interface to C++. It even allows inline assembly that can interact with your variables. The D standard library is called Phobos.

I highly suggest D. D was made for efficiency. According to Adam D. Ruppe, "[C is] equally fast". And C is one of the fastest languages out there. So if you want to build a game with the speed of C and the high-level capabilities of C++, D sits right there inbetween. If you have any questions, feel free to join irc.freenode.net #d.

To sum it all up, D is basically the safe version of C++. While the language is multi-paradigm, including OOP, much emphasis was put on the FP paradigm, using pure functions and immutability. All objects have an init property so if you declare 'int foo;', it is initialized to int.init. Yes, there are still pointers. Pointers in D are called lvalue and values are called rvalue. An lvalue always points to an rvalue.

For more information, visit the official D site, http://www.dlang.org/ .

AMDG
  • 1,118
  • 1
  • 13
  • 29
2

I'm looking forward to learning D language someday too :)

But there's one thing to remember: good language is good, but you, as a game developer, need also tools (like libraries) to do your bidding. And few good libraries currently have bindings to D. However, I know of one that most likely (but not certainly) has:

Ogre - one of the leading, if not leading, free-as-in-freedom library for all your portable 3D graphic needs.

Of course you need more, but that pretty much depends on your game.

I'm not aware on how easy or hard is it to make bindings to D for a C++ library. It may be hard, may be easy and somewhat automated. Latter would be pretty much possible, because, as I take it, languages are very close to each other, and D developers probably had C++ in mind a lot of the time.

Hope this helps.

Septagram
  • 9,425
  • 13
  • 50
  • 81
  • I'm not considering using libraries such as Ogre. Instead, I want to write such libraries from scratch using just Direct3D/OpenGL, XAudio/*nix counterpart, XInput/*nix counterpart, etc. – Gui Prá Dec 23 '10 at 06:24
  • 3
    You may be a game developer, or you may be a game library developer. Whatever you choose, remember it and stick to it from the start of your project to its end. It's easy to get absorbed in wheel reinvention and optimization. But you are building a car, aren't you? If I'm wrong and your intent is precisely to write libs for game development in D, then all the more better, pretty please do so A S A P ! :) – Septagram Dec 23 '10 at 06:44
  • I've used Ogre3D and frankly not 15 MB of what it comes with was what I needed. Currently I'll have to develop a game engine geared towards a particular game, but I really am willing to write a more generic engine later on. In any case, since I have to develop this game soon, I'll probably just stick with C++. I'll save D for the real deal (the actual generic engine). – Gui Prá Dec 23 '10 at 06:54
  • Nah, Ogre doesn't have D bindings. There's quite a lot of interest making one though, perhaps with SWIG's help. – jcao219 Dec 25 '10 at 21:49
1

Remedy (Max Payne, Alan Wake, Quantum Break) are using D : http://dconf.org/2013/talks/evans_1.html

Denis Gladkiy
  • 2,084
  • 1
  • 26
  • 40
1

The folks calling themselves "team0xf" did this entirely in D1.

Baxissimo
  • 2,629
  • 2
  • 25
  • 23
-1

From another perspective, D compiles into the same object files (albeit OMF format) as C/C++. One would assume D's optimization of the assembly is comparable to C/C++, regardless, the assembly is always there to hand optimize if you want.

ste3e
  • 995
  • 1
  • 9
  • 18