Inherent code performance advantages of D over C?

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Dec 6 15:55:10 PST 2013


On Fri, Dec 06, 2013 at 03:19:24PM -0800, Walter Bright wrote:
> On 12/6/2013 3:02 PM, Maxim Fomin wrote:
[...]
> >Such advantages are offset by:
> >
> >- huge runtime library
> 
> C has a huge runtime library, too, it's just that you normally don't
> notice it because it's not statically linked in. Be that as it may,
> 2.064 substantially reduced the size of "hello world" programs.

Are there any upcoming further improvements in this area? It would be
nice to not have multi-MB programs that only print "hello world". :)
(Not that that's any meaningful indicator of typical program size, since
typically programs do more than just print "hello world", but still, I
think there's still lots of low-hanging fruit here.)


[...]
> >- phobos snowball - one invocation of some function in standard
> >library leads to dozens template instantiations and invocations of
> >pretty much stuff
> 
> True enough, but does that lead to non-performant code? 2.064 cuts
> that down quite a bit anyway, and I think we can make more
> improvements in this regard.

It would be nice to decouple Phobos modules more. A *lot* more.
Currently there is a rather nasty tangle of mutual imports between
several large modules (e.g., std.stdio, std.format, std.algorithm,
std.conv, and a few others). Import just one of them, and it pulls in
*everything*. This goes against the Phobos philosophy as advertised on
dlang.org -- that dependencies between modules should be minimal.

One low-hanging fruit that comes to mind is to use local imports instead
of module-wide imports. If the local imports are inside templated
functions, I *think* it would prevent pulling in the imports until the
function is actually used, which would have the desired effect. (Right?)
Much of Phobos was written before we had this feature, but since we have
it now, might as well make good use of it.


T

-- 
"A one-question geek test. If you get the joke, you're a geek: Seen on a California license plate on a VW Beetle: 'FEATURE'..." -- Joshua D. Wachs - Natural Intelligence, Inc.


More information about the Digitalmars-d mailing list