D as a Better C

Walter Bright via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Wed Aug 23 07:00:34 PDT 2017


On 8/23/2017 6:28 AM, Moritz Maxeiner wrote:
> Interesting article, though one thing that I'm confused by is
> 
>>> Hence D libraries remain inaccessible to C programs, and chimera programs (a 
>>> mix of C and D) are not practical. One cannot pragmatically “try out” D by 
>>> add D modules to an existing C program.
> 
> I've been mixing C and full D for a while now (on Linux) by either having the 
> main C program call rt_init/rt_term directly (if druntime is linked in when 
> building a mixed C/D application), or have Runtime.initialize/Runtime.terminate 
> be called from D via some plugin_load/plugin_unload functionality when using D 
> shared libraries.
> Why is this not considered practical?

Because in order to add a D function as trivial as:

    int foo() { return 3; }

to a C program, now the C program has to link to druntime, and the program no 
longer has a small footprint. One of the reasons people use C is to get that 
small footprint. This has been a large barrier to C programs making use of D.



More information about the Digitalmars-d-announce mailing list