/_next/static/media/placeholder-social.f0796e1f.png
blog
Swift and room for improvement

Tue, May 3, 2016

Authors
Mauro de Carvalho
Mauro de Carvalho
Share

It’s been roughly two years since Swift appeared, and it’s certainly had its impact, especially in the iOS development ecosystem. However the language still has some room for improvement. In this blog post I will talk about some of the improvements I’d like to see in the future.

Features

Swift is constantly evolving and features are still being added and removed from the language. Unless maintaining source compatibility is a must have for you, an evolving language is pretty much always a good thing as improvements are always welcome. However, when it comes to programming languages I tend to think that less is more. I’m not saying Swift has useless features, it doesn’t, but for various reasons I tend to favor smaller, simpler languages to feature-rich ones. These include:

  • A simpler compiler means that it will probably be easier to develop and less prone to errors (and don’t tell me the Swift compiler hasn’t crashed for you).
  • It’s easier to introduce people to the language and to projects.
  • Unless you follow a strict style guide (see for example id Software's C++ Coding Style Conventions) things can get messy on long projects with a big team.

Cross Platform development

I think we were all happy when Apple open sourced Swift, as it opened the doors, among other things, to cross platform development. Notwithstanding, this is still a work in progress and will not be available until Swift 3.0. Moreover, the Swift Standard Library is actually pretty small, providing only core functionality (which isn’t necessarily a bad thing), but it means that Foundation is usually needed. Unfortunately, while there are efforts to implement Foundation in other operating systems (like Apple’s own implementation or SwiftFoundation) they are not ready yet. Using Foundation also means dealing with all those NS prefixes.

The ecosystem

The iOS/OS X development ecosystem also changed a lot when Swift was introduced. In general changes were for the better, like not having to use Objective-C for development, but there were some regressions too.

Xcode

If you’re doing iOS or OS X development there’s no getting away from Xcode. Let’s be honest and admit that Xcode was never a top tier IDE, however, with Swift, stuff like refactoring does not work at all. The refactoring options in Xcode are not that great either, but at least they used to work. Regressions are not fun, no matter how small.

Breakage

As I’ve mentioned before, I’ve had the compiler segfault on me several times, forcing me to change my code to something else.

"Legacy" APIs

iOS APIs have not been redesigned to take advantage of what Swift offers. This isn’t bad per-se, but it is just a wasted opportunity to improve things. Things like delegates have to be used when a closure would probably suffice. At least with Swift 2.2 #selector() was introduced which is a bit better than just passing Strings.

Conclusion

Swift is far from perfect, but it’s constantly evolving and improving. Even with it’s drawbacks, it’s lightyears ahead of Objective-C. Only time can tell where Swift will be in a few years from now, but I am certain that the future is bright and that it will only get better.

Wondering how AI can help you?