3 ms·
So if I understand it correctly, Apple decided to move that complexity to the language itself? I was reading up on the rules for references in Swift, and it loo
by lokedhs 7y ago
So if I understand it correctly, Apple decided to move that complexity to the language itself? I was reading up on the rules for references in Swift, and it looks like a lot of complexity and lots of opportunities for introducing errors leading to leaks.
- pjmlp 7y agoThat is the price to pay for reference counting as approach to automatic memory management. If you want to hide circular references from developers, then a cycle collector is required on the runtime. For example this was the approach taken by Mesa/Cedar, or for a more modern reference CPython. If you look into C++/CX or C++/WinRT, this issue is also surfaced to the programmer. Rust makes it even more explicit with its reference counting library types. At the end of the day, it depends on what Swift designers were optimising for. Which to me looks like the easiest and less performance impact to integrate with the Objective-C runtime and respective libraries. Swift's approach is still easier than doing the same from Objective-C, its target audience.