August 23, 2017
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/

"D polymorphic classes will not, as they rely on the garbage collector."

They do? Don't have to allocate classes on the GC heap.
August 23, 2017
On Wednesday, 23 August 2017 at 14:37:19 UTC, Steven Schveighoffer wrote:
> 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

They don't (right now, using dmd ~master), because they depend on druntime:

--- a.c ---
#include <stdio.h>
#include <stdint.h>

uint32_t foo();

int main(int argc, char** argv)
{
    uint32_t x = foo();
    printf("%d\n", x);
}
-----------

--- b.d ---
auto test()
{
    uint i = 42;
    return () {
        return i;
    };
}

oo()
{
    auto x = test();
    return x();
}
-----------

$ dmd -c -betterC b.d
$ gcc a.c b.d
Undefined symbols for architecture x86_64:
  "__d_allocmemory", referenced from:
      _D1b4testFNaNbNfZDFNaNbNiNfZk in b.o
ld: symbol(s) not found for architecture x86_64extern(C) uint foo()
{
    auto x = test();
    return x();
}
-----------

$ dmd -c -betterC b.d
$ gcc a.c b.d
Undefined symbols for architecture x86_64:
  "__d_allocmemory", referenced from:
      _D1b4testFNaNbNfZDFNaNbNiNfZk in b.o

August 23, 2017
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/

nice article, however very unfortunate  introduction for the ADHD Generation as you start reading and you get put of by historical disabilities of D that are not true anymore. you may want to edit that and add the "until now" beforehand ;)
August 23, 2017
On Wednesday, 23 August 2017 at 15:17:31 UTC, Moritz Maxeiner wrote:
> On Wednesday, 23 August 2017 at 14:37:19 UTC, Steven Schveighoffer wrote:
>> 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
>
> They don't (right now, using dmd ~master), because they depend on druntime:
>
> [...]

Sorry, I screwed up when pasting. Here's what I meant to post:


--- a.c ---
#include <stdio.h>
#include <stdint.h>

uint32_t foo();

int main(int argc, char** argv)
{
    uint32_t x = foo();
    printf("%d\n", x);
    return 0;
}
-----------

--- b.d ---
auto test()
{
    uint i = 42;
    return () {
        return i;
    };
}

$ dmd -c -betterC b.d
$ gcc a.c b.d
Undefined symbols for architecture x86_64:
  "__d_allocmemory", referenced from:
      _D1b4testFNaNbNfZDFNaNbNiNfZk in b.o
August 23, 2017
On 8/23/2017 7:24 AM, Steven Schveighoffer wrote:
> Looks like there are some outstanding requests to be fulfilled before it's pulled.

I don't agree that the requests improve matters.

August 23, 2017
On 8/23/2017 7:10 AM, Steven Schveighoffer wrote:
> It's only if you do something that needs the runtime, such as static ctors, or use the GC.

Or use asserts, or even declare a struct.

August 23, 2017
On 8/23/2017 7:10 AM, Steven Schveighoffer wrote:
> Nope.

A ModuleInfo is generated, as well as FMB/FM/FME sections. Those sections may not work with the C runtime.
August 23, 2017
On 8/23/2017 8:05 AM, John Colvin wrote:
> "D polymorphic classes will not, as they rely on the garbage collector."
> 
> They do? Don't have to allocate classes on the GC heap.

Using them without the GC is a fairly advanced technique, and I don't want to deal with people writing:

    C c = new C();

and complaining that it doesn't work.
August 23, 2017
On 8/23/2017 7:37 AM, Steven Schveighoffer wrote:
> How do dynamic closures work without the GC?

They don't allocate the closure on the GC heap. (Or do I have static/dynamic closures backwards?)
August 23, 2017
On Wednesday, 23 August 2017 at 15:53:11 UTC, Walter Bright wrote:
> On 8/23/2017 7:10 AM, Steven Schveighoffer wrote:
>> It's only if you do something that needs the runtime, such as static ctors, or use the GC.
>
> Or use asserts, or even declare a struct.

No structs in -betterC ???