January 30

On Tuesday, 30 January 2024 at 15:17:31 UTC, Dibyendu Majumdar wrote:

>

The idea of generating automatic bindings to declarations in header files may have been old, but the idea of compiling actual C programs appears to have come from Zig:

https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html

The idea is not new and unique for Zig
3 years before your post https://users.rust-lang.org/t/rustcc-a-c-compiler-written-in-rust/14322/4

January 30

On Tuesday, 30 January 2024 at 15:17:31 UTC, Dibyendu Majumdar wrote:

>

On Tuesday, 30 January 2024 at 14:27:18 UTC, bachmeier wrote:

>

It's not full ImportC, but I remember Walter was talking about adding C header translation to the compiler well before that, and apparently it was an old idea by then:

The idea of generating automatic bindings to declarations in header files may have been old, but the idea of compiling actual C programs appears to have come from Zig:

https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html

There were discussions about the possibility of dmd compiling C code several years ago. My search attempts keep turning up way too many pages, but this is an old idea in the D community.

January 30

On Tuesday, 30 January 2024 at 15:17:31 UTC, Dibyendu Majumdar wrote:

>

On Tuesday, 30 January 2024 at 14:27:18 UTC, bachmeier wrote:

>

It's not full ImportC, but I remember Walter was talking about adding C header translation to the compiler well before that, and apparently it was an old idea by then:

The idea of generating automatic bindings to declarations in header files may have been old, but the idea of compiling actual C programs appears to have come from Zig:

https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html

Zig did it before D (arguably C++ and Objective C did something similar well before Zig). It doesn't really matter if Walter knew about what Zig was doing or not. It was a good idea and it's a good addition to D at the end of the day.

January 30

On Tuesday, 30 January 2024 at 15:36:34 UTC, Mike Parker wrote:

>

There were discussions about the possibility of dmd compiling C code several years ago. My search attempts keep turning up way too many pages, but this is an old idea in the D community.

Okay, here's an early discussion. Not exactly the same, but in the ballpark:

https://www.digitalmars.com/d/archives/22625.html

>

At first pass, I would assume that the C source would be passed without modification into the system's C compiler; the D compiler would then automatically link the C compiler's .o file with the D compiler's .o file.

January 30

On Tuesday, 30 January 2024 at 15:44:28 UTC, Mike Parker wrote:

>

On Tuesday, 30 January 2024 at 15:36:34 UTC, Mike Parker wrote:

>

There were discussions about the possibility of dmd compiling C code several years ago. My search attempts keep turning up way too many pages, but this is an old idea in the D community.

Okay, here's an early discussion. Not exactly the same, but in the ballpark:

https://www.digitalmars.com/d/archives/22625.html

And here's the earliest discussion of an ImportC-style thing that I can find (2006):

https://www.digitalmars.com/d/archives/digitalmars/D/35483.html

>

Why not enable dmd to "import" C header files directly?

One of the commenters listed this as a point against:

>
  1. Writers of other D compilers will feel compelled to build in a C compiler so that they can compile such projects.
January 30

On Tuesday, 30 January 2024 at 15:53:50 UTC, Mike Parker wrote:

>

On Tuesday, 30 January 2024 at 15:44:28 UTC, Mike Parker wrote:

>

On Tuesday, 30 January 2024 at 15:36:34 UTC, Mike Parker wrote:

>

[...]

Okay, here's an early discussion. Not exactly the same, but in the ballpark:

https://www.digitalmars.com/d/archives/22625.html

And here's the earliest discussion of an ImportC-style thing that I can find (2006):

https://www.digitalmars.com/d/archives/digitalmars/D/35483.html

>

Why not enable dmd to "import" C header files directly?

One of the commenters listed this as a point against:

>
  1. Writers of other D compilers will feel compelled to build in a C compiler so that they can compile such projects.

Does it really matter?

January 30

On Tuesday, 30 January 2024 at 15:58:46 UTC, jmh530 wrote:

>

On Tuesday, 30 January 2024 at 15:53:50 UTC, Mike Parker wrote:

>

On Tuesday, 30 January 2024 at 15:44:28 UTC, Mike Parker wrote:

>

On Tuesday, 30 January 2024 at 15:36:34 UTC, Mike Parker wrote:

>

[...]

Okay, here's an early discussion. Not exactly the same, but in the ballpark:

https://www.digitalmars.com/d/archives/22625.html

And here's the earliest discussion of an ImportC-style thing that I can find (2006):

https://www.digitalmars.com/d/archives/digitalmars/D/35483.html

>

Why not enable dmd to "import" C header files directly?

One of the commenters listed this as a point against:

>
  1. Writers of other D compilers will feel compelled to build in a C compiler so that they can compile such projects.

Does it really matter?

The history of programming languages is interesting in itself and it's good to acknowledge those making progress. It's also good to adopt/adapt the pioneering work of others. I'd also note that many programmers come to previously discovered good ideas independently.

OTOH, I think we've all known people who have made false claims in this area. I'd rather associate with those who don't.

So, yes, I think it matters but I don't see it as a big problem within the D community itself.

January 30

On Tuesday, 30 January 2024 at 15:58:46 UTC, jmh530 wrote:

>

Does it really matter?

Of course not. Just sharing what I found since it came up.

January 30

On Tuesday, 30 January 2024 at 16:27:34 UTC, Mike Parker wrote:

>

On Tuesday, 30 January 2024 at 15:58:46 UTC, jmh530 wrote:

>

Does it really matter?

Of course not. Just sharing what I found since it came up.

It doesn't matter as such, but answering competition is a good excuse for it :-)

January 30
On 1/30/2024 12:24 AM, Paolo Invernizzi wrote:
> I'm just wondering how good it is to perform CTFE on C code ... humm
> We are using a custom sql parser, imagine being able to use this [1] instead ... at compile time obviously.

CTFE works just fine on ImportC code !!

I use it to speed up tests in the ImportC test suite. No need to build an executable for many of the semantic tests.