3 ms·
One of the nice aspects of D is that it interfaces with C++ really nicely. I'm not overly familiar with how Rust handles this, as the last time I tried to glue
by sargun 8y ago
One of the nice aspects of D is that it interfaces with C++ really nicely. I'm not overly familiar with how Rust handles this, as the last time I tried to glue together Rust and C++ was more than a year ago, and the tooling was in evolution.
From Go / CGo, it can be pretty scary to interface with native C++ code, and it requires lots of annoying boilerplate.
- WalterBright 8y ago"C++ has a very complex ABI, and the Rust ABI is not frozen. However, both C++ and Rust support functions that use the C ABI. Therefore, interoperability between C++ and Rust involves writing things in such a way that C++ sees Rust code as C code and Rust sees C++ code as C code." https://hsivonen.fi/modern-cpp-in-rust/ https://hsivonen.fi/modern-cpp-in-rust/
- hardwaresofton 8y agoContext: this poster is likely Walter Bright the creator and first implementer of D lang itself. Cool to know you also read that article about C++ in rust (I personally read a little bit then left because trying to interface with C++ from rust wasn't a problem I had), but I guess it's obvious that you would.
- WalterBright 8y ago> is likely Probably 100%
- arunc 8y agoI've written wrappers for C++ libraries to work with D and it's _very_ easy. To work with C++ classes in D, I created factory methods that created/destroyed them with C ABI and used/disposed them respectively. Working with C is even more easier. There is no FFI, etc. Just use Dstep[1] and get going. Or use dpp[2]. [1] https://github.com/jacob-carlborg/dstep https://github.com/jacob-carlborg/dstep [2] https://github.com/atilaneves/dpp https://github.com/atilaneves/dpp
- WalterBright 8y agoUp until quite recently, while the front end of D was written in D, the back end was in C++ (more precisely, C with classes, as it is fairly auld skool). It's now finally pretty much all in D, and I've been piece by piece refactoring it into more idiomatic D.