Re:Java is very fast, if you don’t create many objects
by peter_lawrey on Thursday September 15, 2022 @12:01AM
(#32846855)
Mutable objects have their own issues, which can catch people out by surprise. Having good test coverage is important.
If you've got a tight section of critical code like he does this is a good technique, however reuse of the same objects through the critical section implies:
- Mutable objects
- Harder to verify correctness
- Need to be very careful to avoid some very very serious bugs and security issues.
E.x. in his HFT example. Improper reuse of an object without correctly resetting/setting all the fields could create bugs as serious as executing a trade against the wrong user or leaking data between users.
None of this is really rocket science or java-specific. It's all basic old school optimization & computer science.