For the last 5 months, I have been working on an iOS project using Swift. Its been an interesting experience. While the language has some parts I like, personally I feel mostly disappointed at the complexity of the language cause, honestly, I don’t see how they help me write apps faster.
My Hopes for Swift
But between a js-like syntax and an interactive playful workspace, I thought Apple had finally cracked it and democratized programming. On the flight back, I was so sure that Swift would be the programming language that I would now recommend to students going forward.
Working with Swift
Working in Swift the last few months, my opinion has changed a lot. The simplicity that (I thought) Swift promised never really happened and I find the language a lot more laborious to work with than even Objective-C which I generally liked.
- Optionals?: Swift introduced Optionals that let you explicitly declare that certain variables may not hold data at all times. I am not sure what kind of bugs this is helping me avoid. And I am tired of unwrapping Optionals all over my code. Additionally, Optionals introduce a whole new slew of potential errors.
- Type casting in Swift sucks. Swift does nothing automatically. Want to add an Int to a CGFloat? Well make sure the you convert your Int to a CGFloat yourself. This gets very annoying when you want to do things like manipulate view dimensions by multiplying with and adding/subtracting constants. I have reached a point where I only do one simple math operation per line.
- Unexpected types: Why the hell does array[1..10] return a Splice object that you have to cast to an Array?! If I am asking for a part of a collection, just return it as the same data type.
- Way too much: There is a lot of smart in Swift, and I am sure it attracts a certain kind of personality. Operator Overloading, Literal Convertables, etc etc. But personally I find very little of that really valuable.
- Readability: Personally I ding a programming language for every meta character in code (?, ! etc) as I think they generally hamper readability. Swift has a lot of that.
- XCode 6 is terrible: XCode has gotten really bad. SourceKit editor crashes all the time, errors make no sense, quick fixes don’t actually fix (video below). Its surprising how poor XCode stands up to other modern IDEs.
Swift has some nice parts too. Playgrounds/REPL are actually useful to debug small pieces of code and the lack of header files is a blessing, but besides that, I am not too excited by it. To me Swift is a disappointment, something I had hoped would open mobile development to a larger pool of people just getting into programming. Instead its another language that seems to have been developed by very smart people for very smart people. Nothing wrong with that, its just not what gets me excited.
I mostly agree with Marco on this when he said:
Swift looks interesting, but in all of Overcast’s development so far, I’ve never run into a problem that’s the language’s fault that Swift would have handled better. It appears to solve problems I don’t have, to gain small (and still theoretical) optimizations that I don’t need, at the expense of many Objective-C features I really like.