Re:It's Coming: The Great Swift API Transformation
by LeoNatan25 on Saturday January 30, 2016 @05:34PM
(#11004121)
Swift has not abandoned this dispatch method "from the get-go", it is still very much one of the supported dispatch methods in the Swift runtime.
https://news.ycombinator.com/item?id=10725707 https://lists.swift.org/pipermail/swift-evolution/Week-of-Mo...
Re:It's Coming: The Great Swift API Transformation
by pcwalton on Saturday January 30, 2016 @08:01PM
(#11004700)
Well, for Objective-C compatibility, and maybe for interfaces/protocols (depending on whether they use fat pointers or not), they need that capability. But Swift tries to push you into C++-like vtables when possible.
(If you're thinking "wow, that must be slow", you're right: objc_msgSend is very heavily optimized, but you can't beat one load from a fixed offset and an indirect jump as in C++ and Java. This is why Swift made the decision to abandon this model from the get-go. Other dynamic languages have ways to optimize this and eliminate the hash table lookup in most cases, but these techniques require self-modifying code, which Apple doesn't want to use; the only feasible solution for Apple's native language was to switch to a different semantics.)