[swift-evolution] associated objects

Chris Lattner clattner at apple.com
Fri Sep 30 18:47:54 CDT 2016

On Sep 30, 2016, at 2:51 PM, Ted F.A. van Gaalen via swift-evolution <swift-evolution at swift.org> wrote:
> Is it possible to have best of (these completely different) both worlds? 

Yes, of course it is.  Your email spends a lot of words trying to form a false dichotomy.  Swift can definitely have both awesome dynamic features while still having performance, predictability and safety.

> Would it be possible in Swift to have facilities to generate objects 
> dynamically at runtime? and, if desirable, how can such be implemented?

Here’s an extant implementation that you can use today:

I’m sure it isn’t ideal, but it proves that it can be done.  When we have bandwidth to reevaluate this area from first principles, I’m sure we can make improvements on it.

I will grant you that Smalltalk is a beautiful language in its simplicity, but for that simplicity it makes many tradeoffs that we’re not willing to make.  We are willing to make the internal implementation of Swift complex if that means that we get a beautiful model for programmers - one that preserves the virtues of safety-by-default, predictability, performance, and joy-to-develop-in.

The meme of “Swift can never (or will never) support dynamic features” is tired, and also wildly inaccurate.


More information about the swift-evolution mailing list