On 7/6/18 11:19 AM, Ecstatic Coder wrote:
On Friday, 6 July 2018 at 14:52:46 UTC, 12345swordy wrote:
On Friday, 6 July 2018 at 14:11:05 UTC, Ecstatic Coder wrote:

Just one silly question.

Can the following "naive" D code trigger a garbage collection stall ?

score.Text = point_count.to!string() ~ " POINTS";

The correct answer is: I don't know, as I don't know what "point_count" is in the first place, as it never been defined.


Actually you answer was right even if the point count was not stored as an integer ;)

The real answer is what rikki says.

Note that what point_count is is irrelevant, the concatenation operator is going to trigger a GC allocation.

We could go further and say "Well, you haven't defined `to` or `string`" and then we can say we have no idea what this means at all!


For C++, the answer is : never.

Of course, the answer in C++ is that it won't compile, this is D code! ;)

And yes, you can have @nogc code in D, and it's less pleasant than normal D code, but still WAY more pleasant that most C++ code. So will people put up with this who want to just write games? Given the current state of the landscape, probably not.

At some point, someone is going to make a fantastic game engine in D, and then we will have a ballgame. Maybe it happens after D gets better support for reference counting, maybe before. Nothing inherent in D makes it impossible or unlikely. But people aren't going to switch "just because", there needs to be a compelling reason that causes someone to champion it.

-Steve

Reply via email to