A few quick thoughts on Swift

Tagged: swift

What's this? I'm reading up on yet ANOTHER programming language?

Yeah, yeah yeah. This was a bit of a while coming. I've been wanting to rebuild Laundromat┬║ and some other midi sequencers for a while. Originally I thought it might be fun to build them with SDL and a tool like C, but a combination of different factors made me think that I should just build for iOS (although, I have mixed feelings about building in the apple ecosystem.)

For now I'm following the 100 days of swiftui course. Normally, I would jump right into trying to build a thing with a new language and learn as I go, but I think the apple ecosystem definitely warrented some extra help from outside. I'm hoping that by the time I'm done working through the course I'll have a better idea if this is the right direction, and can also use that time to asynchronously, finish building Firn2 (hopefully).

For now, I quite like Swift. It's quite similar to Rust, which I had heard people say already, and now I'm starting to see why/how. The syntax is pretty elegant actually, although there are a lot of little niche things that are either a) unique to apple development, which means I will keep forgetting about them unless I write them down or b) has interop with Objective C (more things I will likely forget in the future)

The things I like so far though:

  • not having to deal with ownership (although I'm getting used to it now with Rust)

  • Being able to build UI using a "canonical" approach.

  • More documentation than other niche langs I've been using

  • Feature wise, I like extensions and closures and how optionals are handled. Closures have lots of little tricks to them, I quite like trailing closure syntax.

  • Syntax wise, I like parameter labels, although it's going to take a while to get used to them when declaring functions.

  • Structs & Classes? Interesting. I was starting to think that Structs were all I need - and maybe they are, but it seems that Classes are required for conforming with the objective C legacy stuff (which reminds me of how Clojure interopts with Java, a bit).

Side note: I must be finally getting some stuff through to me because after reading about how Protocols work, I finally realized that "I get it" despite reading/writing them across many different langauges / code bases. Perhaps it was just Paul from hacking with swift being particularly adept at explaining them. So - that's satisfying.

So yeah! Seems like a cool language. It's a shame you can't really use it in other places (I mean, you can but you are shoe-horning it a bit) - I'd really like to feel like taking part in this ecosystem will enable me elsewhere outside of building Apple products, but it doesn't really (yet).

And one last note (if a little self-congratulatory of one) - after doing this kind of thing for 5+ years, learning a new languages isn't really a big deal. I'm starting to just see a syntax as a grammer for expressing an idea, and learning that syntax as an exercise in learning how to "speak that language". It's exciting to feel this way because I understand now that I'm looking for a way to express building a thing, and not wrestling with concepts so much anymore.