| ▲ | flohofwoe 5 hours ago | |
Raylib has a C API though, and this is 'easy-mode' in any language (even without integrated bindings generation like Swift or Zig have - e.g. it's fairly trivial to write a bindings generator that uses Clang's ast-dump json file format as input and translates the API declarations into another language. A more interesting question would be how well the C++ interoperability works that was added in Swift 5.9, does it work with all C++ headers, even headers that make extensive use of template code. Also how does Swift extract information needed for lifetime tracking, e.g. C++ APIs that return smart pointers and object lifetime ends on the caller's side. Does this only work for C++ stdlib smart pointer types, or are custom types also supported. | ||
| ▲ | Someone 4 hours ago | parent | next [-] | |
> A more interesting question would be how well the C++ interoperability works They’re using it in their work on FoundationDB. Looks good, but has limitations. Swift can call C++ and vice versa, Swift classes can inherit from C++ and vice versa, but not for all code, and may need work adding annotations on the C++ side. See https://github.com/apple/foundationdb/blob/main/SWIFT_GUIDE..... There’s a good video on that work from a few years ago that was discussed on HN in https://news.ycombinator.com/item?id=38444876. | ||
| ▲ | repelsteeltje 5 hours ago | parent | prev [-] | |
For sure — that's where it gets difficult. Show me a real C++ interop example. Does function, constructor and operator overloading resolve correctly? How about C++26 reflection? | ||