Jump to page: 1 2
Thread overview
Can you port a 45+kloc commercial C++ game to D?
Oct 03, 2005
Kai Backman
Oct 03, 2005
Walter Bright
Oct 03, 2005
Kai Backman
Oct 03, 2005
Walter Bright
Oct 03, 2005
Tom S
Oct 03, 2005
clayasaurus
measuring LoC ?
Oct 05, 2005
Bruno Medeiros
Oct 06, 2005
Thomas Kühne
Oct 06, 2005
zwang
Oct 06, 2005
JT
Oct 06, 2005
Thomas Kühne
Oct 06, 2005
Ben Hinkle
Oct 06, 2005
Walter Bright
Oct 06, 2005
Markus Dangl
Oct 06, 2005
Kai Backman
October 03, 2005
 Hello everyone and nice to be around,

 My day job is developing a commercial space station game called ShortHike.
It's a constantly evolving project and has been in production since 2002 and
selling online since Feb 2003. The current unstable version contains about
45,000+ lines of custom C/C++ code. The code is pretty streamlined,
I've had plenty of time to keep things clean and refactored. I use only basic
C++ functionality and a extremely limited set of external C libraries.  An
important part of my development strategy is flexibility and gradual
improvement of the game. There is also a separate (custom) scripting layer.
I'm the only developer working on the code. The base code has been
through 6 larger rewrites/refactorings since the project started (60-80% of code
reworked), and is partially based previous work dating back a few years or so.

 Part of a larger rewrite I'm reconsidering my strategy to use C++ for the base
layer. After evaluating the usual suspects (C++/C#/Java) D looks like the most
viable candidate. All the external dependencies already have D headers or they
would be easy to produce.

So here are my specific questions:
- Is it currently feasible to port a commercial 45kloc C++ program to D?
- For those with actual experience doing this, what problems do you foresee I will
encounter in the process?
- Alternatively, what are the experiences in writing 50k loc applications in D?
- Can you point me to shipping application in the 30k-60k range?

 I would appreciate all input I can get to help me make the decision. This
project provides bread on the table so you can understand I want to do my due
diligence.. :-)

 You can find out more about the game at: http://www.shorthike.com

 Thanks in advance for the replies and insight!

  Take care,

 Kai

--
Kai Backman, programmer, kai@shorthike.com http://www.ShortHike.com - space station game

October 03, 2005
"Kai Backman" <kai@shorthike.com> wrote in message news:2005103113238.284032@birch...

- Is it currently feasible to port a commercial 45kloc C++ program to D?

Yes.

- For those with actual experience doing this, what problems do you foresee
I will
encounter in the process?

You may need to rethink the memory allocation strategies you'er using.

- Alternatively, what are the experiences in writing 50k loc applications in D?

DMDScript was converted from C++ to D, and it took about 2 weeks.

- Can you point me to shipping application in the 30k-60k range?

DMDScript.

Good luck! -Walter


October 03, 2005
 On Mon, 3 Oct 2005 11:49:45 +0300, Walter Bright wrote:
> - Can you point me to shipping application in the 30k-60k range?
>
> DMDScript.

 Thank for the quick reply Walter. The D version is roughly 22kloc. How
many kloc was the C++ version? (To get a rough C++->D ratio)

 Kai

--
Kai Backman, programmer, kai@shorthike.com http://www.ShortHike.com - space station game


October 03, 2005
Hi there !

I've been developing a 3d game engine in D for about a year now. I'm using
OpenGL with SDL, SDLttf, OpenIL, Cg and more. The LOC count for the moment being
is about 35k (not counting the above libs or their bindings of course). I don't
have recent demo, but I'll be releasing one soon, with complete source code.
I'm actively working on the rendering subsystem, trying to make it compatible
with cards from RivaTNT to Geforce6 and a similar range of ATI cards, though
still use the best features available on a given GPU (I'm implementing the
shader/vertex cache system that YannL proposed on gamedev.net's forums). I'm
also in the middle of some debugging work, since completely redesigning my
rendering pipeline has produced a few bugs.
Having experience with C++ programming, I think it would take about 30% more
lines of code to produce the same result in that language. Furthermore, the
debugging effort would have to be much greater.
Making a complex D application isn't a dream though. You'll have to fight your
way through compiler bugs and somehow different memory management strategies.
For instance, I'm currently using dmd.132 because dmd.133 introduced an obscure
bug in nested functions that I hasn't been able to isolate yet. I'm also using
lots of malloc/free because the default new/delete are connected to the GC,
causing any memory-intensive application to hang occasionally. E.g. while doing
photon mapping on a 1M polygon model, memory use in my engine can get as high as
400 - 500MB and a fullCollect of the GC takes about 10seconds on my Athlon 2k+
512RAM.
Nevertheless, I think that switching to D was a great choice... I have
considered switching back to C++ at a few points (extreme frustration at the
GC), but just thinking how much cleaner, easier to write and debug D code is,
I've had the motivation to stick to D. In the long run, I've never regretted it
:)

My project is being developed on dsource: http://dsource.org/projects/fragbots/
 The forum's got a few links to old and ugly demos of the engine ( you can
crash the GUI demo by clicking on a listbox with two mousebuttons :D - bug
removed in the current version ).

Good luck with your project !

--
Tomasz Stachowiak a.k.a. h3r3tic


October 03, 2005
You'll see a huge improvement in compile time with D as well.

Kai Backman wrote:
>  Hello everyone and nice to be around,
> 
>  My day job is developing a commercial space station game called ShortHike.
> It's a constantly evolving project and has been in production since 2002 and
> selling online since Feb 2003. The current unstable version contains about
> 45,000+ lines of custom C/C++ code. The code is pretty streamlined,
> I've had plenty of time to keep things clean and refactored. I use only basic
> C++ functionality and a extremely limited set of external C libraries.  An
> important part of my development strategy is flexibility and gradual
> improvement of the game. There is also a separate (custom) scripting layer.
> I'm the only developer working on the code. The base code has been
> through 6 larger rewrites/refactorings since the project started (60-80% of code
> reworked), and is partially based previous work dating back a few years or so.
> 
>  Part of a larger rewrite I'm reconsidering my strategy to use C++ for the base
> layer. After evaluating the usual suspects (C++/C#/Java) D looks like the most
> viable candidate. All the external dependencies already have D headers or they
> would be easy to produce.
> 
> So here are my specific questions:
> - Is it currently feasible to port a commercial 45kloc C++ program to D?
> - For those with actual experience doing this, what problems do you foresee I will
> encounter in the process?
> - Alternatively, what are the experiences in writing 50k loc applications in D?
> - Can you point me to shipping application in the 30k-60k range?
> 
>  I would appreciate all input I can get to help me make the decision. This
> project provides bread on the table so you can understand I want to do my due
> diligence.. :-)
> 
>  You can find out more about the game at: http://www.shorthike.com
> 
>  Thanks in advance for the replies and insight!
> 
>   Take care,
> 
>  Kai
>  --
> Kai Backman, programmer, kai@shorthike.com
> http://www.ShortHike.com - space station game
> 
October 03, 2005
"Kai Backman" <kai@shorthike.com> wrote in message news:200510312219.080693@birch...
>On Mon, 3 Oct 2005 11:49:45 +0300, Walter Bright wrote:
>> - Can you point me to shipping application in the 30k-60k range?
>>
>> DMDScript.
> Thank for the quick reply Walter. The D version is roughly 22kloc. How many kloc was the C++ version? (To get a rough C++->D ratio)

C++ version:
    dscript source: 736,957 bytes
    support code:  ~300,000
    total:                1,036,957

D version:
    dscript source: 505, 806
    support code: 0
    total:                505,806

By "support code" I mean things like the gc, symbol tables, string handling, UTF support, array handling, regular expressions, etc. In D, those are handled either in the core language or in the standard library. (I broke them out separately because many would argue that in C++ one could use STL or Boost.) The D version is a line by line conversion of the C++ code, and the comments in the code are the same.

The D version runs faster, too <g>.


October 05, 2005
Btw, how is any of you measuring LoC ? (with what tool I mean)

-- 
Bruno Medeiros - CS/E student
"Certain aspects of D are a pathway to many abilities some consider to be... unnatural."
October 06, 2005
Bruno Medeiros schrieb:
> Btw, how is any of you measuring LoC ? (with what tool I mean)
> 

http://thomas.kuehne.cn/tools/locd.html

Thomas


October 06, 2005
Bruno Medeiros wrote:
> Btw, how is any of you measuring LoC ? (with what tool I mean)

I use sloccount ( http://www.dwheeler.com/sloccount/ ). The output is a bit weird but it works :)
Looks like there is no Windows binary :(
October 06, 2005
Thomas Kühne wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Bruno Medeiros schrieb:
> 
>>Btw, how is any of you measuring LoC ? (with what tool I mean)
>>
> 
> 
> http://thomas.kuehne.cn/tools/locd.html
> 
> Thomas
> 
> 
> -----BEGIN PGP SIGNATURE-----
> 
> iD8DBQFDRG423w+/yD4P9tIRAkEkAJ9oI0/YG2OJVkM3yTqYThCsDmewGgCeKC9m
> 9G+vqoYnORdGrsSrKowPfJQ=
> =ioQ0
> -----END PGP SIGNATURE-----

Call me paranoid, but the first thing I throw to LoCd is a zero-byte file. And Bang! Access violation. :)
« First   ‹ Prev
1 2