And a few paragraphs later:
extension Array {
func sorted(
by keyPath: KeyPath
) -> Self {
sorted { $0[keyPath: keyPath]
I can't say this is lightweight any longer.My greatest gripe with Swift comes not from Swift itself but from its standard library. When most new languages start with their own standard libraries that are usually interfaces towards C APIs or POSIX, Swift's Foundation is half of MacOS and then some.
I recently needed to read some data from a file in Swift, and it took me quite some time to realise there was no fopen equivalent. Read/write files is a function on String? And getting a file handle is an excercise in figuring out proper dir names and user enums? [1]
There are a few other weird things in the language itself like guards which IMO are an entirely unnecessary construct that can be as easily solved with regular ifs. Or Optionals that have no way of working with them except unwrapping them (either with ! or via guards).
SwiftUI, however, is a very interesting approach, and I hope there are more frameworks (especially UI frameworks) like this.