D as a prototyping language (for C/C++ projects)

Rob T alanb at ucora.com
Tue Feb 26 15:46:51 PST 2013


On Tuesday, 26 February 2013 at 15:26:17 UTC, Craig Dillabaugh 
wrote:
> I am a novice D programmer and use C++ in my work. One thing I
> find myself doing when I need to implement some non-trivial
> algorithm is that I will originally code it in D and perform
> testing from there to make sure I have the logic right.
> Once I have everything working in D I simply port it over to 
> C++.
>
> In my experience this porting is very trivial (it probably helps
> there that I write D like a C++ programmer). While I don't have
> hard evidence I think that the 'porting' effort to C++ is more
> than offset by the productivity gains I achieve fighting with 
> C++
> syntax while trying to get the logic right. Most of the porting
> effort is simply copying and pasting the D code into my C++
> source files and adding headers, replacing imports with 
> includes,
> etc. Usually significant portions of the code compile without 
> any
> changes.
>
> I was curious to know if anyone else uses D like this. If so 
> this
> might be a good way to try and get D into some C++ shops.  The
> nice thing about D in my opinion is that even for people without
> D experience, if they have C++ experience they can likely 'read'
> D code without much trouble (of course some features might not
> map over so well - but the languages are syntactically very
> close).

I can understand why you are doing this. C++ code tends to be 
about 3x the volume of well written D code, so a lot of effort is 
wasted when coding in C++, so if you can get it right through 
using D, then translate to C++, you'll save a lot of time, but of 
course we're better off using D directly, but first the language 
and tool set has to be made production use ready.

Once full shared library support comes about, we'll be able to 
integrate D libs directly into existing C/C++ code. This allows 
for a safe migration path away from legacy C/C++ to D.

--rt


More information about the Digitalmars-d mailing list