On Sat, Dec 07, 2013 at 09:33:53AM -0800, Walter Bright wrote:
> On 12/7/2013 1:45 AM, Joseph Rushton Wakeling wrote:
> >TL;DR the point is that writing in D gave me the opportunity to spend
> >mental and programming time exploring these different choices and
> >focusing on algorithms and data structures, rather than all the
> >effort and extra LOC required to get a _particular_ idea running in
> >C.  That's where the real edge arises.
> 
> I've noticed this too, but I've found it hard to explain to C
> programmers.
> 
> To say it a different way, D makes it easy to refactor code to rapidly
> try out different algorithms. In C, one tends to stick with the
> original design because it is so much harder to refactor.

D's metaprogramming capabilities and compile-time introspection help
this a lot. Even little things like @property (in spite of the problems
associated with its current implementation) go a long way in allowing
two divergent implementations to share the same API, so that it's much
easier to replace one implementation with another -- with no runtime
cost.

In C, once you've committed to a particular implementation, you can't
easily change it without rewriting large chunks of code. While it *is*
possible to do this to some extent using void* and function ptrs and so
on, that would introduce runtime overhead, whereas in D, it's only a
compile-time difference. To avoid runtime overhead you'd have to make
heavy use of macros, which quickly becomes a maintenance nightmare.


T

-- 
Never step over a puddle, always step around it. Chances are that whatever made 
it is still dripping.

Reply via email to