Decentralized Package Management

One thing that has always given me a more favourable view of Swift is how Apple choose to go about handling package management from the very beginning. Similar to Go, the majority of packages are referenced using Git repositories. Swift differs in that you usually have to specify a snapshotted version using the tag feature instead of pulling everything from a certain branch. Not that you can’t do that, don’t get me wrong, it’s just not recommended in production.

While this method is not without its drawbacks, it does eliminate a lot of security concerns. Plenty of my toy Rust and .NET applications had relied on dependent bot to frequently update varies dependencies. Swift takes this approach a step further by having a minimum version baseline. You can really fine-tone this by simply updating every minor patch or major release. 

Really the biggest drawback is that you are building a lot of external dependencies all at once. Sure it removes DLL hell but it does increase the build time and processing resources by quite a bit. Trade offs. It’s essentially bad with languages like Rust because it exists in such weird middle ground between bare bones and having a feature complete standard library. Like, I had to write an extension for a time and date library just so I can get basic support for printing ISO weeks that I could use for my little toy program that was inspired by Tom Scott. I just created DLC for DLC just so my silly little program worked. Like, WTF!? Luckily, Swift isn’t that bad since Foundation is built into the language, regardless of the platform you’re on, and you know they’re going to optimize the shit out of it for experience. But I digress. xD

All that being said, this is how it’s always been done. Many C/C++ programs bundle libraries needed to successfully build their project. It’s basically why many of their classic projects have such big and monolithic repositories. When Git came along, plenty of new projects pulled from submodules instead. Even older .NET applications did this before NuGet came along. Modern programming languages, such as Go and Swift, just adopted a form of this submodule practice by baking it into the package manager and having those be referenced from a cache instead.

Really the biggest benefit is decentralization. Even if Apple attempted to were throw a wrench into the ecosystem, they’d likely miss. The majority of that ecosystem is just open source Git repositories that anyone fork. This is also means that you’re not limited to a central repository or host. Like, there is this one library I discovered a few days ago in the Swift Package Index they recently moved from GitHub to their own personal Git and it still functions all the same.

Compare this something like .NET, where everything is centralized on NuGet. While this isn’t necessarily a bad thing and it has certainly help evaluate the platform, Microsoft really has their grip on the wheel. All their recent .NET talks is just about AI this and AI that. Meanwhile, Apple is over here creating new open source libraries and features. Like the recent @c annotation that exports functions as C headers or their new Configuration library. I love the .NET guys. I really do. The two Scotts are my favourite. I just hate the leadership. (Not that Apple is any better.)