4 ms·
> - Message passing in ObjC is so optimized that it probably can't get much faster, and anyone acting like it's slow has a potentially skewed understanding of t
by jchb 7y ago
> - Message passing in ObjC is so optimized that it probably can't get much faster, and anyone acting like it's slow has a potentially skewed understanding of this
The problem with Objc message passing is not the absolute execution time involved in passing a message.
The problem is that the dynamism involved completely disables the compiler from performing any code-inlining.
Typically inlining small functions is what enables the compiler to unlock further optimisations. From simple things such as merging duplicate loads from same address, to auto-vectorization.
- coliveira 7y agoIf you need this level of optimization you can always use pure C functions, which is exactly why Objective-C was created as a C extension.
- Klonoar 7y agoConsider the following: the smoothest UI/UX platform of the past decade has been iOS, which was pretty much built on ObjC. These types of speedups just aren't necessary in that world. You'd drop to C or C++ if you needed it, which is trading convenience for complexity. You could want it to be faster, but it's not going to materially show itself in common workloads.
- kccqzy 7y agoIf you want inlining don't use message passing. Just define your function as if you were writing C. Simple. Use message passing when you need the dynamism.