Anytime I open up the code editor in Visual Studio, there is always an empty new line at the end of generated codes. I usually delete them since they seem irrelevant to me. However, recently I read code at Github which said:
\ No newline at end of file
This was the last line. Now I'm thinking those empty new lines at the end of source codes do have some relevance. But what do they mean? Do they provide any performance boost?
Two things make me prefer having a newline at the end of files:
Pretty much the only difference it makes is that if you have a file with no newline - like this:
blah\n
bleh (no newline)
When you modify it to be:
blah\n
bleh\n
foo (no newline)
Then according to the diff, you modified 2 lines - one with content, the other one with newline... which is not what you wanted probably. Then again, in reality it doesn't matter that much which way you choose. If you include newlines, your diffs will be a little bit cleaner.
It also makes difference for some preprocessors as mentioned in other answer - but that depends on what language you use.
Of course it makes no performance difference at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With