digitalmars.D - rust reaction to walter's talk on interfacing to C++
- Laeeth Isharc (26/26) Mar 22 2016 https://internals.rust-lang.org/t/interfacing-d-to-legacy-c-code-a-summa...
- Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= (13/18) Mar 22 2016 You need to define what you mean by interfacing:
- Guillaume Piolat (4/6) Mar 22 2016 Cynic me would say the first one to link the clang front-end to
- Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= (2/5) Mar 22 2016 Yes, + IDE + same targets.
- Jacob Carlborg (4/12) Mar 22 2016 i.e. Swift, but that is for C.
- Jonathan M Davis (13/16) Mar 22 2016 That's funny. I would have said that those were _advantages_ for
- Mike Parker (2/13) Mar 22 2016 In general, yes, but in terms of interfacing with C++ they are a
- Jonathan M Davis (5/19) Mar 22 2016 That's true. If you're talking specifically about interfacing
- Johan Engelen (5/14) Mar 22 2016 Shoot me down if unrelated and easily worked around: MSVC
- Walter Bright (2/5) Mar 22 2016 It is a current problem. I've thought of many solutions, but none were s...
- Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= (15/23) Mar 22 2016 Well, it could have been a win if structs were more restricted
- QAston (11/23) Mar 24 2016 Rust doesn't need D-style transitive const because it can be
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. "
Mar 22 2016
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?
Mar 22 2016
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? :)
Mar 22 2016
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.
Mar 22 2016
On 2016-03-22 11:48, Guillaume Piolat wrote:On Tuesday, 22 March 2016 at 08:52:23 UTC, Laeeth Isharc wrote:i.e. Swift, but that is for C. -- /Jacob Carlborghttps://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? :)
Mar 22 2016
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
Mar 22 2016
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.
Mar 22 2016
On Tuesday, 22 March 2016 at 11:03:10 UTC, Mike Parker wrote: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 DavisThat'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.
Mar 22 2016
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: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)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.
Mar 22 2016
On 3/22/2016 4:05 AM, Johan Engelen wrote: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)It is a current problem. I've thought of many solutions, but none were satisfying.
Mar 22 2016
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...
Mar 22 2016
On Tuesday, 22 March 2016 at 11:00:44 UTC, Jonathan M Davis 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. - Jonathan M DavisRust doesn't need D-style transitive const because it can be replicated using variable bindings and ownership. When you create an object and only assign it immutable binding for it it's transitively immutable forever. Tail mutability can be achieved by wrapping a field in std::Cell: https://doc.rust-lang.org/std/cell/ . Imo much less invasive than D's constness. Rust doesn't have implementation inheritance yet, so no class/struct split. We'll see how they deal with that, various proposals are made.
Mar 24 2016