Jump to page: 1 2 3
Thread overview
How usable is the D language without a garbage collector?
Jul 15, 2022
LinguisticMystic
Jul 15, 2022
max haughton
Jul 15, 2022
LinguisticMystic
Jul 15, 2022
rikki cattermole
Jul 15, 2022
max haughton
Jul 15, 2022
Araq
Jul 15, 2022
electricface
Jul 15, 2022
ryuukk_
Jul 15, 2022
ryuukk_
Jul 15, 2022
bachmeier
Jul 15, 2022
Guillaume Piolat
Jul 15, 2022
bachmeier
Jul 15, 2022
ryuukk_
Jul 15, 2022
H. S. Teoh
Jul 15, 2022
Guillaume Piolat
Jul 16, 2022
evilrat
Jul 15, 2022
Salih Dincer
Jul 16, 2022
Era Scarecrow
Jul 16, 2022
welkam
Jul 17, 2022
Siarhei Siamashka
July 15, 2022

I'm looking for a modestly mature language to be a C++ replacement for my hobby needs. D seems to be a good one as it ticks all the boxes of C++ while fixing most (all?) of its flaws. However, what confuses me is the fact that D has a garbage collector. My necessary requirement is that the runtime should not include any such thing. And D does have some sort of @nogc switch. My question is, how usable is the scenario of GC-free programs in reality? Does the switch apply globally, so that the compiled binary is free from GC code? How many essential libraries can work without GC? Is it better for me to look elsewhere if I don't want GC?

Thanks for your clarifications!

July 15, 2022

On Friday, 15 July 2022 at 09:27:51 UTC, LinguisticMystic wrote:

>

I'm looking for a modestly mature language to be a C++ replacement for my hobby needs. D seems to be a good one as it ticks all the boxes of C++ while fixing most (all?) of its flaws. However, what confuses me is the fact that D has a garbage collector. My necessary requirement is that the runtime should not include any such thing. And D does have some sort of @nogc switch. My question is, how usable is the scenario of GC-free programs in reality? Does the switch apply globally, so that the compiled binary is free from GC code? How many essential libraries can work without GC? Is it better for me to look elsewhere if I don't want GC?

Thanks for your clarifications!

What kind of software do you want to write

July 15, 2022

On Friday, 15 July 2022 at 09:31:14 UTC, max haughton wrote:

>

What kind of software do you want to write

Video games, number crunching. Stuff C++ is usually used for.

July 15, 2022
On 15/07/2022 9:40 PM, LinguisticMystic wrote:
> On Friday, 15 July 2022 at 09:31:14 UTC, max haughton wrote:
> 
>> What kind of software do you want to write
> 
> Video games, number crunching. Stuff C++ is usually used for.

Neither of which D's GC is the enemy of.

The GC is a library that can only be triggered to stop the world, but is not guaranteed to stop the world on, during a from GC memory allocation.

You are quite free to use malloc/free and not tell the runtime about a thread iff you need to.

You can also disable scanning when a pause would not be desirable.

D has been used in both scenarios with the GC turned on.

https://dlang.org/blog/the-gc-series/
July 15, 2022

On Friday, 15 July 2022 at 09:40:05 UTC, LinguisticMystic wrote:

>

On Friday, 15 July 2022 at 09:31:14 UTC, max haughton wrote:

>

What kind of software do you want to write

Video games, number crunching. Stuff C++ is usually used for.

For number crunching the GC is not going to get in your way (i.e. more than the actual mathematics) unless you write extremely unfortunate code (this is true of any memory allocator).

July 15, 2022

On Friday, 15 July 2022 at 09:27:51 UTC, LinguisticMystic wrote:

>

Thanks for your clarifications!

I make GC free programs but not out of choice.

The GC is very rarely the cause of bad performance; there is nothing preventing you from optimizing, because D is native and a system language. SO it's not like a Javascript situation, where creating garbage can be unavoidable.

On the contrary, if you can use a GC you will be more productive for the non-critical parts, and creating a good program in the first place. Gaining valuable time to optimize bottlenecks.

An enormous majority of system software can be written with a GC somewhere.

July 15, 2022

On Friday, 15 July 2022 at 09:40:05 UTC, LinguisticMystic wrote:

>

On Friday, 15 July 2022 at 09:31:14 UTC, max haughton wrote:

>

What kind of software do you want to write

Video games, number crunching. Stuff C++ is usually used for.

Depends on what kind of video games you are thinking of. A strategy game or a basic RPG MUD would be no problem, even with the GC. You can bind to non-templated C++, so you could use a flexible C/C++ renderer like Skia running on a non-gc thread.

If you want to create a first person shooter game then you should pick the framework(s) first, and language second. Creating a quality game-engine for that from scratch takes a massive investment given hardware differences etc, so the language-choice becomes secondary.

That said, everything in C++ is RAII-based so it is hard to beat in terms of language features for that type of programming, despite C++ being one of the most time consuming languages around. C++ is not really a hobby language…

Anyway, you don't have to stick to one language. You can mix.

July 15, 2022

On Friday, 15 July 2022 at 11:18:15 UTC, Ola Fosheim Grøstad wrote:

>

Anyway, you don't have to stick to one language. You can mix.

But you shouldn't mix as debugging and the tooling situation in general across languages is terrible. At least when "mixing" implies some sort of scripting language with its own interpreter loop.

July 15, 2022

On Friday, 15 July 2022 at 09:27:51 UTC, LinguisticMystic wrote:

>

D seems to be a good one as it ticks all the boxes of C++ while fixing most (all?) of its flaws.

I don't have an answer to your main question, because I mostly just use the GC (including for number crunching) and my life is good.

However, I want to caution that you need to view D as an alternative to C++, not an iteration. I have on many occasions seen C++ users get upset because D does not always operate the way they're used to C++ operating. It's a different language.

>

However, what confuses me is the fact that D has a garbage collector. My necessary requirement is that the runtime should not include any such thing.

Bjarne Stroustrup has, for a very long time, boasted that you can use garbage collection with C++. That has clearly not prevented you from using C++. The fact that D has a garbage collector does not mean anything; just don't use it. You'll lose some parts of the standard library.

July 15, 2022

On Friday, 15 July 2022 at 11:48:31 UTC, Araq wrote:

>

On Friday, 15 July 2022 at 11:18:15 UTC, Ola Fosheim Grøstad wrote:

>

Anyway, you don't have to stick to one language. You can mix.

But you shouldn't mix as debugging and the tooling situation in general across languages is terrible. At least when "mixing" implies some sort of scripting language with its own interpreter loop.

Recommended reading it: https://dlang.org/blog/the-gc-series/

« First   ‹ Prev
1 2 3