Java "trick"? - Using an obfuscator to compact source code in mobile apps
I'm reading APress' book on embedded Java development, "Beginning J2ME - From Novice to Professional", which I'm thoroughly enjoying (review forthcoming). In the book's second chapter, authors Sing Li and Jonathan Knudsen discuss the importance of compacting source code for a MIDlet-based mobile application to ensure efficient program execution. One of the tips they recommend for doing so is to use an obfuscator to rename classes, data members, and methods - and in so doing reducing the total amount of code to be interpreted, compiled, and ultimately executed within the JAR. This leads to better performance.
This is something I've not thought about before. In my work with smart client development using .NET, I've been taught to use such tools to protect code, shielding it from reverse-engineering encounters. Further, I've heard of people obfuscating their source code to intentionally screw-up decompilers. But even in my research into MMIT and the .NET Compact Framework, I'd not heard of this being mentioned before. Maybe .NET's just that good that this isn't so much of a concern, and/or maybe Java's got memory leak/consumption tendencies. Depends whom you ask, I guess.
Although the RAM/ROM occupancy concerns would obviously be much less for an app running on the desktop, the same concept surely can be applicable in non-mobile environments. This is a neat little trick I hadn't considered, so I'm shelving it in Ye Olde Mental Rolodex for future use.