News for hackers. Stuff that matters.
Re:On Apple's Love Affair with Swift by masklinn on Saturday August 11, 2018 @11:38AM (#17740086)
> That’s why LLVM is such a great idea - any llvm language can interoperate with any other, within the same binary, with no overhead.

I don't believe LLVM provides a stable cross language ABI, and AFAIK languages just use regular FFI (via the C ABI) to communicate with one another, regardless of them being implemented on LLVM or not.

Re:On Apple's Love Affair with Swift by ihnorton on Saturday August 11, 2018 @01:32PM (#17740636)
> I don't believe LLVM provides a stable cross language ABI, and AFAIK languages just use regular FFI (via the C ABI) to communicate with one another

Provided the compilers generate compatible versions of LLVM IR, then cross-language calls can be done at the IR level. See github.com/Keno/Cxx.jl

IIUC Swift already uses clang to load module maps in order to expose and call Objective-C, and they plan to do something similar with C++ (no link handy but I think there is an issue or enhancement proposal about it).

Re:On Apple's Love Affair with Swift by slavapestov on Saturday August 11, 2018 @08:46PM (#17742327)
Yeah, Swift’s C interop goes further than most typical FFIs because it actually calls into Clang internals to read headers, lay out structs and form calls. C and Objective-C types, functions and methods are mapped to Swift definitions, by directly looking at the Clang AST.
Re:On Apple's Love Affair with Swift by matheusmoreira on Sunday August 12, 2018 @01:28PM (#17745353)
> C ABI

Is there really such a thing? I thought the ABI was dependent on the operating system and compiler.

I agree that C is unique in it's ability to generate programs that can be interfaced with from any language. This also seems to apply to older languages like Fortran and Pascal, for some reason. Higher level languages are an ABI nightmare; seriously doubt anyone will ever dynamically link against a C++ library at runtime and call a method on a C++ object from any language that isn't C++.