3 ms·
Personally I don't understand why strong reflection support has been left out of Swift. I can understand that there is probably a problem related to ARC and ga
by chvid 10y ago
Personally I don't understand why strong reflection support has been left out of Swift.
I can understand that there is probably a problem related to ARC and garbage collection. But missing this set of features means that there are lot of things that simply cannot be implemented in Swift and thus having remain in Objective-C (Core Data, other ORMs, IoC-frameworks etc.).
That means the iOS/OSX-platform will continue to be split in two programming languages and object-models for the foreseeable future.
- coldtea 10y ago>I can understand that there is probably a problem related to ARC and garbage collection. I don't think so, since Objective-C also uses ARC and is very dynamic. I'd say the typesystem/runtime of Swift might have more to do with it.
- mpweiher 10y agoWhile there are almost certainly other considerations as well, ARC definitely makes Objective-C much less dynamic. The Objective-C compiler gets significantly more strict with ARC turned on, for example sending unknown messages is an error instead of a warning. Various runtime functions that used to be quite safe also become dangerous, for example it used to be OK to send performSelector: style messages with non-object returning messages (void) and simply ignore the result. That now becomes a crash as ARC tries to retain the return value. So in order the be compatible with ARC, the "cheap and cheerful" reflection that ObjC has isn't really sufficient. ARC is predicated on the compiler having essentially a statically checkable call-chain.
- fit2rule 10y ago>That means the iOS/OSX-platform will continue to be split in two programming languages and object-models for the foreseeable future. iOS/OSX has been split into multiple languages for a long time, anyway. The C/C++-based framework subsystem has produced many others..