Just found this. Seems pretty interesting. Anyone know more about the
developer?
http://www.appleumbrella.com/2011/08/d-psp-emulator-svn-r306/
One thing I like is the use of CustomFloat for defining half-floating
point numbers - one application I had in mind when defining CustomFloat.
Glad to see it works (after the community fixed it :o)).
Andrei

Just found this. Seems pretty interesting. Anyone know more about the
developer?
http://www.appleumbrella.com/2011/08/d-psp-emulator-svn-r306/
One thing I like is the use of CustomFloat for defining half-floating
point numbers - one application I had in mind when defining CustomFloat.
Glad to see it works (after the community fixed it :o)).
Andrei

Just found this. Seems pretty interesting. Anyone know more about the
developer?
http://www.appleumbrella.com/2011/08/d-psp-emulator-svn-r306/
One thing I like is the use of CustomFloat for defining half-floating
point numbers - one application I had in mind when defining
CustomFloat. Glad to see it works (after the community fixed it :o)).
Andrei

Thank you for the link.
I think there is enough evidence that it is possible to use D (V.1) to write
some video games. It's one of the very few niches where D has shown some more
appreciation. So to blow on this tiny fire, do you know ways to improve the D2
language and D2 Phobos to help game development?
-----------------
Some comments on the source code:
The author seems to believe that the right way to name D modules is with a
starting uppercase, like "Event.d".
In the modules I see a large amount of array appends (~=), the author maybe
thinks those are efficient operations, as in C++ vectors.
To simulate a CPU computed gotos help performance. Interpreters are common,
computed gotos are useful to run finite state machines too (and in
computational biology I have had to build such machines. I have used computed
gotos of GNU-C to speed up code).
This again shows that some common basic exceptions are needed in Phobos:
http://code.google.com/p/pspemu/source/browse/trunk/src/pspemu/Exceptions.d
-----------------
With the idea recently discussed this code:
http://code.google.com/p/pspemu/source/browse/trunk/src/pspemu/core/EmulatorState.d
this(Interrupts interrupts, Memory memory, IBattery battery,
IDisplay display, Controller controller, Gpu gpu, Cpu cpu) {
this.interrupts = interrupts;
this.memory = memory;
this.battery = battery;
this.display = display;
this.controller = controller;
this.runningState = runningState;
this.gpu = gpu;
this.cpu = cpu;
resetVariables();
}
Becomes:
this(this.interrupts, this.memory, this.battery,
this.display, this.controller, this.gpu, this.cpu) {
this.runningState = runningState;
resetVariables();
}
This is not just shorter, it's more DRY and less bug-prone.
-----------------
This page:
http://code.google.com/p/pspemu/source/browse/trunk/src/pspemu/core/Memory.d
Contains code like:
class InvalidAddressException : public MemoryException {
I think that "public" needs to become a syntax error.
-----------------
This is bad code, I didn't even know D supports empty catch:
http://pspemu.googlecode.com/svn/trunk/src/pspemu/utils/Expression.d
static long parseString(string s, long default_value = 0) {
if (s.length > 0) {
try {
...
} catch {
}
}
return default_value;
}
-----------------
That asm code for the float[4] vectors are cute, unfortunately they kill
inlining with DMD, so they often produce slower code:
http://pspemu.googlecode.com/svn/trunk/src/pspemu/utils/MathUtils.d
-----------------
This seems at home in Phobos too:
http://code.google.com/p/pspemu/source/browse/trunk/src/pspemu/utils/Types.d
Bye,
bearophile

So to blow on this tiny fire, do you know ways to improve the D2 language and
D2 Phobos to help game development?

There's different levels of game developer. Indies will mostly want
convenience, but AAA developers need control.
For example, a good vector + matrix + quaternion math library would be
great for indies, but AAA developers would likely write their own, even
if the library was highly optimised with SIMD, floatInVec etc.
SIMD intrinsics are obviously essential for AAA development.
The garbage collector is something that still needs work. My current
project has several second stalls every once in a while due to the GC
(indies might be happy to miss a frame or two (30-60ms) but AAA
developers won't, so you either don't use the GC, or it has to collect
in under a couple of ms).
I managed to remove all my per-frame allocations, but this was not easy.
I had to modify my druntime to print out when allocations where
happening to find them (most were those static array initialisations
that I often talk about).
Of course, having libraries available for audio/image
loading/manipulation is helpful, and bindings for OpenGL etc. but those
are already available through Derelict. I don't think they need to be in
Phobos.
The most important thing at the moment is just to get the language into
a usable state and to get all the advertised features working. We also
need more tutorials and resources to explain the subtler parts of D2
(e.g. when, why and how template alias parameters work).

There's different levels of game developer. Indies will mostly want
convenience, but AAA developers need control.<

Right. Both groups are important.

For example, a good vector + matrix + quaternion math library would be great
for indies, but AAA developers would likely write their own, even if the
library was highly optimised with SIMD, floatInVec etc.<

A 2D/3D/4D vector is good to have in Phobos. (Quaternion are optional).

SIMD intrinsics are obviously essential for AAA development.<

The problem is they change as time goes. So instead of adding a ton of those
(ugly) intrinsics, I suggest to add a meta-feature to D: a syntax to write
inlin-able asm expressions (as present in LDC). With this syntax, SIMD
intrinsics become library (even Phobos) code to standardize.

I had to modify my druntime to print out when allocations where happening to
find them (most were those static array initialisations that I often talk
about).<

This is useful. Why don't you create a patch that (when a specific compiler
switch is on) lists at compile-time all heap allocations and closure
allocations of a compilation unit?

The most important thing at the moment is just to get the language into a
usable state<

This will take time, and you can't rush it.
Thank you for the answers,
bye,
bearophile

A 2D/3D/4D vector is good to have in Phobos. (Quaternion are optional).

Quaternions are important for fast 3D rotations, but yes, vectors are
most important.

SIMD intrinsics are obviously essential for AAA development.<

The problem is they change as time goes. So instead of adding a ton of those
(ugly) intrinsics, I suggest to add a meta-feature to D: a syntax to write
inlin-able asm expressions (as present in LDC). With this syntax, SIMD
intrinsics become library (even Phobos) code to standardize.

The problem with that approach is that the compiler doesn't know about
them and will likely have trouble optimising. GCC will optimise SIMD
intrinsic math in the same way that it optimises scalar math.
Also, unless I'm mistaken, you can't use inline assembly to define a
vector type whose storage is an xmm register. In GCC, you'd do
typedef __m128 Vec4;
or at least
struct Vec4 { __m128 m_xyzw; };
This ensures that when you return them or pass them into a function then
they are passed in registers and don't have to go through memory. Can
you do that in LDC? (I'm not familiar with it).

I had to modify my druntime to print out when allocations where happening to
find them (most were those static array initialisations that I often talk
about).<

This is useful. Why don't you create a patch that (when a specific compiler
switch is on) lists at compile-time all heap allocations and closure
allocations of a compilation unit?

Good. This enhancement request asks for just closures, but listing general heap
allocations too is possible:
http://d.puremagic.com/issues/show_bug.cgi?id=5070
Regarding your problem of the "static array initialisations", it will be
eventually fixed, I presume. Don has said it's not too much hard to fix, and I
think it's worth fixing.
Bye,
bearophile

The garbage collector is something that still needs work. My current
project has several second stalls every once in a while due to the GC
(indies might be happy to miss a frame or two (30-60ms) but AAA
developers won't, so you either don't use the GC, or it has to collect
in under a couple of ms).