Jump to page: 1 28  
Page
Thread overview
August 23
To coincide with the improvements to -betterC in the upcoming DMD 2.076, Walter has published a new article on the D blog about what it is and why to use it. A fun read. And I'm personally happy to see the love this feature is getting. I have a project I'd like to use it with if I can ever make the time for it!

The blog:

https://dlang.org/blog/2017/08/23/d-as-a-better-c/

Reddit:
https://www.reddit.com/r/programming/comments/6viswu/d_as_a_better_c/
August 23
On Wednesday, 23 August 2017 at 13:12:04 UTC, Mike Parker wrote:
> To coincide with the improvements to -betterC in the upcoming DMD 2.076, Walter has published a new article on the D blog about what it is and why to use it. A fun read. And I'm personally happy to see the love this feature is getting. I have a project I'd like to use it with if I can ever make the time for it!
>
> The blog:
>
> https://dlang.org/blog/2017/08/23/d-as-a-better-c/
>
> Reddit:
> https://www.reddit.com/r/programming/comments/6viswu/d_as_a_better_c/

Interesting article, though one thing that I'm confused by is

>> Hence D libraries remain inaccessible to C programs, and chimera programs (a mix of C and D) are not practical. One cannot pragmatically “try out” D by add D modules to an existing C program.

I've been mixing C and full D for a while now (on Linux) by either having the main C program call rt_init/rt_term directly (if druntime is linked in when building a mixed C/D application), or have Runtime.initialize/Runtime.terminate be called from D via some plugin_load/plugin_unload functionality when using D shared libraries.
Why is this not considered practical?
August 23
On 8/23/2017 6:28 AM, Moritz Maxeiner wrote:
> Interesting article, though one thing that I'm confused by is
> 
>>> Hence D libraries remain inaccessible to C programs, and chimera programs (a mix of C and D) are not practical. One cannot pragmatically “try out” D by add D modules to an existing C program.
> 
> I've been mixing C and full D for a while now (on Linux) by either having the main C program call rt_init/rt_term directly (if druntime is linked in when building a mixed C/D application), or have Runtime.initialize/Runtime.terminate be called from D via some plugin_load/plugin_unload functionality when using D shared libraries.
> Why is this not considered practical?

Because in order to add a D function as trivial as:

   int foo() { return 3; }

to a C program, now the C program has to link to druntime, and the program no longer has a small footprint. One of the reasons people use C is to get that small footprint. This has been a large barrier to C programs making use of D.

August 23
On Wednesday, 23 August 2017 at 13:12:04 UTC, Mike Parker wrote:
> To coincide with the improvements to -betterC in the upcoming DMD 2.076, Walter has published a new article on the D blog about what it is and why to use it. A fun read. And I'm personally happy to see the love this feature is getting. I have a project I'd like to use it with if I can ever make the time for it!
>
> The blog:
>
> https://dlang.org/blog/2017/08/23/d-as-a-better-c/
>
> Reddit:
> https://www.reddit.com/r/programming/comments/6viswu/d_as_a_better_c/

Great piece.

It might be useful to beef up the documentation on some of the things that betterC changes. For instance, here
http://dlang.org/dmd-windows.html#switch-betterC
links to TypeInfo, which has like one line of explanation of what it's for, and ModuleInfo isn't linked to at all (and I'm still a little unclear on what that does).
August 23
On 8/23/17 10:00 AM, Walter Bright wrote:
> On 8/23/2017 6:28 AM, Moritz Maxeiner wrote:
>> Interesting article, though one thing that I'm confused by is
>>
>>>> Hence D libraries remain inaccessible to C programs, and chimera programs (a mix of C and D) are not practical. One cannot pragmatically “try out” D by add D modules to an existing C program.
>>
>> I've been mixing C and full D for a while now (on Linux) by either having the main C program call rt_init/rt_term directly (if druntime is linked in when building a mixed C/D application), or have Runtime.initialize/Runtime.terminate be called from D via some plugin_load/plugin_unload functionality when using D shared libraries.
>> Why is this not considered practical?
> 
> Because in order to add a D function as trivial as:
> 
>     int foo() { return 3; }
> 
> to a C program, now the C program has to link to druntime, and the program no longer has a small footprint. One of the reasons people use C is to get that small footprint. This has been a large barrier to C programs making use of D.
> 

Nope.

Stevens-MacBook-Pro:testd steves$ cat testdfunc.d
extern(C) int foo() { return 3; }
Stevens-MacBook-Pro:testd steves$ cat testdfunc_c.c
#include <stdio.h>
extern int foo();

int main()
{
    printf("%d\n", foo());
}
Stevens-MacBook-Pro:testd steves$ dmd -c testdfunc.d
Stevens-MacBook-Pro:testd steves$ gcc -o testdfunc testdfunc_c.c testdfunc.o
Stevens-MacBook-Pro:testd steves$ ./testdfunc
3


It's only if you do something that needs the runtime, such as static ctors, or use the GC.

-Steve
August 23
On 8/23/2017 7:01 AM, jmh530 wrote:
> ModuleInfo isn't linked to at all (and I'm still a little unclear on what that does).

That's because ModuleInfo doesn't appear in the online documentation due to having a malformed Ddoc comment. I fixed it here:

  https://github.com/dlang/druntime/pull/1906

but nobody has pulled it.
August 23
On Wednesday, 23 August 2017 at 14:01:30 UTC, jmh530 wrote:
> On Wednesday, 23 August 2017 at 13:12:04 UTC, Mike Parker wrote:
>> To coincide with the improvements to -betterC in the upcoming DMD 2.076, Walter has published a new article on the D blog about what it is and why to use it. A fun read. And I'm personally happy to see the love this feature is getting. I have a project I'd like to use it with if I can ever make the time for it!
>>
>> The blog:
>>
>> https://dlang.org/blog/2017/08/23/d-as-a-better-c/
>>
>> Reddit:
>> https://www.reddit.com/r/programming/comments/6viswu/d_as_a_better_c/
>
> Great piece.
>
> It might be useful to beef up the documentation on some of the things that betterC changes. For instance, here
> http://dlang.org/dmd-windows.html#switch-betterC
> links to TypeInfo, which has like one line of explanation of what it's for, and ModuleInfo isn't linked to at all (and I'm still a little unclear on what that does).

Walter has made a PR to improve the ModuleInfo documentation: https://github.com/dlang/druntime/pull/1906
August 23
On 8/23/17 10:11 AM, Walter Bright wrote:
> On 8/23/2017 7:01 AM, jmh530 wrote:
>> ModuleInfo isn't linked to at all (and I'm still a little unclear on what that does).
> 
> That's because ModuleInfo doesn't appear in the online documentation due to having a malformed Ddoc comment. I fixed it here:
> 
>    https://github.com/dlang/druntime/pull/1906
> 
> but nobody has pulled it.

Looks like there are some outstanding requests to be fulfilled before it's pulled.

-Steve
August 23
On Wednesday, 23 August 2017 at 14:00:34 UTC, Walter Bright wrote:
> On 8/23/2017 6:28 AM, Moritz Maxeiner wrote:
>> 
>> I've been mixing C and full D for a while now (on Linux) by either having the main C program call rt_init/rt_term directly (if druntime is linked in when building a mixed C/D application), or have Runtime.initialize/Runtime.terminate be called from D via some plugin_load/plugin_unload functionality when using D shared libraries.
>> Why is this not considered practical?
>
> Because in order to add a D function as trivial as:
>
>    int foo() { return 3; }
>
> to a C program, now the C program has to link to druntime, and the program no longer has a small footprint. One of the reasons people use C is to get that small footprint. This has been a large barrier to C programs making use of D.

Thank you, are there other factors involved, or is it only impractical for people who require minimal application size / memory footprint, then?
August 23
On 8/23/17 9:12 AM, Mike Parker wrote:
> To coincide with the improvements to -betterC in the upcoming DMD 2.076, Walter has published a new article on the D blog about what it is and why to use it. A fun read. And I'm personally happy to see the love this feature is getting. I have a project I'd like to use it with if I can ever make the time for it!
> 
> The blog:
> 
> https://dlang.org/blog/2017/08/23/d-as-a-better-c/
> 
> Reddit:
> https://www.reddit.com/r/programming/comments/6viswu/d_as_a_better_c/

How do dynamic closures work without the GC?

Nice article, BTW.

-Steve
« First   ‹ Prev
1 2 3 4 5 6 7 8