Last updated: 10 days ago
The difference between value type and reference type is key to know when you should create a class, a struct or an enum.
But what does it mean for the memory management?
Passing values around instead of pointers, is great for immutability and limiting side effects, but it comes at a cost : calling a function with a value type parameter means that we are passing a copy of the argument, which might take some time to create.
Also there is something really weird when you think about it :
Array are value types in swift, but how does swift manage a struct that has a potential infinite number of elements. That is where copy on write comes along. (COW 🐮)
COW is a great tool, but it can lead to some performance issues. To mitigate them, a new
modify keyword has yet to be released in a future version of Swift.
This talk aims at introducing progressively concepts and problematics related to COW, in order to make it accessible even to those that are new to Swift.
I do believe this is a really interesting topic and that it is important to cover it because the pitfall of COW is not going to magically fix itself with the appearance of a new keyword, developers will need to know what is under the hood and when they should or should not worry about this performance issues, and how they can fix it.
This a technical talk which is rich in content so it should last at least 40 minutes.