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.