Maybe D runtime/GC has to initialize and go away every time a function is called, in a way that would not make it useful for adding small do-very-little functions like string to lower, urlencode etc. I'm not sure how this works yet but I've written a few extensions in C.
Yes, the D runtime has to initialise when the D program starts, and (depending on what libraries you use) static constructors need to be called. It's minimal, but like you said, it would be inefficient for small functions.
The druntime is open source. Here's druntime's main
function.
If you are just exporting functions through a C interface (using extern(C)
) and calling those then there is no need to start up the runtime, although you shouldn't use the GC or rely on static constructors etc. if you do that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With