3 ms·
I don't see how Swift is similar to Rust -- it's a garbage collected, OO language, not really appropriate for low level / systems level programming. It's a nice
by cmrdporcupine 7y ago
I don't see how Swift is similar to Rust -- it's a garbage collected, OO language, not really appropriate for low level / systems level programming. It's a nice looking language for what it is, with some nicer modern features in its type system etc, but its niche is not the same as Rust.
- throwaway894345 7y ago> it's a garbage collected, OO language, not really appropriate for low level / systems level programming I'm of the impression that Swift is reference counted, which, while technically a kind of GC, is also appropriate for low level / systems programming (which isn't to say that Swift is a good language for low level / systems programming; only that its memory management isn't the disqualifying factor).
- cmrdporcupine 7y agoI wouldn't consider reference counted GC systems level appropriate. It _can_ be more deterministic, but not when it's tracing and collecting cycles (which a decent modern RC implementation must do) and it usually plays havoc on L1 cache (by touching counts). You can make RC quite nice (I've written cycle collecting implementations before) but there's reasons why C++ programmers are encouraged generally to avoid shared_ptr and use unique_ptr whenever possible: harder to reason about or trace object lifetimes, and performance implications. Now if the garbage collection was optional, and one could still freely heap or stack allocate and free, then, yes, I could see it. But I don't think that's the case w/ Swift, at least not last time I looked at it. It's also why Go is imho not a 'systems' programming language.
- ken 7y ago> I wouldn't consider reference counted GC systems level appropriate. It _can_ be more deterministic, but not when it's tracing and collecting cycles (which a decent modern RC implementation must do) Swift has what you would call an ‘indecent’ RC design, then, because it doesn’t. > and it usually plays havoc on L1 cache (by touching counts). Swift (like Objective-C) can store the refcounts either inline or in supplementary structures, for performance. > Now if the garbage collection was optional In the common case, it practically is, as (most) value types will only ever live on the stack, or inline in another data structure.
- cmrdporcupine 7y agoimho inline will still mess with cache somewhat as adding a reference count still often requires bringing something into cache or evicting something from cache that wouldn't happen with a pure pointer reference. Glad to hear that value types are optimized well.
- pjmlp 7y agoIt is for Apple, where the long term roadmap is for Swift to become the systems programming languages of their platforms.