Mar 14 2006

Incompressible Java, PI day

Published by at 7:39 pm under Technology   

Weiqi Gao reminded me that today is “PI Day”; that along wouldn’t warrant a post here, but the Java snippet for estimating the value of PI rather inefficiently, did:

The inefficiency of the PI estimate didn’t bother me – rather it was the inefficiency of the text of the program. This is a a good example of the “incompressibility” of Java; there are a lot of words and symbols in there. Contrast that with a bit of Ruby:

ruby -e “print (1..64000).inject(0.0) { | sum, i | sum + 6.0 / (i*i) } ** 0.5”

3.141577732895

The difference in the answer is from the different underying floating point data types. The textual difference is easy to talk your way around for a small program like this. But we’ve found that as our applications grow, the amount of Java code grows at a frightening rate compared to the functionality therein. We work around that with great tools (Eclipse, IDEA), and accept it as a trade off to the strong library support and abundance of developers. But the language itself…

If you found this post useful, please link to it from your web site, mention it online, or mention it to a colleague.

No responses yet

Comments are closed.