Hacker Newsnew | past | comments | ask | show | jobs | submitlogin



Then a question: how does one call these APIs from another language? You can use Objective-C frameworks from anything that can call C functions, by manually doing objc_msgSend and all the related stuff. But will you have to write a Swift wrapper for these?


I would guess that's the linker's job?

I don't need to do that in my day to day job, but I do remember that as part of an OS class at school (some 20+ years ago) one of the tasks we were assigned was that we had to work in pairs of teams, where one team would implement a function and another team would implement code that called that function, the only requirement being that both teams had to use different languages. The point of the exercise was to show how, provided you had a defined API, thanks to linking you could use the best language for each job.


In many languages you need to somehow define the symbols you import before the linker comes into play. How would you define Swift symbols for C++? For Java? For Rust? And that's provided their linkers would actually know what the Swift ABI is — and they most probably don't. So I guess your only option would be to descend all the way down to assembly and shove the right things into the right registers and then jump to the right place.


Yes, just like on Android you will need to write Java or Kotlin, and the NDK only exposes game development APIs.

Objective-C is done, see WWDC 2022.


On macOS, the Swift ABI is stable. It is different from the C or C++ ABI. Somebody would need to implement the Swift ABI for another language. Which is kinda tricky because Swift has many features that other languages don’t have. Rust could probably do it, or C++ with a ton of templates I guess.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: