July 06, 2018
On Friday, 6 July 2018 at 16:45:41 UTC, Ecstatic Coder wrote:
> On Friday, 6 July 2018 at 16:33:19 UTC, 12345swordy wrote:
>> On Friday, 6 July 2018 at 15:19:33 UTC, Ecstatic Coder wrote:
>>> For C++, the answer is : never.
>>
>> ...Yeah I had already figure out what your aiming at. For C++ the correct answer is "I do not know as I don't know how it is implemented". You act like there isn't any GC libraries for C++.
>>
>> -Alex
>
> LOL
>
> Unless you implement your game in managed-C++, I don't think there is much to worry about that though...

Your comparison is logical fallacious to begin with.

-Alex
July 06, 2018
On Friday, 6 July 2018 at 15:19:33 UTC, 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:
>>> On Friday, 6 July 2018 at 13:50:37 UTC, 12345swordy wrote:
>>>> [...]
>>>
>>> +1
>>>
>>> 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.
>>
>> -Alex
>
> Actually you answer was right even if the point count was not stored as an integer ;)
>
> For C++, the answer is : never.
>
> Two small memory blocks will have to be allocated from the memory pool, which is not smart, obviously, but apart of that, nothing to worry about.
>
> Because there is no garbage collector in C++, memory has to be allocated and deallocated in a continuous manner...

Also if your concatenate string in a loop in c# then you use the https://www.dotnetperls.com/string-join function as it simpler and faster.
There is no reason why we can't have the function equivalent in D.

-Alexander
July 06, 2018
On Friday, 6 July 2018 at 15:30:22 UTC, Ecstatic Coder wrote:
> On Friday, 6 July 2018 at 15:07:41 UTC, wjoe wrote:
>> [...]
>
> Actually, as I said, even today many game engines are still written in a C-inspired manner, i.e. C + classes, templates and polymorphism, mainly for performance reasons (cache friendly data oriented designs, etc).

You can do that in D.

July 06, 2018
On Friday, 6 July 2018 at 16:48:17 UTC, 12345swordy wrote:
> On Friday, 6 July 2018 at 16:45:41 UTC, Ecstatic Coder wrote:
>> On Friday, 6 July 2018 at 16:33:19 UTC, 12345swordy wrote:
>>> On Friday, 6 July 2018 at 15:19:33 UTC, Ecstatic Coder wrote:
>>>> For C++, the answer is : never.
>>>
>>> ...Yeah I had already figure out what your aiming at. For C++ the correct answer is "I do not know as I don't know how it is implemented". You act like there isn't any GC libraries for C++.
>>>
>>> -Alex
>>
>> LOL
>>
>> Unless you implement your game in managed-C++, I don't think there is much to worry about that though...
>
> Your comparison is logical fallacious to begin with.
>
> -Alex

I was just trying to explain why C++ developers have GC phobia through a very simple example.

Even the simplest string concatenation in any garbage collected language (like Java, etc) can be the cause of of serious game freeze, which most players (including me) won't tolerate for long.

Even one tiny allocation which is hidden deep somewhere in an external library of some sort...

But it was obviously pointless to try to explain it on this D forum. I understand it now.
July 06, 2018
> Also if your concatenate string in a loop in c# then you use the https://www.dotnetperls.com/string-join function as it simpler and faster.
> There is no reason why we can't have the function equivalent in D.
>
> -Alexander

Yeah I know, this code was DELIBERATLY naive.

That was the whole point of it.
July 06, 2018
On Friday, 6 July 2018 at 17:00:49 UTC, Ecstatic Coder wrote:
> On Friday, 6 July 2018 at 16:48:17 UTC, 12345swordy wrote:
>> On Friday, 6 July 2018 at 16:45:41 UTC, Ecstatic Coder wrote:
>>> On Friday, 6 July 2018 at 16:33:19 UTC, 12345swordy wrote:
>>>> [...]
>>>
>>> LOL
>>>
>>> Unless you implement your game in managed-C++, I don't think there is much to worry about that though...
>>
>> Your comparison is logical fallacious to begin with.
>>
>> -Alex
>
> I was just trying to explain why C++ developers have GC phobia through a very simple example.
>
> Even the simplest string concatenation in any garbage collected language (like Java, etc) can be the cause of of serious game freeze, which most players (including me) won't tolerate for long.
>
> Even one tiny allocation which is hidden deep somewhere in an external library of some sort...
>
> But it was obviously pointless to try to explain it on this D forum. I understand it now.

Are you seriously going to ignore video games that are entirely implemented in GC focus language such as C#/java?! The GC is NOT AN ISSUE IF YOU KNOW WHAT YOU ARE DOING!

-Alexander
July 06, 2018
> Are you seriously going to ignore video games that are entirely implemented in GC focus language such as C#/java?! The GC is NOT AN ISSUE IF YOU KNOW WHAT YOU ARE DOING!
>
> -Alexander

+1

Indeed ABSOLUTELY NO garbage collection will happen during the game loop is 100% of your GC-language code doesn't make any string concatenation, object allocation, etc.

While ANY C++ game can make ANY number of allocations/allocations inside a game loop and still run without a risking any freeze. I will probably slower than it should, so you'd better don't make too much of them ;)

But the game won't freeze.

C++ is allocation/deallocation tolerant to a reasonable extent.

GC language aren't. You eventually have to reach the ZERO allocation limit, or you expose yourself to unwanted game freezes.


July 06, 2018
On Friday, 6 July 2018 at 17:04:37 UTC, Ecstatic Coder wrote:
>> Also if your concatenate string in a loop in c# then you use the https://www.dotnetperls.com/string-join function as it simpler and faster.
>> There is no reason why we can't have the function equivalent in D.
>>
>> -Alexander
>
> Yeah I know, this code was DELIBERATLY naive.
>
> That was the whole point of it.
Misuse of tools is not an argument against the tools themselves. Blaming the GC for your "naive" code, is equivalent to a carpenter blaming his hammer for his error when the hammer is in fine shape.

As I said before, the GC is not an issue if you know what you are doing.

-Alexander
July 06, 2018
On Friday, 6 July 2018 at 17:16:54 UTC, Ecstatic Coder wrote:
>> Are you seriously going to ignore video games that are entirely implemented in GC focus language such as C#/java?! The GC is NOT AN ISSUE IF YOU KNOW WHAT YOU ARE DOING!
>>
>> -Alexander
>
> +1

You are start reminding me of another person who pull these type of stunts. Which is not a good thing btw, as that guy is a notorious troll.


> While ANY C++ game can make ANY number of allocations/allocations inside a game loop and still run without a risking any freeze.
You are doing something very wrong if you are doing this.

-Alexander
July 06, 2018
On Fri, Jul 06, 2018 at 05:16:54PM +0000, Ecstatic Coder via Digitalmars-d-announce wrote:
> > Are you seriously going to ignore video games that are entirely implemented in GC focus language such as C#/java?! The GC is NOT AN ISSUE IF YOU KNOW WHAT YOU ARE DOING!
> > 
> > -Alexander
> 
> +1
> 
> Indeed ABSOLUTELY NO garbage collection will happen during the game loop is 100% of your GC-language code doesn't make any string concatenation, object allocation, etc.
[...]

	import core.memory;
	GC.disable();
	string s;
	foreach (i; 0 .. 1_000_000) {
		s ~= "look ma! no GC collection happens!";
	}
	...
	GC.collect();	// GC collection happens here
	...
	GC.enable();	// go back to "default" GC behaviour


T

-- 
Three out of two people have difficulties with fractions. -- Dirk Eddelbuettel