Hacker News new | ask | show | jobs
by antonhag 1081 days ago
It is quite common that you only need to optimize very small parts of a program to this level. The rest of the program can be written in more conventional styles.

You could of course FFI into e.g. C for those parts, but that is usually harder to maintain than a few well optimized java classes.

2 comments

> It is quite common that you only need to optimize very small parts of a program to this level.

It's a quite common myth developers believe about performance. Hotspots do happen sometimes, but once they have been optimized you quicky end up with a flat profile and an "everything is slow" problem. And in some types of apps, the majority of code is performance critical.

It depends - even when you run into an "everything is slow" problem, it might be that it's like 1 endpoint out of 2000 that causes performance issues. In this case, you might need to focus very much on performance for that endpoint, but maybe not for other endpoints. Profilers can help you figure out what code to focus on.

If the majority of code is performance critical, the tradeoffs are of course different.

Nah, "everything is slow" is vanishingly rare in practice.
Depends on the application. In area of compilers, databases, CAD, game engines, simulation, distributed analytics, machine learning the only code that isn't on the critical path is some configuration / control plane / UI - which is minority of the code.
Certainly not in the entirety of those areas. I've worked in a couple of them and functionality was a higher priority than performance and we picked our tools accordingly.
The cases you’re talking about are the rare ones. Source: I did this professionally and now recreationally.
> You could of course FFI into e.g. C for those parts, but that is usually harder to maintain than a few well optimized java classes.

Hopefully Foreign Function & Memory API [0] makes FFI so much easier that we get to drop down to C without much fuss.

[0] https://openjdk.org/jeps/442