Jump to page: 1 24  
Page
Thread overview
D as a prototyping language (for C/C++ projects)
Feb 26, 2013
Craig Dillabaugh
Feb 26, 2013
dennis luehring
Feb 26, 2013
Namespace
Feb 26, 2013
monarch_dodra
Feb 26, 2013
Craig Dillabaugh
Feb 26, 2013
bearophile
Feb 26, 2013
Craig Dillabaugh
Feb 26, 2013
renoX
Feb 26, 2013
Craig Dillabaugh
Feb 26, 2013
monarch_dodra
Feb 26, 2013
MattCodr
Feb 26, 2013
bearophile
Feb 26, 2013
Jacob Carlborg
Feb 26, 2013
H. S. Teoh
Feb 26, 2013
Jacob Carlborg
Feb 26, 2013
Ary Borenszweig
Feb 26, 2013
simendsjo
Feb 27, 2013
Jacob Carlborg
Feb 27, 2013
Jacob Carlborg
Feb 26, 2013
Jacob Carlborg
Feb 27, 2013
Paulo Pinto
Feb 27, 2013
Zach the Mystic
Feb 27, 2013
Jacob Carlborg
Feb 27, 2013
timotheecour
Feb 28, 2013
Jacob Carlborg
Feb 26, 2013
Rob T
Feb 27, 2013
monarch_dodra
Feb 27, 2013
Rob T
Feb 27, 2013
simendsjo
Feb 27, 2013
Namespace
February 26, 2013
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).
February 26, 2013
Am 26.02.2013 16:26, schrieb Craig Dillabaugh:
> 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++.

i don't get it

you are an novice D programmer and your programs are easy to convert back to C++ so you'r not using too much D specials

whats the point of doing it like this?




February 26, 2013
On Tuesday, 26 February 2013 at 15:43:42 UTC, dennis luehring wrote:
> Am 26.02.2013 16:26, schrieb Craig Dillabaugh:
>> 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++.
>
> i don't get it
>
> you are an novice D programmer and your programs are easy to convert back to C++ so you'r not using too much D specials
>
> whats the point of doing it like this?

I do it as well.
In D you can write code (mostly) much faster.
However, I would not attempt to implement larger projects (more) in D, because D is simply not mature enough and lacks too much.
So after writing and testing in D, I port my program/code then in C++ and complete it.
February 26, 2013
On Tuesday, 26 February 2013 at 15:43:42 UTC, dennis luehring wrote:
> Am 26.02.2013 16:26, schrieb Craig Dillabaugh:
>> 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++.
>
> i don't get it
>
> you are an novice D programmer and your programs are easy to convert back to C++ so you'r not using too much D specials
>
> whats the point of doing it like this?

It's not about using special features. As a matter of fact, I'd think he'd purposefully stay away from special features.

The point is that he *develop* the program in D in half the time it would have taken him in C++. Given this productivity gain, he can mess and improve his program much faster and with more quality than he could have in C++.

Once his D program is stable and the outline/flow is clearer to him, and he knows what he wants to do, he only has to convert to C++, which can be done very fast.

I do this too. It is *very* helpful when you don't know *where* you are going when you start.

I'd stick to D all the way, but as namespace said, D may not be mature enough, or stable enough, or just allowed as a final language in the workplace :/
February 26, 2013
Craig Dillabaugh:

> 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++.

I often write the code in D (sometimes I start from Python and then I convert it to D), get it right, write down more tests, then I slowly lower the level of the D code keeping it correct with help of the tests, and then convert it to C.

When the code is quite complex, if I do this I waste some time, but it's a known amount of time, while if I follow a more direct route, writing the C code directly, I can't tell how much debugging time I will need.

Bye,
bearophile
February 26, 2013
On Tuesday, 26 February 2013 at 15:43:42 UTC, dennis luehring
wrote:
> Am 26.02.2013 16:26, schrieb Craig Dillabaugh:
>> 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++.
>
> i don't get it
>
> you are an novice D programmer and your programs are easy to convert back to C++ so you'r not using too much D specials
>
> whats the point of doing it like this?

I should qualify that a bit. I don't avoid D features altogether,
but I don't necessarily use many of the advanced features (eg.
mixins) that might have no equivalent in C++. I work in
scientific computing so I do much of my work with arrays.
Working with D arrays is much, much nicer than in C++.  So I save
lots of time getting my algorithm working/tested.  Then the
porting is pretty simple, because while slices for example are
not supported in C++ you can handle the same logic in C++ without
too much trouble.  However, the C++ code is uglier and not having
to deal with that ugliness lets me focus my mental effort on the
details of my algorithm. This lets me implement it correctly more
quickly.

Using D associative arrays vs C++ std.map is another example.

Now, I would never suggest using D to prototype a full
application or anything like that, but at least for the type of
work I tend to do I find that using D lets me focus on my
'algorithm' without fight with awkward syntax.




February 26, 2013
On Tuesday, 26 February 2013 at 16:15:49 UTC, bearophile wrote:
> Craig Dillabaugh:
>
>> 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++.
>
> I often write the code in D (sometimes I start from Python and then I convert it to D), get it right, write down more tests, then I slowly lower the level of the D code keeping it correct with help of the tests, and then convert it to C.
>
> When the code is quite complex, if I do this I waste some time, but it's a known amount of time, while if I follow a more direct route, writing the C code directly, I can't tell how much debugging time I will need.
>
> Bye,
> bearophile

One of the reasons I like D for this kind of work is that as a
multi-paradigm language it lets you do stuff in a style closer
what your final C++ code
will look like. My research is in satellite image processing, so
most of
my work involves reading in imagery into 2D arrays and performing
processing
over all/or part of an image. I find being able to write code
like:

for(int i =0; i < rows; i++) {
   for(int j = 0; j < cols; j++) {

   }
}

Sometimes is the easiest way to perform certain tasks.  D lets
you do this and the syntax is exactly the same a C/C++ - Python?
I don't know - but I imagine it would be tricker to port to C++!
I have found, at least in this particular problem domain, that
the C++/D style syntax is about as good as it gets.
February 26, 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++.

I'm curious: is this process still useful with C++11?

BR,
renoX
February 26, 2013
On Tuesday, 26 February 2013 at 15:26:17 UTC, Craig Dillabaugh
wrote:
> I was curious to know if anyone else uses D like this.

I usually do this, but in a little different way. I wrote my code
in a interpreted language, and then I port to D or C languages.
February 26, 2013
On Tuesday, 26 February 2013 at 16:34:01 UTC, renoX wrote:
> 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++.
>
> I'm curious: is this process still useful with C++11?
>
> BR,
> renoX

Again since my work is heavily array based probably, I would
guess so, but perhaps not quite so much.  How long though until
C++11 is broadly available?

« First   ‹ Prev
1 2 3 4