The D Programming Language for Game Development [closed]
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
开发者_如何学CClosed 3 years ago.
Improve this questionRecently 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!
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++
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
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.
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!
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
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/ .
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.
The folks calling themselves "team0xf" did this entirely in D1.
Remedy (Max Payne, Alan Wake, Quantum Break) are using D : http://dconf.org/2013/talks/evans_1.html
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.
精彩评论