Solved

Optimize Code By Commenting Out Blank Lines?

Posted on 2004-08-18
3
173 Views
Last Modified: 2010-04-23
Someone told me that commenting out blank lines in VB.NET code improves efficiency because the compiler does not have to evaluate the blank lines. For example:

MessageBox.Show("Hello world!")
'
'
'
MessageBox.Show("I commented out the blank lines.")

This sounds ridiculous to me. Blank lines in code should be ignored by the compiler -- whether or not it is commented out. Am I right?

Is there (or was there ever) a language where commenting out blank lines made a difference?
0
Comment
Question by:dbnewbie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 11

Expert Comment

by:saleek
ID: 11839766
Hi,

It may do with compilers from other languages, but it certainly isnt the case with .net.

regards,

KS
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 50 total points
ID: 11842317
I have never saw this anywhere before.

I would say that either commented lines or empty lines are skipped the same way by the compiler so it won't change anything at compile time.

Without having tested it, I am sure that the resulting EXE or DLL will be the same.

The real test would be to generate to EXEs (one with blank lines commented out and one without) and check the file with ILDASM.
0
 

Author Comment

by:dbnewbie
ID: 11857829
I used ILDASM and noticed no difference. Thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.net and sql server 4 55
VB.NET 2008 Winforms Signing 13 42
Vb.net progressbar with timer1 in visual studio win app 11 38
Stop Git from being my repository 1 27
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question