Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there additional overhead in using D instead of C if I'm writing code to extend interpreted languages?

Tags:

d

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.

like image 330
BreezyChick89 Avatar asked Sep 14 '12 14:09

BreezyChick89


1 Answers

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.

like image 91
Peter Alexander Avatar answered Jan 03 '23 17:01

Peter Alexander