Go Memory usage: 13mb
Rust Memory usage: 9mb
D Memory usage: 7mb Go Memory usage: 13mb
Rust Memory usage: 9mb
D Memory usage: 7mb> Rust downloaded a lot of crates, but that's probably because the Rust version of the code has more features than mine has. For example, it fetched rpassword, a tool that hides password characters as you type them into a terminal, much like Python's getpass function. That's one of the many things I don't have in my code.
Also, quick tip for anyone writing scripts with a GC or malloc/free: turn the collections/free off and just allocate until you finish the script. The OS collects the memory and you save a few seconds.
My guess is that you have experience with platforms such as the JVM or CLR (dot NET) and expect garbage collected languages to use up a lot of memory.
The JVM and CLR use generational/copying GC. These types of GC sacrifice memory to get efficient collection -- the more memory they use, the more efficient the GC [1].
Both Go and D use non-copying GC which has a lower memory overhead.
I am not sure about D, but Go also uses escape analysis so that data structures are allocated on the stack instead of the heap when possible which can help to reduce garbage and hence memory usage.
[1] The principle is similar to the one described in this paper where the GC time is independent of the amount of garbage: https://scholar.google.com/scholar?cluster=48058747733581794...
D sometimes does this but for the most part it depends on how you write the code. strings, large arrays, and class objects are typically GC'd but struct instances and small arrays are often not.
The code in the blog post appears to mostly use small stack memory.
The only weird thing i see in the blog post is 30 second compile. Yikes, this should be more like 3 second from scratch, max - it must use some heavier-than-necessary dependencies.
Go has Google's direct backing, which is more what I was pointing towards.
D developers are all experts in the art of crafting compilers and language design.
9 women can't make a baby in a month
Imagine what they can do in 19 years.
And Go, by the virtue of having less features, has to allocate quite more. Eg: Go doesn't have lazy ranges / streams. Dynamic dispatch using interfaces has to allocate memory on heap.
Also, I expect D standard library to be optimized for Non-GC use case at least a part of it, because that's one of its use cases.
Compiler's escape analysis matters too. I'm told Go's escape analysis is not very sophisticated.
Last, it may be case of missing features in D version as a comment mentioned.
I would not have predicted D would be better than Rust in any measure if those are the number of maintainers.
I'd guess that the larger team must be able to do more. "Faster alone, further together".