Live data from Hacker News

Ask HN: Should source files always end in a new line?

news.ycombinator.com

11–20 of 40 posts

Re: Ask HN: Should source files always end in a new line?

#12
I was thinking a while ago about formatting restrictions that could make sense in a language (programming, markup, whatever) to simplify things (… and which would surely also annoy some users, but what’s life without fun?). Things like requiring tabs (partly because in a vacuum they’re simply better than spaces, and partly to protest against YAML which goes the other way), and banning carriage returns (how much trouble has supporting both ␍␊ and ␊ caused, I wonder? It’s not a little). Requiring EOL at EOF was also one I thought of.

Re: Ask HN: Should source files always end in a new line?

#14
post #8

The only difference I can think of is when appending to a file. Starting with an empty file you’re on a new line. But if you don’t end every line with a newline character then your next line will end up on the same line in the file as the last one.

Only reason I do it is because if you're adding onto a file, git will say the (prior) last line is modified because you have added the newline to it. But it's not a really big deal, I don't enforce it with any linter/CI. It's just 0.01% annoying to see a 20 line commit say 21 lines changed.
Post reply on HN