My Battle with Swift

Looking Back - First iPhone App

I've been doing some work at writing an application for the iPhone. I drew the entire thing up on paper, thought through the decisions, and now I'm putting it into code. I already have a backend server readily providing me with resources and a datbase where a simple schema lives. On iPhone you have Objective-C and Swift, no other options at a simple minute glance. I started down the path of writing Objective-C but that was only because I'm kind of set in my ways. So I forced myself to give Swift a try with SwiftUI as the UI providing library. What I've found is that you need to learn to read the language spec fairly immediately, not the formal grammar about implementing your own compiler but how to read the function signatures.

In the era of generative AI this is somewhat easier, I'm able to tell one of these systems what I'm looking to do and then after some sculpting get what I want. With the transition of SwiftUI from NavigationLinks to NavigationStacks though, I've found that both Bard and ChatGPT have roughness around the edges - ChatGPT doesn't even know about NavigationStacks as it doesn't have 2023 data, but Bard does. It just takes some convincing to get Bard to understand it's coding in properties that don't actually exist on the class.

I decided at this point that I'm pretty capable of reading function signatures in other languages IE Go, C....and now you might notice a big crack. I don't have any huge experience reading these specs in a heavily object-oriented language. Which I definitely consider Swift to be. If you look at Wikipedia for Swift, you might see it being stated as declarative there, but the only sense I can see for that is within the same page they make references to SwiftUI which /is/ in fact declarative. Without SwiftUI, good luck doing declarative programming in Swift.

It would be a good time to take a step back from SwiftUI, which by the way is declaratively coded rather than you writing the implementation of how you want to display the UI yourself you declare it like you might HTML or Terraform on the cloud infrastructure side. This doesn't match up exactly with Swift itself, which isn't itself declarative, but it still uses a good amount of the same types. Like closures....what the hell is a closure? Well it's a lambda...which is an anonymous function. From the Swift Programming Language Closures are self-contained blocks of functionality that can be passed around and used in your code. Closures in Swift are similar to blocks in C and Objective-C and to lambdas in other programming languages. . I think this is a very important thing to point out because while most everything that has ever written anything in a programming language before has defined a function ex: main(), there are going to be those that have no written a lambda. Having this within A Swift Tour (an overview) essentially of the language, is good, but that overview shouldn't be the 3rd thing a person sees when the are introduced to the language with the first two being About Swift and Versioning.

At this point I'm looking to read function and type signatures - so I've taken a step back from SwiftUI itself to shake down Swift the language for a bit and glean some sense from it.

I'm starting with the Language Guide - skimming around until I hit something that is new. I'm also going through the tutorials for Swift itself, like making a CLI tool, a library, and a web service. The CLI tool and web service are things that you can make a main.swift file within the terminal, add some code in vim, then run swiftc to compile. Easy enough.