News for hackers. Stuff that matters.
Re:Java is very fast, if you don’t create many objects by ben7799 on Monday September 12, 2022 @10:00AM (#32810375)
There's good advice there but you definitely need to not go crazy and get into premature optimization land.

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.

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.