Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Blank Lines and performance impact  RSS feed

 
Anirudh Vyas
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any negative impact on performance in compilation when i leave blank lines? for example :
if(someCondition){

//blank line here
}else if(someCondition){

// blank line here
}else{

// blank line here
}

Regards
Vyas, Anirudh
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Clearly if you leave blank lines there are a few extra characters to be parsed by the compiler, which also makes your files a few bytes larger per line. However, usually performance of compilation is not an issue since, especially with Java, it's a one-off operation - even if you had to leave it to compile overnight (which would be extremely unusual) that shouldn't be an issue. What is usually more important is the runtime performance of the resulting program and how this scales to the size of the input (e.g. an array/matrix size or a number of client HTTP requests) - and since extraneous whitespace will be skipped over by the compiler when translating into bytecode, empty lines aren't going to matter.

This is a case where it's far more important to make your code readable and maintainable. If that means putting in or taking out lines, then so be it.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anirudh,
I'd also like to add that any difference in the compile time length is going to be tiny. Not something to worry about!
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On modern-day computers, the compiler can pass over many, many lines of whitespace in the period of time it takes angry co-workers to beat you to a pulp because they can't read your code.

Actually, long, long ago, I spent a little time working with a "training" computer system (back before microprocessors). It used a very small rotating drum storage, but primarily operated off of paper tape and was programmed in an assembly language. You could always tell when a section of paper tape contained comments, because the tape reader started running faster as the machine skipped over the parts of the program that didn't have to be parsed.

But these days, you can ignore a whole lot of text in a microsecond.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!