www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D libraries in other languages

reply . . <a b.c> writes:
C++ is notoriously hard to use with other languages. Is D any 
better?

If I made a D library, how easy would it be to use it in other 
languages (C, C++, Go, and Rust)?
Jan 23 2019
next sibling parent bauss <jj_1337 live.dk> writes:
On Wednesday, 23 January 2019 at 22:25:31 UTC, . . wrote:
 C++ is notoriously hard to use with other languages. Is D any 
 better?

 If I made a D library, how easy would it be to use it in other 
 languages (C, C++, Go, and Rust)?
D interfaces directly with C, so no problem there. As far as C++ it should work just as well, there are only a very few quirks with that. Anything that can interface to C can interface just as easily to D.
Jan 23 2019
prev sibling next sibling parent reply Manu <turkeyman gmail.com> writes:
On Wed, Jan 23, 2019 at 2:30 PM . . via Digitalmars-d
<digitalmars-d puremagic.com> wrote:
 C++ is notoriously hard to use with other languages. Is D any
 better?

 If I made a D library, how easy would it be to use it in other
 languages (C, C++, Go, and Rust)?
Approximately equally challenging as C++. You basically depend on `extern(C)`. In D you may gain one substantial advantage, in that you might create a system to automatically wrap the D-facing API in `extern(C)` export shims. So perhaps you can automate a lot of `extern(C)` boilerplate...
Jan 23 2019
parent Atila Neves <atila.neves gmail.com> writes:
On Thursday, 24 January 2019 at 04:37:06 UTC, Manu wrote:
 On Wed, Jan 23, 2019 at 2:30 PM . . via Digitalmars-d 
 <digitalmars-d puremagic.com> wrote:
 C++ is notoriously hard to use with other languages. Is D any 
 better?

 If I made a D library, how easy would it be to use it in other
 languages (C, C++, Go, and Rust)?
Approximately equally challenging as C++. You basically depend on `extern(C)`. In D you may gain one substantial advantage, in that you might create a system to automatically wrap the D-facing API in `extern(C)` export shims. So perhaps you can automate a lot of `extern(C)` boilerplate...
You automate pretty much all of it: https://github.com/kaleidicassociates/autowrap
Jan 24 2019
prev sibling parent Jacob Carlborg <doob me.com> writes:
On 2019-01-23 23:25, .. wrote:
 C++ is notoriously hard to use with other languages. Is D any better?
 
 If I made a D library, how easy would it be to use it in other languages 
 (C, C++, Go, and Rust)?
As others have mentioned, D can interface with C. D can also interface with C++ and with Objective-C. It depends on which language you want to interface with, you mentioned C++. -- /Jacob Carlborg
Jan 24 2019