Hacker News new | ask | show | jobs
by jchb 2460 days 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.

3 comments

Consider 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.

If 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.
If 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.