
80: “Lists and loops”, with special guest Nick Lockwood
Swift by Sundell
Swift's Copy on write : A Foot Gun
Swift's type system uses copy on right for value types that need to be mutable. Arrays and strings cannot be fixed size because they need to be mutable, so the value cannot live on the stack. Instead, it allocates an array on the heap and stores a pointer to it in the struct. When you change the array through the struct, it checks for any other references and makes a copy of the whole array if there are any. This can lead to inefficient performance in multi-threaded applications.
00:00
Transcript
Play full episode
Remember Everything You Learn from Podcasts
Save insights instantly, chat with episodes, and build lasting knowledge - all powered by AI.