• einpoklum 10 hours ago |
    This is the 12th part of a series of posts introducing the Swift language to C++ developers:

    https://www.douggregor.net/posts/

    I wouldn't recommend starting from the 12th part, it probably makes sense to read the posts in order.

  • DidYaWipe 6 hours ago |
    I generally like Swift, but one aspect that strikes me as amateurish and arbitrary is that structs are passed by copy, while classes are by reference. There's no visible syntactic notation to tell you what's happening. You have to examine the definition of the class or struct.

    Swift programmers are urged to choose structs for their data by default, which breaks Apple's evangelized "single source of truth" in their "reactive" SwiftUI paradigm. You can't have a single source of truth when everything's being copied all over the place, as it is with structs. And SwiftUI's observation framework only (kind of) works with structs and primitives, not classes.

    So the entire thing is a contradictory mess that makes programming on Apple platforms a joyless slog and a nightmare to test. Your entire app becomes a pile of contrived states and flags that you tweak to trick the UI into doing what you want.

    So the question is: Are we to abandon the "use structs whenever possible" mantra in Swift?

  • needlesslygrim 5 hours ago |
    This is interesting because these semantics seems to be a direct(ish) clone of Rust's. I wonder if this moves Swift's performance ceiling closer to Rust's?