Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
January 23, 2019 D libraries in other languages | ||||
---|---|---|---|---|
| ||||
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)? |
January 23, 2019 Re: D libraries in other languages | ||||
---|---|---|---|---|
| ||||
Posted in reply to . . | 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.
|
January 23, 2019 Re: D libraries in other languages | ||||
---|---|---|---|---|
| ||||
Posted in reply to . . | 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...
|
January 24, 2019 Re: D libraries in other languages | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | 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 |
January 24, 2019 Re: D libraries in other languages | ||||
---|---|---|---|---|
| ||||
Posted in reply to . . | 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 |
Copyright © 1999-2021 by the D Language Foundation