Alas, the steps Swift is taking all seem to be going in the opposite direction: more compile-time, more strictness, less dynamicism. As has been written before: Swift is not a better Objective-C, it is a better C++.
I really hope I am wrong about this, but given the current direction, the expressed philosophy and values as well as the predilections of the people involved, I don't see the direction changing from the initial vector.
I'm not disputing the idea that instead of replacing the C, Swift's designers could have focussed on enhancing the message passing component, but I would argue that doing so without also replacing the C would have been a mistake.
Perhaps the dynamic elements will also be overhauled over time.
Huh?
"Requiring dynamic dispatch is rarely necessary."
"The bad news is that, by default, your objects will no longer work with KVO or swizzling. If the designer of a class doesn’t anticipate a reason for a particular method or property to be dynamic, that lack of foresight gets baked in at compile time."
etc.
See http://mjtsai.com/blog/2014/08/18/its-a-coup/
If that is not correct, I'd love to hear about it!
> Swift's designers could have focussed on enhancing the message passing component,
That would have been great.
> doing so without also replacing the C would have been a mistake.
Absolutely. But really they've replaced the "Objective" and enhanced the C. After all, Objective-C is a blend of Smalltalk and C. If you remove the C, what is left?
>Perhaps the dynamic elements will also be overhauled over time.
Maybe. So far, that "overhaul" seems to be mostly de-emphasis, deprecation and removal. :-(
But, I'll concede that KVO won't work with arbitrary properties of binary libraries you receive or that Apple builds into the platform, assuming they use swift and choose not to mark them dynamic.
So in this sole regard, swift is less dynamic.
I guess it remains to be seen whether this actually becomes a problem.
Precisely. For example, a lot of Cocoa these days relies on dictionaries and/or stringly-typed identifiers: KVC, KVO, Bindings, Archiving, CoreImage attributes, CoreData's interface to the database etc, etc. Autolayout also uses a separate string-based language.
There are a lot of problems with this approach, not the least of which are performance, code bloat and lack of any kind of compile-time checking.
Polymorphic Identifiers[1] in Objective-Smalltalk[2] are an attempt at addressing these issues (and others). The paper shows why you actually need a small amount of language support to successfully build libraries that address these issues.
I wish I could complain about how Swift's approach to these issues is so much inferior to mine (grin), but there just isn't anything at all. If anything, support for solving these sorts of problems is thinner than in Objective-C. Yikes!
Another issue is the large-scale structure of applications...their architecture: target/action, delegates, bindings (again), notifications, view-controller segues etc. are all architectural connectors, and a large part of what makes Cocoa so powerful. However, these types of connections (-> configurations) can only be described in ad-hoc ways in code, or in a different ad-hoc way in IB. Various inspectors of a GUI builder are not really the proper place to describe the overall architecture of your program.
There have been many systems/languages for describing such high-level architectures, for example ArchJava or ACME. In Swift? Crickets.
When direct language support for a feature is not present, dynamic messaging has been a great way of making library features available as if they were built-in language features. Swift makes this harder or downright impossible.
> Swift wasn't designed to make better libraries and tools possible
Yep. In fact, it's arguably a step back even compared to Objective-C. Which is sad.
> but rather to work well with the ones we already have.
Except that it doesn't really work all that well with existing ones either. Objective-C interop seems to clearly be marked "legacy", with the default apparently non-interoperability.
[1] https://www.hpi.uni-potsdam.de/hirschfeld/publications/media...
[2] http://objective.st/