D for scientific computing
Rob T
alanb at ucora.com
Fri Jan 25 09:45:14 PST 2013
On Thursday, 24 January 2013 at 10:17:50 UTC, Walter Bright wrote:
> On 1/23/2013 6:36 PM, Rob T wrote:
>> BTW the D version of my sqlite3 lib is at least 1/3 smaller
>> than the C++
>> version, and not only is it smaller, but it is far more
>> flexible due to the use
>> of templates (I just could not make much use out of C++
>> templates). A reduction
>> like that is very significant. For large projects. it's a
>> drastic reduction in
>> development costs and perhaps more so in long term maintenance
>> costs.
>
> Interesting. I found the same percentage reduction in
> translating C++ code to D.
I wonder what the main reasons are for the reduction? I did make
my D version of the sqlite3 lib slightly better by removing some
redundancies, but that had only a ~100 line effect on the size
difference. I know that the basic design is pretty much the same,
so there's no radical design change that would account for the
difference.
It could be that I did a better job in subtle ways when
converting over from C++ because of the experience gained from
the original work, for example I think the error detection and
reporting I have in the D version is much simpler, and likely
accounts for some of the size difference. The question though, is
could I have implemented the same changes in the C++ version just
as easily? I'm not so sure about that because when I program in
D, it "feels" better in terms of being much less tedious to work
with, so there must be more going on than just a few design
choices. I also find that I get into these "ah ha" moments, where
I realize that I don't have to do much of anything extra to make
something new work - hard to explain without real examples, but I
know I run into these when working with D more so than when
working with C++.
An interesting test would be to translate a D program into a C++
one, to see if the C++ version will shrink due to subtle
improvements, but I think that would be very difficult to do if
there are templates involved. You just cannot make heavy use out
of templates in C++ like you can in D.
Have you ever translated from D to C++?
--rt
More information about the Digitalmars-d
mailing list