• Post Reply Bookmark Topic Watch Topic
  • New Topic

white spaces and CPU time  RSS feed

 
Rahul Ashar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does white spaces and comments are expensive in terms of CPU time while compiling java code into byte code

Does it matters to JVM taking CPU time if there is any white spaces or comment.

(I am aware that white spaces or comment are not considered while execution of byte code)
 
Campbell Ritchie
Marshal
Posts: 56598
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Comments and whitespace are eliminated from the code at a very early stage of parsing, so I am sure they have very little effect on compilation time. Since they don't appear in the bytecode, they have no effect on execution speed.

But they are very valuable for maintaining and reading code, so make sure to keep them in.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
agreed. any time lost in the compiling phase (which would be trivial in any case) is MORE than made up for in maintenance of the code. Which can you read faster:


or
 
Rahul Ashar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much for your help

I do apologies for not asking the query in a bit formal way

Rahul
 
Campbell Ritchie
Marshal
Posts: 56598
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
I can see nothing wrong with your question style
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!