On Monday, July 11, 2016 01:16:11 Adam Sansier via Digitalmars-d-learn wrote: > Thanks. I'd rather prematurely optimize out the gc then have to > go back and get it to work. It's not hard to write non-gc code, > it's been done for ages. But having some compiler help makes > things nice. It seems there is more of a phobia of writing non-gc > code than the phobia of the gc.
It's more a case that you're just making life harder for yourself if you avoid the GC. Some programs (like AAA games) are going to need to avoid the GC, but your average program is going to be just fine using the GC - especially if you use idiomatic D and favor structs over classes and use ranges rather than allocating a bunch of stuff on the heap like you'd do in Java, or even often in C++. So, most folks who are trying to avoid the GC are causing themselves pain by doing so without actually needing to. It's perfectly possible to do avoid the GC in D, and some programs will need to, but most won't, and avoiding the GC is always more of a pain than just using it. My advice would that unless you're doing something where you know that a stop the world GC will be unacceptable, that you just use the GC and not worry about it until profiling shows you that you need to do something differently. And even then, it's often the case that you just need to alter a small portion of your program so that the GC doesn't run during that piece of the code, or you make a critical thread be non-GC so that it doesn't get stopped during a collection cycle. Folks have made very performance-critical programs work that way, and it's a lot more pleasant than trying to avoid the GC everywhere. I don't know what you're doing, so I don't know whether you should be trying to avoid the GC or not. You're obviously the one who's going to have to judge that. I'm just pointing out that odds are that you don't need to avoid it and that you're just making life harder for yourself if you do. But what you do is obviously completely up to you. - Jonathan M Davis