Re:Next C compiler is a D compiler: Introducing DMD's ImportC
by boundchecked on Wednesday November 02, 2022 @10:32PM
(#33446185)
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
by IceWreck on Thursday November 03, 2022 @02:17AM
(#33447678)
You can use C libraries in Rust, even compiled .so files where you dont have the corresponding C headers.
Re:Next C compiler is a D compiler: Introducing DMD's ImportC
by bachmeier on Wednesday November 02, 2022 @10:03PM
(#33445910)
> 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
by newpavlov on Wednesday November 02, 2022 @10:08PM
(#33445967)
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
by yvdriess on Thursday November 03, 2022 @04:56AM
(#33448560)
You can link in and interop fine with C/C++ as long as you link in the D runtime, kind of how you can mix C and C++ by linking in libcxx.
D's betterC mode ensures that the binary can run purely on libc without D's runtime library. It's kind of like being able to link and execute C++ code without needing libcxx.
Re:Next C compiler is a D compiler: Introducing DMD's ImportC
by eptcyka on Thursday November 03, 2022 @06:46AM
(#33449215)
There are serious considerations for including Go code in a rust project, but it's not like there are any showstoppers - one just can't use the default runtime and must rely on Cgo, and the FFI entry points are not performant. Other than that, it's relatively painless. Far less painful than calling into the JVM IMO.
Re:Next C compiler is a D compiler: Introducing DMD's ImportC
by Doxin on Thursday November 03, 2022 @03:49AM
(#33448170)
> Using D code in Rust probably will be much more painful and I am not sure if it can be done 100% safely
You can just as easily declare D code to be extern(C) and have rust treat it as a C library.
Using D code in Rust probably will be much more painful and I am not sure if it can be done 100% safely...