sotto.org

Write Dumb Code

From an “interview”:http://java.sun.com/developer/technicalArticles/Interviews/goetz_qa.html with Brian Goetz of Sun:

Q. So how can developers write Java code that performs well?

A. The answer may seem counterintuitive. Often, the way to write fast code in Java applications is to write dumb code — code that is straightforward, clean, and follows the most obvious object-oriented principles. This has to do with the nature of dynamic compilers, which are big pattern-matching engines. Because compilers are written by humans who have schedules and time budgets, the compiler developers focus their efforts on the most common code patterns, because that’s where they get the most leverage. So if you write code using straightforward object-oriented principles, you’ll get better compiler optimization than if you write gnarly, hacked-up, bit-banging code that looks really clever but that the compiler can’t optimize effectively.

Sunday, March 4th, 2007 at 12:20 pm