Why does Apple recommend to use structs by default?

Passing classes around has ARC overhead and from someone's perspective could also be considered as a waste of memory and CPU cycles. Additionally, what you may think of as "gigantic structs" may not be one under the hood. If you're referring to JSON objects, I'd assume such structs have strings, arrays, or dictionaries as their fields. Most of the time their storage would not be copied when passed as arguments, since those are CoW types, either living on the stack if they're small enough, or living on the heap and aren't copied until there's a need to.

The benefits of value types are enormous though. It's easier to reason about those, easier to avoid reference cycles, trivial to make to make them Sendable and/or immutable, easier to localize mutability to a certain scope when needed. If you're still concerned about some copying that you think should be avoidable, I suggest some form of participation in the evolution of the ownership model and corresponding proposals and pitches. I'm only listing a few that I'm following:

8 Likes