Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Performance  RSS feed

 
Balaji Saranathan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Just out of curiosity....
Does having a very long method names..I mean really long like
checkIfThisOperationIsPermittedForThisUser() brings in performance issue or unwanted destructive issues with JVM.
Any suggestions are welcome.
Thanks
Bala
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Balaji,
I can't say with any certainty about this but I'll take a wild guess. Since Java is an interpreted language the longer identifier names will probably have a slight impact. The modern JIT compilers probably make the impact even less.
Now if you use a lot of reflection or introspection in your program it may impact it a little more. But all in all I don't think it's going to make a whole lot of difference.
Michael Morris
SCJP
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Balaji Saranathan:
Does having a very long method names..I mean really long like
checkIfThisOperationIsPermittedForThisUser() brings in performance issue or unwanted destructive issues with JVM.

Am not sure about performance. probably our productivity :-) i think java is a little on the *verbose* side.
The biggest problem is since there is a compile-execute step. Even if we miss out a letter, say a "I" in the method name , compile and then it will report an error and so on.
 
Mark Herschberg
Sheriff
Posts: 6037
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Based on my, moderate knowledge, Michael's comments are generally correct. The byte code does contain the names, as put in the Java code. I believe, longer names do take slightly longer to resolve. It also has a very real effect on (byte) code size.
If the byte code size is an issue, you can use an obfuscator. Obfuscators are really made for hiding code. That is, the bytecode contains all your class, method, and field names. It can easily be decompiled, back to nearly the original code, sans comments. Well named objects can (and should) give good clues as to how the code works.
Obfuscators basically rename the classes and methods and fields. Generally it picks short names, e.g. a, b, aa, ab... This makes it hard to understand when decompiled. It also can reduce code size from 30-70% (according to DashO, anyway, although I've gotten good gains myself).
Obfuscators also do speed up code. However, I'm not sure how much of this is from shorter names. They also do clever things like finalize non-overridden methods.

A final word of advice, I would never recommend choosing shorter names for the purpose of speed, becase the gains are near zero. on the other hand, it's code maintenance which is costly, and should be minimized by good class, method, and field names.

--Mark
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Balaji Saranathan:
Hi,
Just out of curiosity....
Does having a very long method names..I mean really long like
checkIfThisOperationIsPermittedForThisUser() brings in performance issue or unwanted destructive issues with JVM.
Any suggestions are welcome.
Thanks
Bala


Keep using those long names! That's a fantastic name for a method. If I were a developer that had to maintain your code, I would have a very good idea what that method does just by the name, and this is a good thing.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
As we say down hyere in Texas "Rob really hit the nail on the head." When I started in this business back in the '70's we were encouraged to to make descriptors as short as possible due to limited storage, the first machine I programmed on had 8K of core which is the equivalent of RAM, now that we are getting close to "storage nirvana" I say let everyone know what your method does and what your variable contains.
Michael Morris
SCJP2
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!