July 05, 2018
On Wednesday, 4 July 2018 at 19:29:55 UTC, Ecstatic Coder wrote:
> First, to be clear, I mainly use D as a scripting language for file processing, and for this use case, having a GC is a blessing.

This is a non issue and a GC doesn't matter at all in this case. You could allocate all you wanted and never free and as long as there's enough memory to finish the script you couldn't tell the difference. Once a script or program is done the OS reclaims all memory.

But memory leaks in software, running in some kind of main loop, become real performance bottlenecks eventually and a time sink to debug.

> You say that garbage collection is not a real problem for game development.

No, what I'm saying is that I've hadn't had any issues with the GC so far and that I don't expect any.
I'm also saying that I keep hearing this argument against using D but it was never backed up by anthing substantial so it sounds like an excuse by folks who never really considered D in the first place.

Like, what does it matter if a collection cycle is triggered during a loading screen ?
Performance aware C++ folks do have to do resource management at some point, too, and that's not free either and is usually done while the loading screen is displayed.

> For instance, have you read Unity's own official recommandations on how to overcome this problem ?

No, I haven't.
It probably boils down to pre-allocation, object pools, reusing objects, don't allocate in a loop, caching data, be mindful of what you do and when and how, etc, etc.

Which would be good advice for game development in general and I'd do exactly that in C/C++, or any non-GC'd language, too.


> And about developing video games in C++, actually most studios use orthodox C++. This means no exceptions, no RTTI, few virtual methods, fast lightweight smart pointers and collections, etc.

They could get that with -betterC which also does not use a GC.


> And about the scripting language, it's not my fault if some game engine developers don't care for the performance or GC issues when adding a scripting language to their game engine.

Never said it was your fault, just pointed out the fact that it's a very common occurance.

> So, as I said, those who use C++ or Rust because D's GC is a problem for them, won't probably use D in its current state.

Or any other language tagged GC for that matter, except maybe LUA.

Nobody and nothing forces anyone to use the GC or features which use it. Just go ahead and  manage your memory manually. They will not be using features like dynamic arrays, the standard library, and such but that's not a loss since they'd roll their own, more performant implementations, anyways.

But I'm convinced that they wouldn't consider D - even if there was a GC-free Phobos.
They would find the next excuse.

Those who are willing find solutions, those who are not find excuses.



July 05, 2018
> Nobody and nothing forces anyone to use the GC or features which use it. Just go ahead and  manage your memory manually. They will not be using features like dynamic arrays, the standard library, and such but that's not a loss since they'd roll their own, more performant implementations, anyways.

That's my main problem with this approach actually.

This makes D much less interesting to use, while it creates several other problems hard to tackle, like C++ interoperability, compilation on the target platform, etc.

Probably not worth the effort in many cases...

That's also why there aren't that many commercial games developed in Rust too.
July 05, 2018
On Wednesday, 4 July 2018 at 19:29:55 UTC, Ecstatic Coder wrote:
> On Wednesday, 4 July 2018 at 18:05:15 UTC, wjoe wrote:
>> On Wednesday, 4 July 2018 at 08:50:57 UTC, Ecstatic Coder wrote:
>>> But indeed, being able use D in a GC-free environment (like C++ and Rust do) would be something many people may NEED, for instance to be able to EASILY use D for soft-realtime applications like games.
>>
>> This has to be the no. 1 excuse.
>>
>>
>> 
>>
>> Games have been made with GC'd languages, 3D games, even. And successfully, too.
>> Minecraft, a very successful one, comes to mind, which is or at least was made in Java.
>> Plenty of games are made in C#, too.
+1
>
>>
>> Slow code is slow and allocating memory in a tight loop is a huge performance killer - regardless of language.
+1

>>
>> Nothing forces anyone to use the GC, memory can be managed manually via malloc/free and you get to do it with scope statements/nested functions which makes it nicer than in C. You could also implement shared/weak ptr stuff in D - warts and all.

That's what Timur said.

>> If you need a GC free standard library, I believe there is an ongoing effort -or several- at code.dlang.org and probably other places.
>>
>> You said do this and that, GC, etc. to motivate C++ folks to come to D. I say it's an excuse not to use D and no matter the effort of advertising, a GC free phobos, etc. on part of the D-Lang Foundation and contributors would make these folks switch. They would simply find a different excuse.
>>

>
> You say that garbage collection is not a real problem for game development.
>
> Maybe, but that's not my experience. For instance, have you read Unity's own official recommandations on how to overcome this problem ?
>
> And obviously, Tibur, a highly skilled D game engine developer, is not a big fan of D's non incremental garbage collector, from the number of @nogc he has put in his Dlib container code.

He has written no-GC libs for sure but he said in a blog post about his projects that he has no problem with GC. As long as you do not use it in critical areas.

> Modern D is a very attractive choice as a language for game development. Even the garbage collector is not a problem, because you can use object pools, custom allocators, or simply malloc and free. The key point is to know when the GC is invoked and try to avoid those cases in performance critical code. Personally, I prefer using malloc so that I can free the memory when I want, since delete has been deprecated and destroy  just releases all the references to an object instance without actually deleting it. Using manual memory management imposes some restrictions on the code–for example, you can’t use closures or D’s built-in containers–but that, again, is not a big problem. A large effort is currently underway to lessen GC usage in dlib, so that you can use it to write fully unmanaged applications with ease. It has GC-free containers, file I/O streams, image decoders, and so on.

https://dlang.org/blog/2016/09/16/project-highlight-timur-gafarov/

Remember he's into real-time stuff.

> As an indie game developer with a strong bias toward graphics engines and rendering tech, I always try to keep track of modern compiled languages effective enough for writing real-time stuff. The most obvious choice in this field is C++, and I actually used it for several years until I found D in 2010. I immediately fell in love with the language’s clean, beautiful syntax, its powerful template system, the numerous built-in features absent in C++, and the rich and easy to use standard library.

>
> Maybe you disagree with us because you are a professional game developer who has already released a successful commercial game in D without caring for the garbage collection. If it's the case, then nice, I'd be happy to have it wrong on this :)

Read the blog post, you're wrong.

>
> Of course it's perfectly your right to develop your games without caring for all these performance "details". But other people do.

GC in not a performance bottle neck if you truly know what you're doing.

>
> So, as I said, those who use C++ or Rust because D's GC is a problem for them, won't probably use D in its current state.

If D had X people. Not customers.


July 06, 2018
LOL

Ok, if I'm wrong, then this means D is already a perfect replacement to C++, especially for game development.

Just by curiosity, can you tell me how many successful commercial games based on a D game engine are released each year ?

Or just this year maybe...
July 06, 2018
On Friday, 6 July 2018 at 13:15:43 UTC, Ecstatic Coder wrote:
> LOL
>
> Ok, if I'm wrong, then this means D is already a perfect replacement to C++, especially for game development.
>
> Just by curiosity, can you tell me how many successful commercial games based on a D game engine are released each year ?
>
> Or just this year maybe...

No triple AAA engine is going to switch to D for the following reasons:
1.)Cost vs benefit from converting C++ to D.
2.)Gamers do not care how things are implemented, they want results.
3.)There are high abundance of c++ programmers for employees to hired. I can't say the same thing for D.
4.)GC phobia.(The notorious culprit)


-Alex
July 06, 2018
On Friday, 6 July 2018 at 13:50:37 UTC, 12345swordy wrote:
> On Friday, 6 July 2018 at 13:15:43 UTC, Ecstatic Coder wrote:
>> LOL
>>
>> Ok, if I'm wrong, then this means D is already a perfect replacement to C++, especially for game development.
>>
>> Just by curiosity, can you tell me how many successful commercial games based on a D game engine are released each year ?
>>
>> Or just this year maybe...
>
> No triple AAA engine is going to switch to D for the following reasons:
> 1.)Cost vs benefit from converting C++ to D.
> 2.)Gamers do not care how things are implemented, they want results.
> 3.)There are high abundance of c++ programmers for employees to hired. I can't say the same thing for D.
> 4.)GC phobia.(The notorious culprit)
>
>
> -Alex

+1

Just one silly question.

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

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

And what about the same code in C++ ?

Now guess why there is such a "phobia"...

July 07, 2018
On 07/07/2018 2:11 AM, Ecstatic Coder wrote:
> On Friday, 6 July 2018 at 13:50:37 UTC, 12345swordy wrote:
>> On Friday, 6 July 2018 at 13:15:43 UTC, Ecstatic Coder wrote:
>>> LOL
>>>
>>> Ok, if I'm wrong, then this means D is already a perfect replacement to C++, especially for game development.
>>>
>>> Just by curiosity, can you tell me how many successful commercial games based on a D game engine are released each year ?
>>>
>>> Or just this year maybe...
>>
>> No triple AAA engine is going to switch to D for the following reasons:
>> 1.)Cost vs benefit from converting C++ to D.
>> 2.)Gamers do not care how things are implemented, they want results.
>> 3.)There are high abundance of c++ programmers for employees to hired. I can't say the same thing for D.
>> 4.)GC phobia.(The notorious culprit)
>>
>>
>> -Alex
> 
> +1
> 
> Just one silly question.
> 
> Can the following "naive" D code trigger a garbage collection stall ?
> 
> score.Text = point_count.to!string() ~ " POINTS";

If the GC has been disabled (which any sane performance caring application should do) no.
July 06, 2018
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:
>> On Friday, 6 July 2018 at 13:15:43 UTC, Ecstatic Coder wrote:
>>> [...]
>>
>> No triple AAA engine is going to switch to D for the following reasons:
>> 1.)Cost vs benefit from converting C++ to D.
>> 2.)Gamers do not care how things are implemented, they want results.
>> 3.)There are high abundance of c++ programmers for employees to hired. I can't say the same thing for D.
>> 4.)GC phobia.(The notorious culprit)
>>
>>
>> -Alex
>
> +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

July 06, 2018
On Friday, 6 July 2018 at 13:15:43 UTC, Ecstatic Coder wrote:
> Just by curiosity, can you tell me how many successful commercial games based on a D game engine are released each year ?

Just out of curiosity, how many games have been released based on a C++ game engine in 1998 ?


The original Unreal engine was almost completely written in asm, back in the late 90ies.

The first C++ game engine I found was the Object Oriented Graphical Redering Engine, started some time around 2001.

Carmack resisted C++ for a longer time and I believe I read something about the engine was  ported to C++ when they developed Id Tech 4 around 2004.


July 06, 2018
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:
>>> On Friday, 6 July 2018 at 13:15:43 UTC, Ecstatic Coder wrote:
>>>> [...]
>>>
>>> No triple AAA engine is going to switch to D for the following reasons:
>>> 1.)Cost vs benefit from converting C++ to D.
>>> 2.)Gamers do not care how things are implemented, they want results.
>>> 3.)There are high abundance of c++ programmers for employees to hired. I can't say the same thing for D.
>>> 4.)GC phobia.(The notorious culprit)
>>>
>>>
>>> -Alex
>>
>> +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...