Hacker News new | ask | show | jobs
by mpweiher 3340 days ago
> you don't need speculative optimisations to make something like Objective C fast.

There is a difference between "make X fast" and "write fast code in X", a distinction that is hugely important in practice.

So no, I don't need speculative optimization to write fast code in Objectice-C, but I would need speculative optimization to make Objective-C code fast [without touching the Objective-C source code].

> But you say to do that you don't use the dynamic features where you need performance

No, I did not say that at all. I said I mix dynamic features and non-dynamic features where necessary, and that I need both to make things fast. And (more importantly), that the most important optimizations have nothing to do with either (which counters the assertion that inlining is "the mother of all optimizations").

> So yes you don't need speculative optimisations... as long as you apply similar optimisations manually in the source code yourself.

The point being that (a) those optimizations are such a small part of the overall optimization process, which in turn is applied to such a tiny part of the overall code-base, that automation is not needed. Which invalidates the assertion that these optimizations are "necessary". Nice to have? Yes. Necessary? No.

The other point (b) is that optimizations by the compiler/JIT aren't as good as those applied manually for many reasons, one being that the compiler/JIT has to make the transformations indistinguishable at a fairly low-level, whereas the author has a higher-level overview and can adjust the semantics to fit. So doing it manually is also worth it.

The third point is that I cannot rely on the compiler/JIT making those optimizations, there is no guarantee that they will be applied. And with today's performance landscape being what it is, reliability is paramount, meaning that being able to guarantee even a slightly higher bound is more important than meeting a lower bound some of the time or even on average.

> I'm not convinced therefore :)

As long as I am capable of applying those optimizations manually, I have made my original point which is that having these optimizations done automatically is not necessary for performance, but at best "nice to have". Which doesn't mean that more compiler support wouldn't be nice, the process in Objective-C is too ad-hoc.