I see a lot of people saying things such as
Nice work, Nick
Or
Thanks, Mat
Is the comma really needed? I'm not 100% sure because my spelling and grammar is not great, but I think it reads very strange.
Yes, it is. The name is technically an interjection and must be separated by commas. Whether it is at the beginning of the sentence or the end, it must be separated off.
Another reason is because commas save lives.
It's time to eat Mat.
Here, we're having fried Mat wrapped in noodles for supper.
It's time to eat, Mat.
Here, we're having supper with Mat. It can make a large difference in the meaning.
The comma is required. This shouldn't be subjective. For example, there is a difference between "how are you my old friend" and "how are you, my old friend." I hope readers can see the difference.
For the case of "thanks john, " the same rules as illustrated in the above window apply. There is actual meaning or grammatical reasoning for the the comma. People often say it goes where a speaker would pause, but that is merely a tip to where it should be placed for young readers.
My sister is a grammarian, professor of english literature, and a librarian. She always said that just because other people drop the comma doesn't mean it is right. This goes for the "in work emails" example everyone uses. In work emails most people also do not put a period after "Thanks, John." They either put a comma or nothing, which are both so grammatically wrong if you press enter and start your paragraph with a capitalization.
The comma is required. Sentence 3, below, follows the same pattern as 1 and 2, in which the comma is obviously required:
A comma is not required here and should generally be disfavored. You should generally write the same way you would speak. A comma often represents a pause. Nobody says "Thanks [pause] James"; rather, you say "Thanks James." Adding a comma here can actually increase ambiguity when there are multiple people part of an email chain, because people typically "sign" the end of an email letter with ", [name]". For example, "Thanks, Joe" is ambiguous as to whether Joe is the person being thanked or the person giving thanks.
"It's time to eat, Mat" is a cute and useful example of where it would be critical to include a comma even though a speaker might not pause before saying Mat. However, this atypical example doesn't support writing "Thanks, Mat" if you're trying to thank Mat.
There is no "technical" grammatical reason to include a comma in "Thanks, Mat" where you are trying to say "Thanks Mat."
Consider the following: