Tom,
To the limits that Swift is described, yes, it should be free to talk about. Of course, Swift is just the language -- it has nothing to do with the additions or changes made to the SDK, most of which are still under NDA, of course.
As to how Swift will impact PhoneGap -- here's my thoughts:
- Initially: very little impact at all. Swift interops with Obj C just fine, so there's no need to rewrite what works. The only reason to do so would be to improve performance (Swift can be faster) or of Obj C goes away. I doubt there's much performance increase that can be pulled out of PG's startup simply by switching languages (most of this deals with instantiating a web view, which takes time, and then code running within that web view), and Obj C isn't going away any time soon.
- Short-term: I expect PhoneGap will begin seeing Swift-powered plugins. I haven't tried writing one yet, but it might lower the entry barrier when it comes to writing native plugins. OTH, it does nothing for the SDKs, which is the majority of what one has to learn. Syntax is easy -- SDKs are hard.
- Long-term: I expect that if Swift takes off like Apple hopes, Obj C will eventually be deprecated. I expect that over the years, Swift will be able to do everything Obj C does now (and it looks like it can do that /now/, from my cursory glance), and the language will be continually improved. If the developer community switches to Swift en masse, there will be little incentive to continue Obj C enhancements, IMO. Prior to that point, I would expect that PG would slowly migrate bits and pieces over to Swift as the developer community also migrates from Obj C to Swift. (Even if only through attrition.) I would expect this process to take years within the community, so whether or not PG would switch as quickly remains to be seen. I guess it depends on the influx of new committers who work in the language.
Swift itself looks like an interesting language, with a lot to love, and with a few failings from my cursory overview:
- Parts of it feel like an ObjC wrapper, only prettier -- akin to CoffeeScript over JavaScript. There are a few places where Apple should have made a more obvious break from the Obj C underpinnings -- but of course, with Obj C interop a de facto requirement, this would have been difficult to accomplish.
- Parts of it feel like a language designed by committee. I'm not terribly in favor of operator functions, for example -- a + should not be able to be overridden -- at some point some one is going to have the operator do something funny, and the code is no longer self-descriptive. That c-style for-loop is dreadfully out-of-place when considering the other loops, imo.
- Parts of it feel like doing a thing simply to do that thing. For example, a common error with zero-based arrays is to loop from 0 through to the length -- which will result in a range error. Swift's solution to this is to introduce two range operators: the "..." operator which operates on all the values inclusive (0...3 = 0,1,2,3), and the ".." operator which operators on all the values but the last (0..3=0,1,2). Now, I don't know about you, but that is not at all immediately apparent from my reading of the source code. Sure, it might eliminate one class of mistakes, only to replace them with another class entirely (or a couple). Much better, in my opinion, to have done something like this: [0...3]=0,1,2,3, [0...3)=0,1,2, (0...3)=1,2, (0...3]=1,2,3. Consistent, and makes sense when reading the source (although it only does so with integers, since reals would imply 0.00...01 - 2.99..99). But honestly, why can't we write "for x in 0..(length-1)": it makes sense, and what is going on is clearly visible in the source without having to know the esoterica of the language. The ? and ! operators feel a bit like this too, in my opinion, and add a level of obtuseness to the language that it doesn't need. I understand the point is to reduce having to worry about nillable variables, but to someone who doesn't know the language ? and ! are going to come across as "odd" -- in much the same way as "[...]" came across in Objective C.
- Did I miss it, or is there really no try...catch/exception handling here? I did a search to be sure, and I don't see it anywhere. I suppose multiple return values from functions helps (so being able to return a value and a failure/success message). I know Apple eschews exception handling for various reasons, but I was surprised to not see this make an appearance for user code at the least (even if the SDK didn't use it).
- No async handling built in -- I assume Apple is relying on their other thread handling methods in the runtime to handle this, but it would have been nice to have direct equivalents to yield and such.
- A few of the keywords just feel funny: why `func` vs `function`? Why `init/deinit` vs `func init` and `func destroy`? (I know there are reasons, but it still feels funny to me...)
- ARC is very much a mainstay of the language. As much as I like ARC, I wonder if it should be so tied into the language. Furthermore, it seems to me that if Apple is going to do some magic under the hood (as they are doing with object copies, but only when needed, etc.), why not go a little further with that magic and eliminate the need for [unowned self]? The need for the declaration is important, but I would think the use case here is reversed -- when I want to capture self strongly, perhaps I should declare it then, and the compiler should assume a weak capture by default. Otherwise this particular class of mistake isn't going to be eliminated (unless there are warnings thrown to the user saying "are you sure you mean to capture self strongly?").
- A definite ObjC-ism is the way named parameters are handled. There's very clearly a thin veneer going on here -- and I'm not sure I like it. Especially in the declaration -- what in the world is that "#" doing there? Personally, I think this would be a common use case so that it should go the other way, but there really should be some other syntactical method of declaring what is an externally named parameter vs an internally named parameter. (Or better: do away with the distinction entirely.)
- I really don't like let vs var. I'd much prefer const vs var here. The semantics are much more clear.
Now all that sounds like I'm really down on the language -- I'm not, really! There's a lot in there to like and love, and I can't wait to actually dig in to it. Having the playground is even better and should help speed up dev time and encourage "try this out to see what it does". And there are nutty things Obj C does too, so Obj C doesn't get off the hook here either.
Of course there are aspects of it that could change -- Apple isn't promising source code compatibility until iOS 8's release (I think that one is safe to say), so don't be surprised if something breaks in the upcoming months.
As to working in iOS 7, from what I've seen elsewhere, the WWDC app itself is written in Swift. So Apple is clearly dogfooding their own product. I wonder how much else has been written in it that we don't know about. Given that this has had to take years to build (and the docs admit that), I expect much more of Apple's products are written in Swift (or have portions written in Swift) than we know.