|
|
|
|
|
by astrange
1254 days ago
|
|
This largely depends on how much of Swift<>ObjC bridging you'll hit, as such it'll get faster if more of Foundation is converted to Swift. In particular Swift is more memory efficient than ObjC because there's less boxing overhead to small values. That should matter more than the overhead from more overflow checking. |
|
This is another commonly held belief that doesn't hold up to actual measurements.
For an example, see part 2: https://blog.metaobject.com/2020/04/somewhat-less-lethargic-...
All the pure Swift implementations are even slower than the bridged ones, and the bridged ones are slower than the most comically inefficient Objective-C one (using KVC, for example), which is slower than the reasonable Objective-C ones.
> In particular Swift is more memory efficient than ObjC ...
It's not.
> ... because there's less boxing overhead to small values
You would think, yes. I actually did think that as well. Because it really sounds plausible. So imagine my surprise when I measured some common cases for my book (Chapter 9) and it turned that even in the cases where I just knew™ that Swift would be faster, because of this very reason, it just wasn't.
> That should matter more than the overhead from more overflow checking.
Computers don't care what you think "should" be the case, and they cannot be argued into better performance due to plausible arguments and strongly held beliefs.
You need to measure what actually is the case.