Post #2387923
2026-02-25 05:34 UTC
There are some things about Swift that I still haven't gotten over, however.
I dislike the distinction between function argument labels and parameter names. In essence it lets you have two different names for a function argument: a user-facing name and an internal function body name. This feature infiltrates the syntax of Swift, and makes function definitions more difficult to read in my eyes.
Additionally, the concept of a "mutating method" seems very tacked-on to me. By marking a structure's method as `mutating`, you enable it to modify the properties of the structure instance. This feels like something that was almost added as an afterthought; it feels like there was a bit of influence from Rust here, although I don't know if that's actually the case. Either way, it feels like a weird spot of the language that doesn't *quite* fit with the rest.
And finally, trying Swift has given me a new appreciation for Rust's fantastic error messages. Writing Swift in Xcode as a beginner, I found it a lot harder to debug compiler errors because:
- Error have a line number, but not column range, so it is harder to diagnose what section of a line is causing the issue.
- Errors do not link to documentation nor have a stable error code that I can Google. Having an example of what causes the error and how to fix it is super valuable!
Don't get me wrong, Swift is still a nice language to work with! I certainly prefer it over Objective-C and C++, and SwiftUI's composability has worked wonders in code organization, but it certainly has made me appreciate things I take for granted in the Rust ecosystem.
#swift #rust
Replies (0)
No replies.