At the Apple Worldwide Developers Conference 2019 the fruit company presented its richest Swift induced harvest so far.
Write code. Blow minds. This year’s Dub Dub did not fall short of its motto. Now, three weeks later, after the hot takes have cooled down, I quickly want to highlight some things that were seeded with a new programming language. En passant initiated by a research project that lead to LLVM, after five years of community driven evolution, Swift is real now.
Amazing, how some syntactic sugar and a type system on top of LLVM, as Chris Lattner jokingly put it on Sundell’s show, has changed Apple’s software engineering.
Declarative user interface programming
The term functional programming is broadly used these days, a definite winner in buzzword bingo. We get the drift though, less state and a declarative programming model. Functional principles can help in all domains, UI programming is no exception, with plenty of state to manage, complex composites, and disparate sources of asynchronous events. Take Elm and, to some degree, React Hooks as examples. The trend is clear, testable software wins.
React developers can relate to SwiftUI, a declarative user interface framework with a new Swift DSL and deep Xcode integration, including live previews. Most developers are excited, some not so much—closing a chapter Apple hit a nerve.
SwiftUI is a simple way to build user interfaces across all Apple platforms. It’s a stepping stone to a unified Apple developer experience. If you have been on the fence, now is a good time to start developing for Apple platforms.
WWDC marks the end of Apple’s NeXT era and the beginning of the Swift era.—Brent Simmons
Anticipated for the longest time, a live-coding environment for Xcode—beyond playgrounds.
These declarative Swift APIs are enabled by Function Builders, which allow you to create embedded domain-specific languages in Swift. Other components are Property Wrappers and the new custom view controller initializers (1, 2) in iOS 13.
I cannot wait to build something with SwiftUI. However, familiar with the intricacies of app making, I remain sceptical. It’s all in the details. There’s a reason why I have never considered React Native.
Organizing and sharing code
Since the Swift Runtime is part of the OS, not longer baked into apps, launch times get quicker, app sizes shrink, and further optimizations, like faster bridging between Swift and Objective-C, are possible. For example, transitioning from String to NSString has gotten 15% faster with Swift 5.1.
👉 Swift 5 switched string encoding from UTF-16 to UTF-8.
With ABI stability, reached with Swift 5, and module stability, added now with 5.1, distributing binary frameworks became feasible. Framework and program can be build with different compilers. Module stability added a textual interface that is available during development.
Packages are platform independent, they build for whatever the client needs. For example, you can build an iOS app and a watchOS app using the same package. Xcode builds the package accordingly. If you have ever maintained a multi-platform library, I am sure you will appreciate the implications of this.
Many common package manager practices, like semantic versioning and package locking, become a part of software development with Xcode. Of course, niceties like code completion and documentation for dependencies are available within the IDE.
Package.resolved under version control. Similar to
In the coming years we will see a flourishing open source ecosystem for Apple platforms. Teams will organize their code in smarter ways and be able to iterate much faster on their products.
Less Code. Better Code. Everywhere.
It’s great to see Swift bearing fruit. 🍒 I have not felt that inspired by Apple since the introduction of Swift itself. Fired up by the sessions, I cannot wait to get my hands dirty using these new tools, but mind you, UIKit is not going anywhere anytime soon. Did you see those UI collection updates (220, 215)? 😍