Just shy of two weeks ago, Apple announced their new programming language Swift at WWDC. Apple stated that Swift was Objective-C without the C, and presented it as where things are moving. It is a very exciting time for Apple developers in general, and this new language is just the tip of things. So of course, I dove right in!
I’ll state right off the bat that I have mixed feelings about Swift. As I1 quipped on Twitter, it’s not just Objective-C without the C, it’s Objective-C without the Objective-C2. The language makes a number of tradeoffs that I feel are questionable. It involves concepts that sound great on paper, but in practice likely won’t work out (how many programmers do you think will actually bother to properly check optionals before !‘ing them? I will, and I know you will, but what about Bob down the hall?).
That said, there is a lot to like about the language, and a lot to be excited about. Pointers are hidden away so we don’t have to type the asterisks anymore. Enumerations in Swift are a vast improvement over anything offered by the C family of languages. Tuples are first class members of the language (of course they will be abused to return errors along with results, but you have to take the good with the bad).
Unfortunately my current day job doesn’t involve Objective-C or Swift, so I’ve only had the opportunity to use it on the evenings and weekends. Still, this has been enough time to completely convert a new project that I recently started from Objective-C to Swift. In the process I came across a number of issues with the language to report to Apple, which I’ve listed below in no particular order:
- First class support for introspection (rdar://17301920) (Closed, duplicate of rdar://17177549)
- Parse issues with assignment operators (rdar://17301831) (Turns out this is by design, but they did request my feedback. I suggested whitespace should only be used to break ties when there is ambiguity. The issue is still open.)
- Disallow operator overloading outside of system libraries (rdar://17304784) (Closed, no surprise)
- Get rid of the … operator (rdar://17307454)
- Constant Arrays should be immutable (rdar://17301730) (Closed, duplicate of rdar://17192555)
- Objective-C methods with varargs are not exposed to Swift (rdar://17302764) (Closed, duplicate of rdar://15935999)
- Protocol adoption syntax is horrible and potentially confusing (rdar://17302943)
- Please reconsider the message passing syntax (rdar://17305912) (Closed, no surprise)
- Either require semicolons or don’t (rdar://17301982)
- C-style static string concatenation is unsupported (rdar://17302399) (Closed, they like it this way)
- Use dynamic dispatch by default (rdar://17306182) (Closed, no surprise)
I also have a handful more that I am still digesting a bit before reporting them.
If you look through those, it’s very apparent that I have some strong disagreements with many of the decisions made in the design of the language. Most of them are unlikely to be addressed in a way which satisfies me, but that’s ok. I reported the issues because I like the idea of Swift and the initiative Apple is taking by introducing it, and I want it to be better. And while Apple is busy either fixing or discarding my issues, I will do what I always do: program in whatever language seems best suited to the task at hand, be that Objective-C, Swift, or something else.