| Thread overview | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
March 22, 2016 rust reaction to walter's talk on interfacing to C++ | ||||
|---|---|---|---|---|
| ||||
https://internals.rust-lang.org/t/interfacing-d-to-legacy-c-code-a-summary-of-a-competing-languages-capabilities/1406/3 from > a year back, but I didn't see it mentioned here before. " Personal thoughts for Rust: This could be a killer feature for D. As far as I know, no language (which doesn't just translate to C++) supports C++ interfacing in any non-insane manner. It would significantly reduce the barrier to incrementally replacing C++ with D code. I believe that if Rust wants to compete in this space, matching D's capabilities here would be of considerable value. Rust is not as well-off as D in some areas: D has the advantage of its template system actually being a superset of C++'s. It also has conventional OO features. Finally, it has a several-year head start. Rust has two advantages I can think of: it doesn't have the struct/class split that D does, and it has non-transitive *mut and *const (at least, I don't think they're transitive in Rust). This isn't a question of all-or-nothing. Clearly, interfacing with any possible C++ code is just complete lunacy. D has thus far demonstrated that there's a decently-sized proportion of C++ code that can be bound to without needing to integrate a full C++ compiler. With the Servo team looking to start adding components written in Rust into Firefox, might be an excellent opportunity to look at exactly what features would be most useful. " | ||||
March 22, 2016 Re: rust reaction to walter's talk on interfacing to C++ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Laeeth Isharc | On Tuesday, 22 March 2016 at 08:52:23 UTC, Laeeth Isharc wrote: > This isn't a question of all-or-nothing. Clearly, interfacing with any possible C++ code is just complete lunacy. You need to define what you mean by interfacing: 1. Interfacing with existing C++ libraries. 2. Interfacing with C++ code written with D in mind. 3. Interfacing with legacy C++ applications(pre C++11) Point 3 will become irrelevant over time, so it is not worth the trouble. Point 2 is achievable even from Python (Boost Python). Point 1 is what is needed for C++ interfacing to be a selling point and then you do need: 1. Redefine or extend D semantics to match C++. 2. Link in clang. > D has thus far demonstrated that there's a decently-sized proportion of C++ code that can be bound to without needing to integrate a full C++ compiler. I don't think this has been demonstrated. What projects are you talking about? | |||
March 22, 2016 Re: rust reaction to walter's talk on interfacing to C++ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Laeeth Isharc | On Tuesday, 22 March 2016 at 08:52:23 UTC, Laeeth Isharc wrote:
> https://internals.rust-lang.org/t/interfacing-d-to-legacy-c-code-a-summary-of-a-competing-languages-capabilities/1406/3
> from > a year back, but I didn't see it mentioned here before.
>
Cynic me would say the first one to link the clang front-end to their compiler will win. Who wants to write bindings when you can just add source files? :)
| |||
March 22, 2016 Re: rust reaction to walter's talk on interfacing to C++ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Guillaume Piolat | On Tuesday, 22 March 2016 at 10:48:42 UTC, Guillaume Piolat wrote:
> Cynic me would say the first one to link the clang front-end to their compiler will win. Who wants to write bindings when you can just add source files? :)
Yes, + IDE + same targets.
| |||
March 22, 2016 Re: rust reaction to walter's talk on interfacing to C++ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Laeeth Isharc | On Tuesday, 22 March 2016 at 08:52:23 UTC, Laeeth Isharc wrote:
> Rust has two advantages I can think of: it doesn't have the struct/class split that D does, and it has non-transitive *mut and *const (at least, I don't think they're transitive in Rust).
That's funny. I would have said that those were _advantages_ for D. D's constness can certainly be unwieldy (some sort of equivalent to C++ mutable would be a very welcome addition if we could pull it off), but whatever flaws D's const may have, the transitivity is a huge plus overall IMHO, and I would have said that the struct/class split was a huge win. It properly segregates the inheritance stuff to reference types while not forcing all user-defined types of any complexity to be reference types.
So, while I'm quite sure that Rust has advantages over D, I would not have listed those among them.
- Jonathan M Davis
| |||
March 22, 2016 Re: rust reaction to walter's talk on interfacing to C++ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | > That's funny. I would have said that those were _advantages_ for D. D's constness can certainly be unwieldy (some sort of equivalent to C++ mutable would be a very welcome addition if we could pull it off), but whatever flaws D's const may have, the transitivity is a huge plus overall IMHO, and I would have said that the struct/class split was a huge win. It properly segregates the inheritance stuff to reference types while not forcing all user-defined types of any complexity to be reference types.
>
> So, while I'm quite sure that Rust has advantages over D, I would not have listed those among them.
In general, yes, but in terms of interfacing with C++ they are a bit irksome.
| |||
March 22, 2016 Re: rust reaction to walter's talk on interfacing to C++ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On Tuesday, 22 March 2016 at 11:00:44 UTC, Jonathan M Davis wrote:
> On Tuesday, 22 March 2016 at 08:52:23 UTC, Laeeth Isharc wrote:
>> Rust has two advantages I can think of: it doesn't have the struct/class split that D does, and it has non-transitive *mut and *const (at least, I don't think they're transitive in Rust).
>
> That's funny. I would have said that those were _advantages_ for D.
>[...], and I would have said that the struct/class split was a huge win.
Shoot me down if unrelated and easily worked around: MSVC mangles "struct" differently from "class". Perhaps the D split between struct/class makes it hard to represent this MSVC mangling? (without changing the C++ source)
| |||
March 22, 2016 Re: rust reaction to walter's talk on interfacing to C++ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On Tuesday, 22 March 2016 at 11:00:44 UTC, Jonathan M Davis wrote: > we could pull it off), but whatever flaws D's const may have, the transitivity is a huge plus overall IMHO, and I would have said that the struct/class split was a huge win. It properly segregates the inheritance stuff to reference types while not forcing all user-defined types of any complexity to be reference types. Well, it could have been a win if structs were more restricted and acted like non-referenced types (pure functional values without identity, just like a CPU register) + if classes were put on the stack (or many objects were allocated as a group) by the compiler as an optimization. The problem is that D is trying hard to be like C/C++ in terms of low-level semantics, and then just about all the advantages are lost. > So, while I'm quite sure that Rust has advantages over D, I would not have listed those among them. The big win for Rust would be some of the basic semantics and the aliasing guarantees for their "unique_ptr" system. Rust can potentially support better optimization and better correctness guarantees than C++/D. But Rust needs a faster compiler, since the Rust feature set matters more for large projects... | |||
March 22, 2016 Re: rust reaction to walter's talk on interfacing to C++ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Tuesday, 22 March 2016 at 11:03:10 UTC, Mike Parker wrote:
>> That's funny. I would have said that those were _advantages_ for D. D's constness can certainly be unwieldy (some sort of equivalent to C++ mutable would be a very welcome addition if we could pull it off), but whatever flaws D's const may have, the transitivity is a huge plus overall IMHO, and I would have said that the struct/class split was a huge win. It properly segregates the inheritance stuff to reference types while not forcing all user-defined types of any complexity to be reference types.
>>
>> So, while I'm quite sure that Rust has advantages over D, I would not have listed those among them.
>
>
> In general, yes, but in terms of interfacing with C++ they are a bit irksome.
That's true. If you're talking specifically about interfacing with C++, then some of D's improvements over C++ do become a problem.
- Jonathan M Davis
| |||
March 22, 2016 Re: rust reaction to walter's talk on interfacing to C++ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Guillaume Piolat | On 2016-03-22 11:48, Guillaume Piolat wrote: > On Tuesday, 22 March 2016 at 08:52:23 UTC, Laeeth Isharc wrote: >> https://internals.rust-lang.org/t/interfacing-d-to-legacy-c-code-a-summary-of-a-competing-languages-capabilities/1406/3 >> >> from > a year back, but I didn't see it mentioned here before. >> > > > Cynic me would say the first one to link the clang front-end to their > compiler will win. Who wants to write bindings when you can just add > source files? :) i.e. Swift, but that is for C. -- /Jacob Carlborg | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply