Using D without libphobos

A. Nicholi nich at caveoforig.in
Thu Apr 26 09:24:19 UTC 2018


On Thursday, 26 April 2018 at 03:53:54 UTC, Mike Franklin wrote:
>
> I suggest reading the following 2 items before digging deeper:
> https://dlang.org/blog/2017/08/23/d-as-a-better-c/
> https://dlang.org/changelog/2.079.0.html#minimal_runtime

I didn’t know D had begun offering serious decoupling like that. 
With something like this, we may very well be able to avoid 
writing C entirely, at least in-house! Thank you for bringing 
that up.

On Thursday, 26 April 2018 at 03:53:54 UTC, Mike Franklin wrote:
> The compiler uses the C compiler (unfortunately again) to do 
> its linking; and it becomes evident that D is in some ways a 
> layer on top of C.
>
> You can compile some D programs without linking libphobos2, but 
> will require separate compilation and linking because the 
> compiler itself actually hard-codes the call to the linker 
> (actually the C compiler as demonstrated above).  Example 3 at 
> https://dlang.org/changelog/2.079.0.html#minimal_runtime 
> demonstrates this.
>
> If you use that method, you won't be able to use certain 
> features of D that have runtime implementations.  The obvious 
> ones are classes, dynamic arrays, and exceptions.
>
> I could go on, but I'd have to make some assumptions about what 
> you're really after.  Feel free to ask more specific questions 
> and I'll be happy to share what I know (or at least what I 
> think I know; sometimes I'm wrong).
>
> Mike

So in a way, the D runtime is similar to libstdc++, providing 
implementations of runtime language features. But it is also like 
C++ in that those language features can be avoided, correct? At 
least with the use of minimal D, I mean. This means that as a 
language, there is enough granularity to theoretically provide as 
few or as many features as one desires for their use case, making 
the penning of new C and C++ code redundant? Do I get this right?


More information about the Digitalmars-d mailing list