www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - C backend for D

reply Dibyendu Majumdar <mobile majumdar.org.uk> writes:
Has there ever been an attempt to create a C backend for D?
Mar 05 2020
next sibling parent reply Stefan Koch <uplink.coder gmail.com> writes:
On Thursday, 5 March 2020 at 20:51:40 UTC, Dibyendu Majumdar 
wrote:
 Has there ever been an attempt to create a C backend for D?
Indeed. If I recall correctly Daniel Murphy did work on one. newCTFE has a C backend as well, which of course will only work for CTFEable code. There are also approaches which use the unofficial LLVM C backend via a custom build of LDC.
Mar 05 2020
next sibling parent sarn <sarn theartofmachinery.com> writes:
On Thursday, 5 March 2020 at 21:43:45 UTC, Stefan Koch wrote:
 On Thursday, 5 March 2020 at 20:51:40 UTC, Dibyendu Majumdar 
 wrote:
 Has there ever been an attempt to create a C backend for D?
There are also approaches which use the unofficial LLVM C backend via a custom build of LDC.
Yep, I've experimented with using using this with (plain) LDC: https://github.com/JuliaComputing/llvm-cbe I got "Hello World" to work, but unfortunately llvm-cbe's forward reference generation is buggy, so I gave up trying to get anything more complicated to compile. Credit goes to this post for the original inspiration: https://qiita.com/mono_shoo/items/81b98ac5656a47617232 (Post from the Japanese D community about using llvm-cbe to run D on a microcontroller.)
Mar 05 2020
prev sibling parent Dibyendu Majumdar <mobile majumdar.org.uk> writes:
On Thursday, 5 March 2020 at 21:43:45 UTC, Stefan Koch wrote:
 On Thursday, 5 March 2020 at 20:51:40 UTC, Dibyendu Majumdar 
 wrote:
 Has there ever been an attempt to create a C backend for D?
Indeed. If I recall correctly Daniel Murphy did work on one.
Is it this one you mean: https://github.com/yebblies/dmd/tree/microd
 newCTFE has a C backend as well, which of course will only work 
 for CTFEable code.
Cool, is there an example C output? Regards
Mar 06 2020
prev sibling next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 3/5/2020 12:51 PM, Dibyendu Majumdar wrote:
 Has there ever been an attempt to create a C backend for D?
https://news.ycombinator.com/item?id=22402123
Mar 06 2020
parent reply Dibyendu Majumdar <mobile majumdar.org.uk> writes:
On Friday, 6 March 2020 at 11:02:36 UTC, Walter Bright wrote:
 On 3/5/2020 12:51 PM, Dibyendu Majumdar wrote:
 Has there ever been an attempt to create a C backend for D?
https://news.ycombinator.com/item?id=22402123
Well most reasons stated in that thread appear to be spurious? Only one that is perhaps a valid issue is debug info. What would real issues for the better C dialect to have a C backend?
Mar 06 2020
next sibling parent kinke <kinke gmx.net> writes:
On Friday, 6 March 2020 at 13:08:47 UTC, Dibyendu Majumdar wrote:
 What would real issues for the better C dialect to have a C 
 backend?
Wrong question - what would be the point of such a backend?
Mar 06 2020
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 3/6/2020 5:08 AM, Dibyendu Majumdar wrote:
 On Friday, 6 March 2020 at 11:02:36 UTC, Walter Bright wrote:
 On 3/5/2020 12:51 PM, Dibyendu Majumdar wrote:
 Has there ever been an attempt to create a C backend for D?
https://news.ycombinator.com/item?id=22402123
Well most reasons stated in that thread appear to be spurious? Only one that is perhaps a valid issue is debug info.
I know people like to argue with me about the validity of the points. Most of them are value judgements, and I consider it compelling. With enough effort, one can make anything work.
Mar 06 2020
parent reply bachmeier <no spam.net> writes:
On Friday, 6 March 2020 at 21:27:12 UTC, Walter Bright wrote:
 On 3/6/2020 5:08 AM, Dibyendu Majumdar wrote:
 On Friday, 6 March 2020 at 11:02:36 UTC, Walter Bright wrote:
 On 3/5/2020 12:51 PM, Dibyendu Majumdar wrote:
 Has there ever been an attempt to create a C backend for D?
https://news.ycombinator.com/item?id=22402123
Well most reasons stated in that thread appear to be spurious? Only one that is perhaps a valid issue is debug info.
I know people like to argue with me about the validity of the points. Most of them are value judgements, and I consider it compelling. With enough effort, one can make anything work.
Notably absent from the OP's post is a compelling argument in favor of a C backend.
Mar 06 2020
parent Dibyendu Majumdar <mobile majumdar.org.uk> writes:
On Saturday, 7 March 2020 at 02:41:27 UTC, bachmeier wrote:
 I know people like to argue with me about the validity of the 
 points. Most of them are value judgements, and I consider it 
 compelling. With enough effort, one can make anything work.
Notably absent from the OP's post is a compelling argument in favor of a C backend.
My question was whether anyone had done this before ... not an ask to create one. So no argument needed. I was curious, that's all.
Mar 07 2020
prev sibling parent reply 12345swordy <alexanderheistermann gmail.com> writes:
On Thursday, 5 March 2020 at 20:51:40 UTC, Dibyendu Majumdar 
wrote:
 Has there ever been an attempt to create a C backend for D?
None, there is simply no good reason for dmd to have a c backend. Once the backend has been open sourced, effort has been made to port it to d via dbetterC.
Mar 06 2020
parent IGotD- <nise nise.com> writes:
On Friday, 6 March 2020 at 19:24:13 UTC, 12345swordy wrote:
 On Thursday, 5 March 2020 at 20:51:40 UTC, Dibyendu Majumdar 
 wrote:
 Has there ever been an attempt to create a C backend for D?
None, there is simply no good reason for dmd to have a c backend. Once the backend has been open sourced, effort has been made to port it to d via dbetterC.
With LLVM, intermediate languages or "transpilers" has become less usual simply because they are less and less necessary. Also debugging becomes more difficult as you have an intermediate language that will fill up the debugging information rather than the actual language that you are using. Nim, is the language that stands out that uses C as the main backend. It has benefits as well as drawbacks. With LDC and GDC, a C backend is more or less obsolete and pointless.
Mar 06 2020