October 10, 2007
Walter Bright wrote:
> Jarrett Billingsley wrote:
>> "BLS" <nanali@nospam-wanadoo.fr> wrote in message news:fegotb$1l3e$1@digitalmars.com...
>>
>>> Actually coding C++ code in D  means : rewrite it and make it D-ish, instead of translate it.
>>> This is , simply said shit; and I guess you folks know it.
>>
>> Wow, harsh.  There are those of us who don't actually spend all of our time translating C++ into D, you know. 
> 
> I don't recommend anyone actually translate C++ code to D, or C code for that matter. If it's a debugged, working code base, translating to another language is usually a losing proposition.
> 
> What matters, though, is being able to interface to that existing code base.

While that sounds like good advice in general, if the C++ library in question is mostly templates, there's not much hope of interfacing to it from D.  Porting is the only option I'm aware of.

Of course some parts don't translate well and should just be rewritten in a way that makes sense in D.   But once the scaffolding is in place, the core, tricky, algorithmic parts that are hardest to debug become easy to translate.  So in that way the D port benefits from the work that went into debugging the C++.  So it's a win over just writing from scratch.

OpenMesh/D is about 15-20K loc.  I ported that from C++ in about 10 days.  No way I would have been able to write that from scratch in the same amount of time.


--bb
October 10, 2007
Bill Baxter wrote:
> While that sounds like good advice in general, if the C++ library in question is mostly templates, there's not much hope of interfacing to it from D.  Porting is the only option I'm aware of.
> 
> Of course some parts don't translate well and should just be rewritten in a way that makes sense in D.   But once the scaffolding is in place, the core, tricky, algorithmic parts that are hardest to debug become easy to translate.  So in that way the D port benefits from the work that went into debugging the C++.  So it's a win over just writing from scratch.
> 
> OpenMesh/D is about 15-20K loc.  I ported that from C++ in about 10 days.  No way I would have been able to write that from scratch in the same amount of time.

I'll agree (from much personal experience) that translating code is a far better option than rewriting from scratch, in order to get it to a different language.
October 10, 2007
Walter Bright wrote:
> janderson wrote:
>> Walter Bright wrote:
>>> Don Clugston wrote:
>>>> Thanks, Walter. Especially for bug fixes 1488 and 1125.
>>>
>>> You're welcome.
>>>
>>>> I suspect the C++ interface stuff will have a big impact on winning over C++ developers.
>>>
>>> It's a bit of a shot in the dark. I'm very curious to see how it will work out.
>>
>> I think once this feature matures, another article highlighting the feature will go a long way to making them aware of the feature.  It will be interesting to see how/where people plug D into their C++ apps.
>>
>> -Joel
> 
> Another angle is that *no other language* provides any sort of hook into C++.

Felix does (and has been around for roughly as long as D).  It was
explicitly designed around C++ interoperability, and offers all
sorts of goodies including extensible syntax, GC, functional
capabilities and more.  But so far Felix has fewer than 100 users, and
probably fewer than 50.  D must be doing something right.

-- James
October 10, 2007
James Dennett wrote:
> Walter Bright wrote:
>> janderson wrote:
>>> Walter Bright wrote:
>>>> Don Clugston wrote:
>>>>> Thanks, Walter. Especially for bug fixes 1488 and 1125.
>>>> You're welcome.
>>>>
>>>>> I suspect the C++ interface stuff will have a big impact on winning
>>>>> over C++ developers.
>>>> It's a bit of a shot in the dark. I'm very curious to see how it will
>>>> work out.
>>> I think once this feature matures, another article highlighting the
>>> feature will go a long way to making them aware of the feature.  It
>>> will be interesting to see how/where people plug D into their C++ apps.
>>>
>>> -Joel
>> Another angle is that *no other language* provides any sort of hook into
>> C++.
> 
> Felix does (and has been around for roughly as long as D).  It was
> explicitly designed around C++ interoperability, and offers all
> sorts of goodies including extensible syntax, GC, functional
> capabilities and more.  But so far Felix has fewer than 100 users, and
> probably fewer than 50.  D must be doing something right.
> 
> -- James

It's my understanding that C# does as well, but I don't have any direct knowledge or experience with it.
October 10, 2007
James Dennett wrote:
> Walter Bright wrote:
>> Another angle is that *no other language* provides any sort of hook into
>> C++.
> 
> Felix does (and has been around for roughly as long as D).  It was
> explicitly designed around C++ interoperability, and offers all
> sorts of goodies including extensible syntax, GC, functional
> capabilities and more.  But so far Felix has fewer than 100 users, and
> probably fewer than 50.  D must be doing something right.

I'd never heard of Felix :-)
October 10, 2007
Brad Roberts schrieb:
> 
> It's my understanding that C# does as well, but I don't have any direct knowledge or experience with it.

C# does not connect to C++ directly (via name mangling). You can invoke C funktions and specify struct alignments for struct used in these calls.
When it comes to interfaces and callbacks/callback interfaces you have to use Managed C++. COM Interop is the keyword, but IMHO, the syntax is sometimes weird and you have to write RCW/CCW (stands for "Runtime Callable Wrapper" and "COM Callable Wrapper") pairs in Managed C++ to support (COM) interfaces.
There is a good book about this:

http://www.informit.com/store/product.aspx?isbn=067232170X&rl=1
October 10, 2007
KlausO wrote:
> C# does not connect to C++ directly (via name mangling). You can invoke C funktions and specify struct alignments for struct used in these calls.
> When it comes to interfaces and callbacks/callback interfaces you have to use Managed C++. COM Interop is the keyword, but IMHO, the syntax is sometimes weird and you have to write RCW/CCW (stands for "Runtime Callable Wrapper" and "COM Callable Wrapper") pairs in Managed C++ to support (COM) interfaces.
> There is a good book about this:
> 
> http://www.informit.com/store/product.aspx?isbn=067232170X&rl=1


D has had support for COM from day 1. But D's new support for C++ goes much further. Global functions can be accessed directly, non-COM polymorphic objects can be accessed, and the C++ calling convention is observed (the COM function calling convention is different).
October 10, 2007
Walter Bright schrieb:
> James Dennett wrote:
>> Walter Bright wrote:
>>> Another angle is that *no other language* provides any sort of hook into
>>> C++.
>>
>> Felix does (and has been around for roughly as long as D).  It was
>> explicitly designed around C++ interoperability, and offers all
>> sorts of goodies including extensible syntax, GC, functional
>> capabilities and more.  But so far Felix has fewer than 100 users, and
>> probably fewer than 50.  D must be doing something right.
> 

Regarding C++ interop. :
Comparing Felix and D is a bit unfair. Felix *compiles* to ANSI C++

> I'd never heard of Felix :-)

http://www.digitalmars.com/d/archives/13809.html :)
October 10, 2007
Jarrett Billingsley schrieb:
> "BLS" <nanali@nospam-wanadoo.fr> wrote in message news:fegotb$1l3e$1@digitalmars.com...
> 
>> Actually coding C++ code in D  means : rewrite it and make it D-ish, instead of translate it.
>> This is , simply said shit; and I guess you folks know it.
> 
> Wow, harsh.  There are those of us who don't actually spend all of our time translating C++ into D, you know. 
> 
> 
Yes sure. But in case that you want, respective need to translate, a few D language adjustments would help to save you a lot of time. Well, D2 will have most of the stuff (like struct inherit., opImplicitCast) plus DTL. Maybe I should simply wait..
October 10, 2007
BLS wrote:
> Actually coding C++ code in D  means : rewrite it and make it D-ish, instead of translate it.
> This is , simply said shit; and I guess you folks know it.

Nope, actually, I don't. If you're so in love with C++, why bother with D?

Regards, Frank