Thread overview
What would be the advantage of using D to port some games?
Jun 24, 2020
matheus
Jun 24, 2020
IGotD-
Jun 24, 2020
matheus
Jun 24, 2020
IGotD-
Jun 24, 2020
matheus
Jul 20, 2020
RegeleIONESCU
Jul 20, 2020
Laurent Tréguier
Jul 21, 2020
RegeleIONESCU
Jul 21, 2020
Johan
Jul 21, 2020
JN
June 24, 2020
Hi, I currently use D for small CLI/Batch apps, before that I used to program in C.

Despite of using D I usually program like C but with the advantage of: GC, AA, CTFE and a few classes here and there.

As we can see there are a lot of old classic games source available like: DOOM, Duke Nukem 3D, Red Alert and most them written originally in C/C++.

What I'd like to know from the experts is: What would be the advantage of using D to port such games?

Thanks in advance,

Matheus.
June 24, 2020
On Wednesday, 24 June 2020 at 18:53:34 UTC, matheus wrote:
>
>
> What I'd like to know from the experts is: What would be the advantage of using D to port such games?
>

Can you elaborate your question a little bit more. Why would you want to port existing game code to another language to begin with? When you mention "advantage", advantage compared to what? Porting to another language at all, porting to another language other than D? In that case what other languages would you have in mind?


June 24, 2020
On Wednesday, 24 June 2020 at 19:14:48 UTC, IGotD- wrote:
> On Wednesday, 24 June 2020 at 18:53:34 UTC, matheus wrote:
>>
>>
>> What I'd like to know from the experts is: What would be the advantage of using D to port such games?
>>
>
> Can you elaborate your question a little bit more. Why would you want to port existing game code to another language to begin with?

To see how the game could fit/run in D, like people are porting some of those games to Rust/Go and so on.

> When you mention "advantage", advantage compared to what?

To the original language the game was written. For example taking DOOM (Written in C), in D what would be the features that someone would use to port this game, like using CTFE to generate SIN/COS table would be reasonable?

I'm just looking for a roughly idea of this matter.

Matheus.
June 24, 2020
On Wednesday, 24 June 2020 at 19:28:15 UTC, matheus wrote:
>
> To see how the game could fit/run in D, like people are porting some of those games to Rust/Go and so on.
>
>> When you mention "advantage", advantage compared to what?
>
> To the original language the game was written. For example taking DOOM (Written in C), in D what would be the features that someone would use to port this game, like using CTFE to generate SIN/COS table would be reasonable?
>
> I'm just looking for a roughly idea of this matter.
>

A previous game implementation in D would be interesting and if you do it you are welcome to write your about experiences here. It's hard to say what features you would take advantage in D as I haven't seen the code in C/C++. However, one thing is clear D would be an easy port because it is so close to C/C++. Every algorithm can be ported directly without any bigger change. If it would Rust you would probably have to rethink some of the data structures and it would be more difficult. Another thing that is clear is that productivity would be high. With today's fast machines and old games you don't have to worry about any GC pauses as there is plenty of time for that. You can basically use the slow "scripting language" features of D. I would expect that D is in the C# ball park in productivity for such task.
June 24, 2020
On Wednesday, 24 June 2020 at 19:46:55 UTC, IGotD- wrote:
> A previous game implementation in D would be interesting and if you do it you are welcome to write your about experiences here. It's hard to say what features you would take advantage in D as I haven't seen the code in C/C++. However, one thing is clear D would be an easy port because it is so close to C/C++. Every algorithm can be ported directly without any bigger change. If it would Rust you would probably have to rethink some of the data structures and it would be more difficult. Another thing that is clear is that productivity would be high. With today's fast machines and old games you don't have to worry about any GC pauses as there is plenty of time for that. You can basically use the slow "scripting language" features of D. I would expect that D is in the C# ball park in productivity for such task.

Thanks for the information. Yes I am thinking about doing it but at the same time I wonder if it's worth (technically speaking) port those games.

I'll analyze if there's any part that could take the advantage of some D features that lacks in C/C++.

Matheus.
July 20, 2020
On Wednesday, 24 June 2020 at 21:14:35 UTC, matheus wrote:
> On Wednesday, 24 June 2020 at 19:46:55 UTC, IGotD- wrote:
>> .

Hello!

I was wondering why some game related packages/libraries are not being developed anymore or are kind of paused. Fore example the last version of derelict-sdl2 is an alpha from May 2018. Lack of people to develop it, to take care of it or is kind of language focus shift?
July 20, 2020
On Monday, 20 July 2020 at 19:49:52 UTC, RegeleIONESCU wrote:
> Hello!
>
> I was wondering why some game related packages/libraries are not being developed anymore or are kind of paused. Fore example the last version of derelict-sdl2 is an alpha from May 2018. Lack of people to develop it, to take care of it or is kind of language focus shift?

The derelict-* packages are being superseded by bindbc-* packages as far as I know, so bindbc-sdl is probably what you want now: https://code.dlang.org/packages/bindbc-sdl
July 21, 2020
On Monday, 20 July 2020 at 20:03:05 UTC, Laurent Tréguier wrote:
> On Monday, 20 July 2020 at 19:49:52 UTC, RegeleIONESCU wrote:
>> Hello!
>>
>> I was wondering why some game related packages/libraries are not being developed anymore or are kind of paused. Fore example the last version of derelict-sdl2 is an alpha from May 2018. Lack of people to develop it, to take care of it or is kind of language focus shift?
>
> The derelict-* packages are being superseded by bindbc-* packages as far as I know, so bindbc-sdl is probably what you want now: https://code.dlang.org/packages/bindbc-sdl

Thank you very much!
July 21, 2020
On Wednesday, 24 June 2020 at 18:53:34 UTC, matheus wrote:
> Hi, I currently use D for small CLI/Batch apps, before that I used to program in C.
>
> Despite of using D I usually program like C but with the advantage of: GC, AA, CTFE and a few classes here and there.
>
> As we can see there are a lot of old classic games source available like: DOOM, Duke Nukem 3D, Red Alert and most them written originally in C/C++.
>
> What I'd like to know from the experts is: What would be the advantage of using D to port such games?

Rather than starting with the mindset of "advantage", I think it is much more valuable to treat it as an investigation of both disadvantages and advantages.

Things that come to mind:
- Try without GC: how hard is it to avoid the GC? Should be easy because you are porting from non-GC code, but maybe it isn't so natural. I would try to 'port' the code in a way that makes the code look like natural D code (instead of just looking like C code that was made to compile with a D compiler).
- Try with GC: what is the effect on the code and design? What is the effect on runtime behavior?
- Note that those games were written with specific avoidance of some C/C++ features and specific C/C++ style-guide and conventions. Can you try to "port" those avoidance/style/convention ideas? (i.e. What arguments were used to avoid those C/C++ features and what D features would have been avoided with similar arguments?)
- The original code is probably optimized in certain perf critical areas for the particular compiler used and common hardware at that time. How are you going to treat that aspect?
- Delegates are not a thing in C. So the design of the programs probably does not feature heavy use of delegates. But maybe the code does handroll some design concepts that are easier in newer languages: manual dynamic polymorphism? manual delegates? manual GC? preparser magic instead of templates? etc. Try to recognize that and change the core to use the new language features.

-Johan

July 21, 2020
On Wednesday, 24 June 2020 at 18:53:34 UTC, matheus wrote:
> Hi, I currently use D for small CLI/Batch apps, before that I used to program in C.
>
> Despite of using D I usually program like C but with the advantage of: GC, AA, CTFE and a few classes here and there.
>
> As we can see there are a lot of old classic games source available like: DOOM, Duke Nukem 3D, Red Alert and most them written originally in C/C++.
>
> What I'd like to know from the experts is: What would be the advantage of using D to port such games?
>
> Thanks in advance,
>
> Matheus.

The advantage is that you have a fun programming project and a challenge. And you don't have to worry about being stuck on the code or art side, because all those are ready for you, you just have to rewrite it in a different language.

Also, when finished, it makes for a fun blog post about challenges of porting C/C++ code to D and which parts were simplified using D features.

I was thinking of porting something like Doom to D also (DooD?), but never got around to it. I guess one could start with a betterC port too.