Thoughts about D

Walter Bright newshound2 at digitalmars.com
Sat Dec 2 23:56:24 UTC 2017


On 12/2/2017 4:13 AM, Iain Buclaw wrote:
> On 29 November 2017 at 03:18, Walter Bright via Digitalmars-d
> <digitalmars-d at puremagic.com> wrote:
>> On 11/28/2017 9:27 AM, Jacob Carlborg wrote:
>>>
>>> Why would druntime be a barrier for you for those projects?
>>
>>
>> When the C version is 90K and the translated D version is 1200K, it is a
>> barrier. It's a barrier for others, as well.
>>
> 
> Did you add an extra 0 here for the D version?

No. I used the sizes for MicroEmacs in C vs MicroEmacs in D. (I translated the 
former into the latter.)

With BetterC, I've been able to create virtually identical binaries for C and D.


>> Another barrier for me has turned out to be the way assert() works in D. It
>> just is not lightweight, and it visibly slows down dmd to have assert's
>> turned on internally. The amount of machinery involved with it in druntime
>> is way overblown. Hence, asserts in dmd are turned off, and that wound up
>> causing me a lot of problems recently. There are even initiatives to add
>> writefln like formatting to asserts. With betterC, asserts became
>> lightweight and simple again.
> I find this assertion hard to believe (pun not intended).  Unless you
> are omitting some extra check (invariant calls?), whether you are
> using D's assert or C's assert, both have the same runtime cost.

asserts are significantly larger in D. One reason is the filename string is 
passed as a D string, which is 2 pushes. A C string is one push.

Consider that D asserts throw an exception. Where's the catch going to be, if 
you're linking the D code into a C program? And the D personality function, 
needed for D exception unwinding, is in druntime.


>> BetterC is a door-opener for an awful lot of areas D has been excluded from,
>> and requiring druntime is a barrier for that.
> It's not a door opener, and druntime is not a barrier.

If you have a C program, and want to add a D function to it, you really don't 
want to add druntime as well. BetterC enables people to provide D addon 
libraries for people who have C main programs.

There's a point to making incremental use of D as low cost as possible.



More information about the Digitalmars-d mailing list