digitalmars.D.learn - Compile to C?
- Nestor (3/3) Jan 21 2017 Hi friends,
- Joakim (5/9) Jan 21 2017 The wiki says there was a dmd fork that attempted this 5 years
- Jack Stouffer (3/7) Jan 21 2017 No, and this is actually a terrible idea. See
- Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= (4/13) Jan 23 2017 No valid arguments for it being a terrible idea in that thread.
- aberba (5/21) Jan 23 2017 Unless you will be limited by tge limitations of C. Vala
- Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= (4/7) Jan 23 2017 What limitations? C/C++ programs go around "limitations" by using
- Adam D. Ruppe (6/7) Jan 21 2017 The hard part in porting to a new platform is rarely the code
- Nestor (2/9) Jan 22 2017 You mean phobos, or system libraries?
- Adam D. Ruppe (2/3) Jan 22 2017 Phobos but mostly the druntime that interfaces with the system.
- Nestor (6/9) Jan 22 2017 I see, I was mostly thinking in Android and/or other platforms,
- rikki cattermole (4/14) Jan 22 2017 Nim probably doesn't care too much about the platform its running on lik...
- Joakim (7/18) Jan 22 2017 Btw, Ldc has good support for a lot of platforms already,
- Bauss (14/18) Jan 23 2017 Nim is able to, because Nim doesn't really compile. The Nim
- Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= (2/7) Jan 23 2017 TLS is a nonissue. You can wrap the TLS declarations in macros.
Hi friends, Is there a way to "compile" d code to C, similar to what nim does? That would be cool for greater portability.
Jan 21 2017
On Saturday, 21 January 2017 at 18:38:22 UTC, Nestor wrote:Hi friends, Is there a way to "compile" d code to C, similar to what nim does? That would be cool for greater portability.The wiki says there was a dmd fork that attempted this 5 years ago, don't know how far he got: https://wiki.dlang.org/Compilers https://github.com/yebblies/dmd/tree/microd
Jan 21 2017
On Saturday, 21 January 2017 at 18:38:22 UTC, Nestor wrote:Hi friends, Is there a way to "compile" d code to C, similar to what nim does? That would be cool for greater portability.No, and this is actually a terrible idea. See https://forum.dlang.org/post/n1vbos$11ov$1 digitalmars.com
Jan 21 2017
On Saturday, 21 January 2017 at 19:30:31 UTC, Jack Stouffer wrote:On Saturday, 21 January 2017 at 18:38:22 UTC, Nestor wrote:No valid arguments for it being a terrible idea in that thread. Being able to translate code to other languages is a very useful feature and makes a language much more interesting in production.Hi friends, Is there a way to "compile" d code to C, similar to what nim does? That would be cool for greater portability.No, and this is actually a terrible idea. See https://forum.dlang.org/post/n1vbos$11ov$1 digitalmars.com
Jan 23 2017
On Monday, 23 January 2017 at 14:40:18 UTC, Ola Fosheim Grøstad wrote:On Saturday, 21 January 2017 at 19:30:31 UTC, Jack Stouffer wrote:Unless you will be limited by tge limitations of C. Vala programming language has that issue even though they utilize GObjectOn Saturday, 21 January 2017 at 18:38:22 UTC, Nestor wrote:No valid arguments for it being a terrible idea in that thread. Being able to translate code to other languages is a very useful feature and makes a language much more interesting in production.Hi friends, Is there a way to "compile" d code to C, similar to what nim does? That would be cool for greater portability.No, and this is actually a terrible idea. See https://forum.dlang.org/post/n1vbos$11ov$1 digitalmars.com
Jan 23 2017
On Monday, 23 January 2017 at 15:24:09 UTC, aberba wrote:Unless you will be limited by tge limitations of C. Vala programming language has that issue even though they utilize GObjectWhat limitations? C/C++ programs go around "limitations" by using compiler extensions and runtime libraries. Vala is trying to keep code simple, like Go. Apples and oranges.
Jan 23 2017
On Saturday, 21 January 2017 at 18:38:22 UTC, Nestor wrote:That would be cool for greater portability.The hard part in porting to a new platform is rarely the code generation - gdc and ldc have diverse backends already (indeed, they tend to work for D as well as C there). But you still have to port runtime library requirements where compiling to C wouldn't help at all.
Jan 21 2017
On Saturday, 21 January 2017 at 19:33:27 UTC, Adam D. Ruppe wrote:On Saturday, 21 January 2017 at 18:38:22 UTC, Nestor wrote:You mean phobos, or system libraries?That would be cool for greater portability.The hard part in porting to a new platform is rarely the code generation - gdc and ldc have diverse backends already (indeed, they tend to work for D as well as C there). But you still have to port runtime library requirements where compiling to C wouldn't help at all.
Jan 22 2017
On Monday, 23 January 2017 at 01:12:21 UTC, Nestor wrote:You mean phobos, or system libraries?Phobos but mostly the druntime that interfaces with the system.
Jan 22 2017
On Monday, 23 January 2017 at 01:17:20 UTC, Adam D. Ruppe wrote:On Monday, 23 January 2017 at 01:12:21 UTC, Nestor wrote:I see, I was mostly thinking in Android and/or other platforms, but it does seem like heavy work, though curiously this approach seems to be working for Nim (at least so far), is it that the language is better suited for that, or simply that more work has been put into it? (not bashing D, honest curiosity)You mean phobos, or system libraries?Phobos but mostly the druntime that interfaces with the system.
Jan 22 2017
On 23/01/2017 3:20 PM, Nestor wrote:On Monday, 23 January 2017 at 01:17:20 UTC, Adam D. Ruppe wrote:Nim probably doesn't care too much about the platform its running on like C. We support things like TLS and shared libraries with GC, that all requires druntime and having system support to some extent.On Monday, 23 January 2017 at 01:12:21 UTC, Nestor wrote:I see, I was mostly thinking in Android and/or other platforms, but it does seem like heavy work, though curiously this approach seems to be working for Nim (at least so far), is it that the language is better suited for that, or simply that more work has been put into it? (not bashing D, honest curiosity)You mean phobos, or system libraries?Phobos but mostly the druntime that interfaces with the system.
Jan 22 2017
On Monday, 23 January 2017 at 02:20:02 UTC, Nestor wrote:On Monday, 23 January 2017 at 01:17:20 UTC, Adam D. Ruppe wrote:Btw, Ldc has good support for a lot of platforms already, including Android and iPhone: http://wiki.dlang.org/LDC Porting druntime to a new OS is not heavy work, mostly translating some C headers: https://github.com/dlang/druntime/pulls?utf8=✓&q=is%3Apr%20is%3Aopen%20netbsdOn Monday, 23 January 2017 at 01:12:21 UTC, Nestor wrote:I see, I was mostly thinking in Android and/or other platforms, but it does seem like heavy work, though curiously this approach seems to be working for Nim (at least so far), is it that the language is better suited for that, or simply that more work has been put into it? (not bashing D, honest curiosity)You mean phobos, or system libraries?Phobos but mostly the druntime that interfaces with the system.
Jan 22 2017
On Saturday, 21 January 2017 at 18:38:22 UTC, Nestor wrote:Hi friends, Is there a way to "compile" d code to C, similar to what nim does? That would be cool for greater portability.Nim is able to, because Nim doesn't really compile. The Nim compiler just translates Nim code to C code and then compiles the C code. It's much harder to do properly in D, because D doesn't use C as a backend, but compiles directly to native. I'd guess the code generation you'd get from doing so with D would be absolute horrific to read, because you'll get rid of CTFE, templates, proper class structure, globals properly stored, since everything in D is TLS and C doesn't then you'll see weird constructs everywhere. If you ask me, it's probably not something you want to do and there really isn't a reason to do it with D either. D has an almost 100% compatibility with C already.
Jan 23 2017
On Monday, 23 January 2017 at 14:53:54 UTC, Bauss wrote:I'd guess the code generation you'd get from doing so with D would be absolute horrific to read, because you'll get rid of CTFE, templates, proper class structure, globals properly stored, since everything in D is TLS and C doesn't then you'll see weird constructs everywhere.TLS is a nonissue. You can wrap the TLS declarations in macros.
Jan 23 2017