D on next-gen consoles and for game development

Dmitry Olshansky dmitry.olsh at gmail.com
Thu May 23 13:55:17 PDT 2013


23-May-2013 22:13, Brad Anderson пишет:
> While there hasn't been anything official, I think it's a safe bet to
> say that D is being used for a major title, Remedy's Quantum Break,
> featured prominently during the announcement of Xbox One. Quantum Break
> doesn't come out until 2014 so the timeline seems about right (Remedy
> doesn't appear to work on more than one game at a time from what I can
> tell).
>
> Now I'm wondering what can be done to foster this newly acquired
> credibility in games.  By far the biggest issue I hear about when it
> comes to people working on games in D is the garbage collector.  You can
> work around the GC without too much difficulty as Manu's experience
> shared in his DConf talk shows but a lot of people new to D don't know
> how to do that.  We could also use some tools and guides to help people
> identify and avoid GC use when necessary.
>
> @nogc comes to mind (I believe Andrei mentioned it during one of the
> talks released). [1][2]

I have simple and future proof proposal:

1. Acknowledge how containers would look like (API level is fine, and 
std.container has it). Postpone allocator or consider them be backed 
into container.

2. Then for any function that has to allocate something (array 
typically) add a compile-time parameter - container to use. Obviously 
there has to be a constraint on what kind of operations it must provide.

3. std.algorithm and std.range become usable. We then can extend this 
policy beyond.

Some examples to boot:

1. std.array.array - incredibly nice tool, turns any range into array.
Let's make a construct function that does the same for any container:
auto arr = array(iota(0, 10).map....)
--->
auto arr = construct!(Array!int)(iota(0, 10).map...)

by repeatedly calling insertAny in general, and doing better things 
depending on the primitives available (like reserving space beforehand 
for array-like types).

BTW users can use alias FTW:
alias toArray = construct!(Array!int); // Yay!

2. schwartzSort - allocates array internally. We just need to pass it 
the right replacement type for array. schwartzSort!(Array!int)(...) - no 
GC required now. Ditto for levenshteinDistance etc.

There could be some limitations on how far such approach can go with 
introducing new overloads. Alternative is new functions with some 
suffix/prefix.
-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list