5 ms·
Most languages have some type of "extern C" as part of their FFI. It should be possible to use C as a langua franca between two non C languages.
by gizmo686 12y ago
Most languages have some type of "extern C" as part of their FFI. It should be possible to use C as a langua franca between two non C languages.
- blinkingled 12y ago> It should be possible to use C Ugh, wouldn't that fall in "just because you can do something doesn't mean you actually should" category? :) Suppose I wrote the library in Go and exported some type of C wrapper and then I loaded that in Rust using Rust->C mechanism - that will load the Golang runtime in Rust! And you still got non-trivial C code to deal with anyways!
- gizmo686 12y agoIf you want to interface two languages, then I do not see a way arround involving the runtime of both languages (in the same way that linking to C code still uses the C runtime). However, using my method does not actually involve any C code. "extern C" makes the compiler produce object code that can be called as if it was produced by C code; it does not produce any C code that would compile to the given object code. Of course, it will also produce C headers to give the type information of the exported symbols, but I wouldn't call that code.