Thoughts about D

Jonathan M Davis newsgroup.d at jmdavisprog.com
Thu Nov 30 03:15:37 UTC 2017


On Tuesday, November 28, 2017 18:18:20 Walter Bright via Digitalmars-d 
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.
>
> 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 wouldn't have expected assertions to cost much more than however much it
costs to evaluate the expression being asserted unless the assertion fails.
Now, even that can slow down a program a fair bit, depending on what's being
asserted and how many assertions there are, but it's not something that I
would have expected to vary particular between C and D. It doesn't surprise
me that the generated code would be larger than you'd get for the same
assertions in C because how assertions are handled when they fail is quite
different, but I would expect the assertions themselves to cost about the
same in terms of performance as long as they don't fail. What's going on
that's making them so much worse?

- Jonathan M Davis



More information about the Digitalmars-d mailing list