When Apple announced SwiftUI about 2 years ago, I was extremely excited. I had previously used Microsoft’s WPF and Silverlight with their declarative layour markup language that resonates very well with the way I think about UIs. In the past few months, I finally had a few weekends that I could dedicate to learning SwiftUI at a high level with a simple project. As I was looking for a project to tinker with, I remembered a number’s game I used to play in middle school when I was back in Istanbul. It is a very simple game where the user tries to reach a target number in the allotted time using a set of numbers and arithmetic. I have fond memories of playing this game, so I decided to re-create it using SwiftUI on iOS. I named it SumNum. Overall, I had a pleasant experience in using SwiftUI. There are still some rough edges around XCode support (even with LivePreview) such as cryptic compiler errors, random crashes and a pretty slow compilation result. However, even with these limitations it is still infinitely better than using Interface Builder. At this point I strongly believe that all Apple UI development will be moving to SwiftUI in the coming few years. I was able to implement an MVVM pattern with simple enough dependency injection and testing in next to no time. However, the Binding/State/EnvironmentObject/ObservedObject concepts are a bit more complicated than they need to be. If you do choose to go down that path, I strongly suggest watching the following Apple Developer Session Video on Data. Animations were surprisingly easy to implement compared to other platforms I have seen. Especially the composability of each animation makes it very easy to re-use them within a given view. I used them for both the menus and gameplay with ease. While I was working on the app, I wanted to add some complex animations that went way beyond animating simple shapes. In my search of a suitable animation I came across Lottie Files by AirBnB. It has many free/low-cost animations by hundreds of animators around the world. They even provide a web/Swift based player that makes it easy to incorporate into iOS apps. I strongly suggest using them. Overall creating the basic game engine & the associated UI was extremely fast. I am very impressed with the implementation of both the Swift language and the SwiftUI framework. As the frameworks start evolving to shed Cocoa and eventually UIKit references, the experience should only get better.
When was the last time you took a week to brush up on the most basic of algorithms and your understanding of data structures? As we get into the rhythm of using our most beloved frameworks, language features and libraries sometimes we do lose touch with the most basic building blocks of computer science. ‘So what?’ You may ask. When you are designing and building software that will be used by tens of millions of people, it is important to understand the trade-offs. A more efficient algorithm can make the difference between a sub-second and 3 second response time on your mobile app or web site. Taking a few hours every quarter or six months to brush up on the most basic building blocks such as DFS, BFS, sorting and checksum algorithms, hash tables, binary trees and tries can help us look at day to day challenges under a new light and come up with alternative solutions. Can you fit 3 hours of brush-up time into your schedule next quarter?