News for hackers. Stuff that matters.
Re:How Swift Achieved Dynamic Linking Where Rust Couldn't by mojuba on Saturday November 09, 2019 @12:05PM (#21492668)
Yes, with all that in mind the complexity I see in the generated code still far exceeds my intuitive expectations. Of course I'll end up removing protocols from critical parts of my code, but like I said in the other comments, then what's the point of writing those parts in Swift? Protocols are the core part of the language, they are offered as a substitute for multiple inheritance and even for e.g. enforcing abstract methods (no other idiomatic way in Swift), they are elegant and look cheap except they are not!
Re:How Swift Achieved Dynamic Linking Where Rust Couldn't by NobodyNada on Saturday November 09, 2019 @03:38PM (#21494198)
The really expensive part here is not the use of a protocol, it’s the downcast (which isn’t really idiomatic Swift). Static dispatch is always faster than dynamic dispatch/polymorphism, but protocols are usually reasonably efficient (even more so if you can use generics instead of existentials).