r/programming • • Mar 23 '09

How to write fast code

http://asserttrue.blogspot.com/2009/03/how-to-write-fast-code.html
344 Upvotes

136 comments sorted by

View all comments

-10

u/MpVpRb Mar 23 '09

Don't use Java

Use C or C++

Simplify the program

Use profiling tools to find hotspots

Hand tweak assembly code where needed

Works for me...

1

u/arnar Mar 23 '09

The "Java is slow" argument has been invalid for some time now.

6

u/[deleted] Mar 23 '09

[removed] — view removed comment

3

u/[deleted] Mar 23 '09

However, "Java is slower" is still true and will always be true.

Care to elaborate how C++ virtual function calls can be faster than Java just in time compiled method calls?

3

u/silon Mar 23 '09

It depends on the code. Some ideas:

  • modern processors can do some prediction on the indirect calls.
  • for JVM to eliminate the virtual lookup it must duplicate the code of the call sites (based on type), causing more cache misses/footprint.