Sign in to follow this  

D for game programming anyone?

This topic is 4681 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! Is anyone using D programming language for games programming? I am only asking because I looked at it for two days and I like it very much now. Maybe it gives little less performance in some cases but I love it because it code looks clean and it has carbage collection and compiletime is almost nothing.

Share this post


Link to post
Share on other sites
Quote:
Original post by stefu
Is anyone using D programming language for games programming? I am only asking because I looked at it for two days and I like it very much now. Maybe it gives little less performance in some cases but I love it because it code looks clean and it has carbage collection and compiletime is almost nothing.


Yes, there are a few people on the D newsgroup who have been using it, and a Japanese fellow has put out 3 or 4 freeware games with D. If you wish to pursue this further, be sure to check out some of the projects at DSource. One of the projects there, called Derelict, is a collection of bindings for several C libraries useful for game programming. So far it includes bindings for: OpenGL, GLU, OpenAL, SDL, SDL_image, SDL_mixer, and SDL_net. Someone just completed a GLFW package which will be added soon. Be sure to check out the current source from the repository via subversion. The zip archive available for download there is rather old and does not contain all of the packages. A new release archive is coming soon.

If you need any help with D, the DigialMars D newsgroup is the place to look for it.

Share this post


Link to post
Share on other sites
I've used D for a number of programs, and it's a very good language. This was a year or so ago though, and the community support, compiler and libraries were not quite there yet. If there are OpenGL, DirectX, SDL, etc bindings and the compiler is stable enough for "serious" programs, there's no reason why you couldn't use it.

There might be a small problem with the garbage collection though. I'm not sure which implementation it's using, but there should be a way to define when it should collect. You definately don't want it collecting in the middle of rendering a frame.

Share this post


Link to post
Share on other sites
D is great for game programming!

I was using D for a game engine that was interrupted by my current project. Just little things like _no preprocessor_, no cpp/h file division, nice delegates, associative arrays (fast ones, too!) were really nice in setting up a clean, object oriented engine/base.

You're welcome to look at it--right now the scripting engine loads some configuration from a Lua script and it draws an ugly space scene. Oh and it uses SDL for the underlying windowing system so technically you could port it to Mac/Linux with a bit of effort. It builds with a program called "Scons," I highly recommend you try it if you're going to get into D. If you want to build it yuo'll have to edit the "Sconstruct" file in the main directory to point to where you have the D compiler stored on your PC. Other than that, it should be okay--SDL and OpenGL Win32 libraries are sitting where they need to be.

Point sprites for the stars is a nice performance thing...the "space scene" around you is drawn sky-box style, i.e. it inherits the camera's rotation but not its direction. There's some CG framework stuff in there too. Oh and the Model class is ugly as all sin at the moment (probably indefinitely) but its based on a RealSoonNow tutorial for loading Milkshape models. Also the beginnings of a GUI system are in there, I think buttons and dragging windows around works.

Anyways there's not much documentation, but you're welcome to take a look through it and maybe you can find it helpful :)

The "kengine" -- download link here (4mb). (Taken down, message me if you'd like me to email it to you.)

[Edited by - snowblind329 on February 17, 2005 1:17:13 AM]

Share this post


Link to post
Share on other sites
Other stuff: compile time, like you mentioned, is blazingly fast. I went back to C++ after working with the D compiler for awhile and that's probably what I missed the most.

And for garbage collection...I didn't get far enough with the object system to really see how much of an impact it would have. Heavy-weight game objects, each associated with a Lua coroutine--it might have become an issue. But the Digital Mars website has some good starter tips for memory management, and they're big on pointing out that you can do everything from use freelists to write your own custom allocator, so don't let it stop you from at least trying out the language.

Share this post


Link to post
Share on other sites
The garbage collector shouldn't get in the way unless you're doing something that's very gc-unfriendly, like allocating hundreds of objects each frame. If it ever does, D allows you to bypass it completely. You can write an entire program without the GC if you so desire. You can also delete GC-allocated objects at any time. So there's a lot of flexibility there. But really, for the large majority of cases it is unlikely that the GC will be an issue at all. Code to the GC first. If it proves to be a bottleneck, either make your code more GC-friendly (as you would in Java) or use one of the other options D provides.

Share this post


Link to post
Share on other sites
Hi!
Thank you fo all comments, very helpful. Not many tutorials out there for D. But the language manual is good.

I think I will do somthing in D now just for fun. Opengl, glfw, glee, vbo mesh and ttfont works already. I have always failed memory management in C++ when project grows and this is gift for me.

D indeed seems to allow manual gc through std.gc module, like disable(), enable(), fullCollect(), genCollect(). And there are method explained hot to get smooth operation so I don't believe it will be a problem, but I'll be more clever later.

@snowblind329
Thanks for the kengine, it is very good for learning language. It is much the same I am doing. I'll compile later, I have to take a look at Scons first.

Share this post


Link to post
Share on other sites
I've heard of D in the past, and this thread sort of caught my interest in it. So I went to their website to see it, and it really does look interesting. I made a post in the D newsgroup a minute ago, if you care to look. I'm going to try it and see how it works; hopefully it will be okay.

Thanks guys.

Share this post


Link to post
Share on other sites
The stuff at DedicateD is old, old, old and will not compile properly under the current version of DMD without heavy modification. Everything at the DedicateD has been rewritten and updated. You can find various versions around the net, but the best place to look is DSource.org. The socket bindings are no longer needed as there is now a binding in D's standard library, Phobos (std.socket and std.sockstream). You can also find a higher level server API in the Mango project at DSource, built on top of std.socket.

Share this post


Link to post
Share on other sites
Wait, I thought D was compatible with C so you could just call C functions direct? Why all this OpenGL etc. binding buisiness?

D has had my interest for a while now. I use Java + OpenGL almost all the time and D seems like a nice compromise between the clean code of Java and the low-level details of C++. The only real question is how mature the tools are...

Share this post


Link to post
Share on other sites
Quote:
Original post by OrangyTang
Wait, I thought D was compatible with C so you could just call C functions direct? Why all this OpenGL etc. binding buisiness?

D can use C libraries directly, but you need D module because D can not use C headers. You just need to convert C header file to D module so that D knows all the functions, constants (defines) and data types. It is not wrapper, no code requierd, just 'header' indofmration.

Yesterday I wrote D binding for ODE and it is working well :)

Share this post


Link to post
Share on other sites
Quote:
Original post by OrangyTang
The only real question is how mature the tools are...


It's all a grassroots effort right now. DMD has not reached 1.0 yet, and the GNU version, GDC, is lagging it a little bit I think (I don't really follow GDC yet, until I get a Mac). And I think we should rephrase your question to 'how many tools there are', because that's what is sorely lacking at the moment. Multiple projects have been started for IDEs, cross platform GUI libraries, debuggers, build systems, h2d converters, and so on. They are all in various stages of completion, some lying dead and dormant. At DSource.org there are at least 3 GUI projects, but only one, MinWin, is active (and looking very promising).

Right now, I'm finding it's not difficult to develop with a text editor, makefiles, and WinDebug on Windows or gdb on linux... but I'm dying for a good IDE. I started to look into a plugin for Code::Blocks, but I really don't have the motivation to deal with it.

One thing I really like about D right now is that this is the ground floor. Nearly anything you contribute right now will make a difference, either as something the community can use or something they can build on. And the more that is contributed, the more that is developed. Plus, there's a book on D programming in the works by D's father, Walter Bright, and Matthew Wilson (of Synesis Software and Imperfect C++). Once that's out in a year or so D 1.0 should be out as well and the beginning of a nice little market for good D tools (be they open source, freeware, shareware, or commercial) will have taken root. There aren't any completed game engines or game tools yet, but eventually the demand will be there for them. Lots of potential for those who are working on projects now.

Share this post


Link to post
Share on other sites
I started playing with D but gave up because there wasn't much to work with. I was still waiting for the DTL, the 'D' version of the STL - without that I found myself really frustrated, having to write my own containers and stuff that I would just do in a few lines with STL.

How's the DTL coming along? There was some guy working on the MinTL, but I don't know how far he got with that.

Share this post


Link to post
Share on other sites
The "Japanese fellow with 3 or 4 freeware games" written in D is Kenta Cho, great games. ABA Games is his site, all games have D sourcecode available. They're very abstract, and not exactly pushing the CPU or GPU to the max, but I would say its proof that you can make great games in D.

Share this post


Link to post
Share on other sites
I really like a lot of the features (I love you slicing!, and UTF8 for strings r0x0rz), but until it gets a little more popular, I'll probably pass.

Now, if someone were to develop an addon to integrate D with VS.Net... that would be just nifty.

Share this post


Link to post
Share on other sites
Quote:
Original post by evolutional
How's the DTL coming along? There was some guy working on the MinTL, but I don't know how far he got with that.


DTL hasn't progressed much in the last few months. That's Matthew's puppy, and his plate has been full. The last release was 0.2 back in August. With all he has on his plate (Imperfect C++, STLSoft, and now the D book) I doubt it will make much progress in the near future. In early December he laid out a list of stuff he was working on for it, but that was the last he said of it.

MinTL is developed by Ben Hinkle. Right now, it's still in a beta state but has several usable containers. I know some people have mentioned using it on the NG. Ben also is the author of Concurrent (a D port of Doug Lea's Java package) and MinWin, a minimal, xplatform GUI system.

I haven't found the need to use anything beyond D's builtin associative arrays and regular arrays yet, though I may have need of something more soon. The thing about D is that you can use associative arrays anywhere you would normally use a hash map, and using builtin array properties and operations you can whip up a simple vector-like class in a few lines of code. MinTL has several forms of linked lists, queues, stacks, and some containers that enhance the functionality of arrays and associative arrays.

Nothing about D, from the compiler and standard library to the third party libraries being developed by community members, is really ready to be used in production. Everything is in varying states of stability, and bugs abound. If you need to start cranking out production code today, D certainly isn't what you should be using. A year from now, yes, but not today.

But I do reccommend that anyone who has a passing interest in the language play around with it in their free time and get familiar with it. Even if you have no desire to pump out any tools or libraries, you still could pass bug reports and feature requests to the newsgroup. Though there's a freeze on new features for D 1.0, Walter has been taking note of new ideas for D 2.0. Many of the features the language has now evolved from discussions on the NG. Though he's quite stubborn on some issues (like the infamous bit vs. int for bool debate), he does listen and will make changes to the spec where warranted.

Share this post


Link to post
Share on other sites

This topic is 4681 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this