3 ms·
Swift is a nice language but its reliance on reference counting means you have to work a lot harder to avoid retain cycles than you do in a garbage collected la
by cageface 8y ago
Swift is a nice language but its reliance on reference counting means you have to work a lot harder to avoid retain cycles than you do in a garbage collected language.
That might have been the right choice for Apple’s uses of Swift where GC pauses affect the user experience but for most other use cases it’s too much of a cognitive burden IMO.
- saagarjha 8y agoPersonally, I find that this only really comes up rarely. Most of the time strong references are fine.
- cageface 8y agoMy iOS code is loaded with weak/strong ref handling logic. It comes up all the time when using closures in UIKit.
- saagarjha 8y agoUIKit is kind of annoying because it’s really not “idiomatic” Swift: it’s a wrapper around Objective-C (albeit, a very nice one) that happens to bring along with it a bunch of decisions that lead to having to deal with reference lifetimes.
- cageface 8y agoThat could be. I'll admit I haven't used Swift at all outside of coding Appkit/UIKit apps.
- dep_b 8y agoiOS Swift is usually the front-end code which means that you're doing a lot of connections to data sources elsewhere. Non-blocking connections always need a weak/strong dance. If you're using Swift for logic most of that is gone.