Live data from Hacker News

Next C compiler is a D compiler: Introducing DMD's ImportC

briancallahan.net

31–40 of 89 posts

Re: Next C compiler is a D compiler: Introducing DMD's ImportC

#31
post #21

Earlier quoted context omitted.

Can DMD compile C projects directly similar to the Zig compiler?

I haven't used Zig, but DMD can compile C projects directly using makefiles or by simply putting the .c files on the dmd command line.

Zig can be used as a standalone CC replacement and not just for FFI purposes.

Re: Next C compiler is a D compiler: Introducing DMD's ImportC

#32

Hello Walter, do you have any advice on integrating Rust and D? Especially regarding GC

Using Rust code in D should be relatively easy: expose C API, compile it into a shared library and use it on the D side as any other library. cbindgen (https://github.com/eqrion/cbindgen) can help with generation of header files. Static linking is possible as well.

Using D code in Rust probably will be much more painful and I am not sure if it can be done 100% safely...

Re: Next C compiler is a D compiler: Introducing DMD's ImportC

#33

Earlier quoted context omitted.

My mistake. Thanks for pointing it out.

I don't think it's your mistake. It seems HN automatically removes certain leading/trailing words from titles so as to reduce clickbait but it doesn't seem to be very smart about it.

It gets annoying, because in cases like this it doesn't make sense, but in other cases it actually changes the meaning of the title. I honestly don't understand it given the prohibition against submitters changing the title.

Re: Next C compiler is a D compiler: Introducing DMD's ImportC

#34

Hello Walter, do you have any advice on integrating Rust and D? Especially regarding GC

Using Rust code in D should be relatively easy: expose C API, compile it into a shared library and use it on the D side as any other library. cbindgen ( https://github.com/eqrion/cbindgen ) can help with generation of header files. Static linking is possible as well. Using D code in Rust probably will be much more painful and I am not sure if it can be done 100% safely...

> Using D code in Rust probably will be much more painful and I am not sure if it can be done 100% safely...

Can you elaborate? Saying it will be "much more painful" without anything further is not especially helpful. I've added D functions to C programs more or less trivially, including compiling to a shared library, with no change to the code.

Re: Next C compiler is a D compiler: Introducing DMD's ImportC

#35

Earlier quoted context omitted.

Using Rust code in D should be relatively easy: expose C API, compile it into a shared library and use it on the D side as any other library. cbindgen ( https://github.com/eqrion/cbindgen ) can help with generation of header files. Static linking is possible as well. Using D code in Rust probably will be much more painful and I am not sure if it can be done 100% safely...

> Using D code in Rust probably will be much more painful and I am not sure if it can be done 100% safely... Can you elaborate? Saying it will be "much more painful" without anything further is not especially helpful. I've added D functions to C programs more or less trivially, including compiling to a shared library, with no change to the code.

Because I am not knowledgeable about D runtime I can not say that it will not cause any conflicts with Rust assumptions (thus the use of "probably"). For example, IIRC there are serious issues with integrating Go code into a Rust project. If D code is compiled in the betterC mode, then there should not be any problems.

Re: Next C compiler is a D compiler: Introducing DMD's ImportC

#36

Hello Walter, do you have any advice on integrating Rust and D? Especially regarding GC

Using Rust code in D should be relatively easy: expose C API, compile it into a shared library and use it on the D side as any other library. cbindgen ( https://github.com/eqrion/cbindgen ) can help with generation of header files. Static linking is possible as well. Using D code in Rust probably will be much more painful and I am not sure if it can be done 100% safely...

I don't think Rust will ever consider FFI'in with another language "100% safe."

Re: Next C compiler is a D compiler: Introducing DMD's ImportC

#39

Walter, since you're here: what's your position regarding bootstrapping and Ken Thompson's "Reflections on Trusting Trust"?

David Wheeler's Ph.D dissertation on the subject hasn't been refuted as far as I know, so the diverse double compilation method should be sufficient to mitigate the compiler subversion threat. I worked on a project to do this in OpenEmbedded to build firmware for the Power9 Talos workstation firmware and the BMC. Somewhat painful but successful.
Post reply on HN