Feedback on Átila's Vision for D

Petar Petar
Thu Oct 17 13:16:07 UTC 2019


On Wednesday, 16 October 2019 at 17:07:27 UTC, Gregor Mückl wrote:
> On Wednesday, 16 October 2019 at 00:33:20 UTC, neikeq wrote:
>> Regarding interop with C++, what are your thoughts on tools 
>> like Calypso? It supports most C++ features, including 
>> advanced stuff like template instantiation, and it seems to be 
>> under active development: https://github.com/Syniurge/Calypso
>
> What is the state of Calypso? The last release was in 2014. 
> This is also the latest tag that was created. Development on 
> master stopped in 2018. The most recent commits were on branch. 
> I would have missed that from a cursory look at the commit 
> history (you have to switch branches to notice!). I don't know 
> when it was last sync'ed with LDC. If I wanted to use it, how 
> would I even go about that? How do I get a version that is 
> compatible with recent versions of D and works / is supported?
>
> My point is: the publicly visible state of the project isn't 
> very encouraging for potential users.

The last line of work appears to be in the clang-9 branch: 
https://github.com/Syniurge/Calypso/commits/clang-9

W.r.t to C++ interop there are 5 areas of development:
1. During the past 3 years there have been a ton of fixes to 
extern (C++) (and to a lesser extent extern (C), which was 
already close to rock-solid) and nowadays it should be pretty 
usable (namespaces, classes and templates work in many cases). 
You can directly call much of D from C++ and vice versa. 
Obviously there are many D and C++ specific language features 
that are not yet/can't be supported, but we're pretty further 
along than what we had a couple of years ago. Having all 3 major 
compilers (first DMD, then LDC and now GDC) be written half in D 
and half in C++ is a testament to that. (Actually now DMD is 
D-only now, but it was in C++ + D mode for enough time to force 
many of the developers at the time to at least make the subset of 
extern (C++) that it used fully working.)

2. During the past year some parts of STL had bindings written to 
them and tested for Linux, Mac and Windows (which is surprisingly 
difficult, due to difference in C++ compilers and STL 
implementations): 
https://github.com/dlang/druntime/tree/master/src/core/stdcpp

3. Having tools like dstep and dpp support C++. As far as I know 
both tools support only C header files, but at least for dpp, 
Atila has listed C++ as a major planned feature. Work in area 1. 
makes 3. now possible. The work of one of GSOC students made a 
huge impact for dstep, so it's likely that a similar tactic for 
dpp would also help.

4. Automatic C/C++ header generation for D code. There has been 
solid progress, but we're probably a couple of months before 
having the work finally merged upstream.

5. Making import C++ automagically work has been the holy grail 
for many. The author of Calypso has had the unfortunate task of 
having to single-handedly work on not only implementation, but 
also solving many language-level challenges like template 
instantiation, overloading and many more. Adding insult to 
injury, the most efficient way to interface with libClang is with 
C++ and for they don't guarantee a stable API, and even break it 
very often, and D's frontend is likely worse then that (at 
minimum it switched from being C++ only, to D only during the 
time Calypso was developed.).
I think the best way forward is to get it merged in LDC as soon 
as possible - that way at least the burden of supporting new D 
frontend and LLVM/clang backend versions could be shared by other 
contributors.


More information about the Digitalmars-d mailing list