5 ms·
What language has C++ interop?
by Scarbutt 3y ago
What language has C++ interop?
- nicwilson 3y agoD does. Not source compatible, but mangling and ABI for linking. And D can generate headers for `extern(C++)` declarations defined in D
- zem 3y agoi've come across carbon (google's c++-next language), clasp (common lisp with an llvm backend), felix (compiler generates c++), and maybe a couple of others i'm forgetting. also some languages have packages that deal with c++ interop to varying extents - see this discussion: https://www.reddit.com/r/ProgrammingLanguages/comments/huhy8i/is_there_a_programming_language_that_can_use_c/ https://www.reddit.com/r/ProgrammingLanguages/comments/huhy8...
- elcritch 3y agoNim does as well. You can use the C++ backend and wrap a decent bit of C++. The imports aren’t automatic so you need to define the FFI, but you can call templates, implement virtual methods, call constructors, etc. NimForUE takes advantage of this: https://youtu.be/Cdr4-cOsAWA https://youtu.be/Cdr4-cOsAWA
- macshome 3y agoSwift just added C++ interop in version 5.9. https://forums.swift.org/t/c-interoperability-in-swift-5-9/65369 https://forums.swift.org/t/c-interoperability-in-swift-5-9/6...
- pjmlp 3y agoBesides all other answers, .NET ecosystem, and IBM i TIMI, by having a C++ compiler as well.
- nh2 3y agoHaskell: It is implemented as a library, without needing compiler support [*]. You can write C++ in TemplateHaskell (Haskell's strongly typed AST-generating macro system), which allows you to use Haskell variables in scope inside your C++ functions. The "inline-c" library allows this for C and C++. Example of its use in the Haskell OpenCV bindings: https://hackage.haskell.org/package/opencv-0.0.2.1/docs/src/OpenCV-Features2d.html#orbDetectAndCompute https://hackage.haskell.org/package/opencv-0.0.2.1/docs/src/... The way it works: It invokes the C++ compiler for you to generate a wrapper function that closes over the Haskell variables used in your code snippet, and on the Haskell side generates a corresponding type-safe function call for you. This approach allows you to use all C++ features that a C++ compiler supports. But it also carries the drawback of ... invoking a C++ compiler, which gives you the slow build speed of C++. [*] Some compiler support was added to be able to specify compiler flags that are specific to the C++ compiler but not the C compiler.
- gpderetta 3y agoLove the non-standard formatting :). It took me a while to see where haskell ended and C++ started. Seems very powerful.