Classes on stack

Ali Çehreli acehreli at yahoo.com
Thu Sep 1 17:24:41 UTC 2022


On 9/1/22 03:51, Redwan wrote:

 > it's uses alot of heap and I don't like it.

 > all of heap usages needs to be done by me

As a fellow ex-C++ programmer (actually, I am still exposed to C++ and I 
don't like what I see), I know my old feelings of "I don't like it", "I 
need", and "I want" were remnants of what C++ had convinced me in its 
way of thinking.

Now I know that what matters is one correct and super efficient program 
written while having fun.

I use the GC wherever it makes sense and I use classes where they make 
sense. By one count, I had 95 structs, 2 classes, and 1 interface in my 
family of programs. "Everything is a class" has always been wrong. It 
took me a long time to see through some experts.

By the way, I haven't started to use @nogc yet.

The only time I had a memory leak in D was due to integral values being 
mistaken for pointers for a 32-bit build when I was loading files into 
huge buffers. I don't use 32 bits anymore, I don't do that anymore, and 
D runtime has been improved since then to have some information where 
actual pointers are.

Ali



More information about the Digitalmars-d mailing list