[Swift] Use dynamic dispatch by default

Number:rdar://17306182 Date Originated:6/13/14
Status:Closed Resolved:As Intended
Product:Developer Tools Product Version:
Classification: Reproducible:
Swift objects, by default, use vtables to pass messages. This is fast and efficient, but requires the loss of many of the benefits of Objective-C’s late binding / dynamic dispatch. In the general case, these loses are not worth the tradeoff. Dynamic dispatch puts tremendous power in the hands of programmers in a safe, sensible way. Vtables give you performance. And really, nothing else. 

I’m not arguing that vtables should be removed from the Swift language, rather that they should only be used when the programmer requests it. Things this would allow:

- All of the flexibility of dynamic dispatch would be first class citizens of the language, rather than a bridge to the old guard.
- Safe handling of nil objects, without having to resort to noisy syntax that many programmers are likely going to end up abusing because they can’t be bothered to learn to do it properly.
- In those extremely rare cases where the overhead of dynamic dispatch actually causes a performance issue, the programmer would have the power to make this tradeoff of flexibility for performance.

This is fundamental. Flexibility should trump performance - but let us turn on the performance where we need to.

Steps to Reproduce

Expected Results

Actual Results


Xcode Version
Xcode 6 Beta 1

Additional Notes


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!