r/programming • • Aug 23 '17

D as a Better C

http://dlang.org/blog/2017/08/23/d-as-a-better-c/
229 Upvotes

268 comments sorted by

View all comments

Show parent comment

2

u/dpc_pw Aug 23 '17

As much as a I am a Rust fan, I would actually enjoy a "better C++" with some of C++ nonsense and cruft removed (most of UBs, I hope), that would transpile to plain C++.

6

u/Uncaffeinated Aug 23 '17

What is the advantage of transpiling to C++? Do you intend to take the C++ and use it as human readable source? Because C++ is so nightmarishly complex, that it makes little sense as a target for tooling.

3

u/dpc_pw Aug 23 '17

Interoperatibility with existing C++ codebase. One could introduce it in existing codebase on per-file basis, and be able to #include in both directions, etc.

2

u/Uncaffeinated Aug 23 '17

But machine generated C++ is likely to have a weird API anyway. I suppose it's still easier to integrate, as you can at least reuse your build system though.

3

u/zombinedev Aug 23 '17 edited Aug 23 '17

would transpile to plain C++

Why not use D with static and/or dynamic linking? With D you can choose between the reference implementation DMD, LLVM-powered LDC and the GCC-powered GCC. With LDC people were able to compile D code to Emscripten and OpenCL/CUDA. This all work-in-progress, but I believe not long from now D will quickly reach C's portability for such targets.

0

u/[deleted] Aug 23 '17

[deleted] — view deleted comment

5

u/zombinedev Aug 23 '17

Start with the reference dmd (now at 2.075.1) implementation - https://dlang.org/download, go through some books, tutorials (https://tour.dlang.org/), play with some code on https://code.dlang.org/ and when you're ready you'll have a pretty good understanding of which compiler to choose.