Hacker News new | ask | show | jobs
by ChubbyGlasses 1600 days ago
This is really nice to see; apart from the weirdly named, macOS specific NS* apis, Swift has been a real pleasure to use and, refreshingly, feels like a language designed for humans first. I hope this means Swift has a chance to eat Rusts’ lunch :)

Does anyone know how c++ classes and struct will interact with ARC?

2 comments

> The biggest semantic impedance mismatch between C++ classes and Swift classes is that Swift classes are reference-counted. It is certainly possible to import a C++ class as a Swift class if it is intrusively reference counted, or wrapped in a shared_ptr.

> But what about non-movable C++ classes that are not reference counted? This issue could be worked around by making retain and release operations on C++ classes be a no-op, and introducing an explicit "delete" operation, effectively making C++ class references in Swift equivalent to UnsafeMutablePointer.

There's some information about it in https://github.com/apple/swift/blob/main/docs/CppInteroperab... this is quite long though so there's likely a lot more information. This quote is apparently just one strategy they're considering? At least that's my take on reading it.

NS stands for NextStep.