I've noticed a few clever and funny jokes from time to time in the comments, so I thought I'd test the waters with my own comment joke (on topic and technically an answer) and it was popular. However I logged on the next day and noticed the comment was removed.
They're allowed, in the sense that you don't get in trouble for posting them. (Within reason of course. If somebody e.g. spams joke comments on many posts then that's a separate issue.)
But comments are prone to deletion, and those which don't offer a substantive contribution to the physics are especially prone to deletion. They do tend to attract flags, too, so we often notice them quickly.
My advice: don't read too much into it when your comments get removed. If you were doing something wrong with comments, such that you should actually refrain from posting such comments in the future, we would tell you so directly.
The answer by @David above summarizes it well.
Below I attempt to see what constitutes a good comment and in what situations a funny comment would be appreciated in any discussion. Sorry for the long post!
Equating a SE question to a classroom
- The Teacher poses a question and students are free to collaborate on the answers.
- A student attempts to answer the question and others may comment with an objective to improve the answer, highlight that the answer does not cover all aspects of the Q, or just may have questions to help them better understand the answer itself, and so on...
- Now assume that there is no urgency in finding the answer; so if a student were to joke at this point, however distracting it may be from the topic it would in most likelihood not be met with disapproval, and may even be appreciated by some :).
- However with a time constraint such as 5 mins more till the lecture ends, the lecturer may not appreciate this and would limit the discussion to just constructive comments. Of course nothing beats a humorous insight (something constructive AND funny!) but that is indeed very rare.
Space/Time Constraints on SE
- On SE we do have a minimal time constraint where questions not given enough attention are pushed lower over time while newer/trending questions get more eyeballs - based on some algorithm... So the goal is to showcase a good question and encourage more users to contribute by engaging them with a constructive and serious discuss in the comments. Example: If I am not serious about my question I will not have researched it well enough and this will not attract users to contribute to the solution.
- More importantly, SE has a space constraint where the comments are limited in number and size, also questions are encouraged to be more precise and well formatted. The aim being to allow users to collaborate and find answers in the most optimal way possible. For this same reason many comments are deleted.
- Typical forums do not have these constraints and so have some negatives like cross-posting, post/comments that are way longer than the quality matter they provide, ... all of these aspects are missing in SE sites.
- Jokes are very subjective so only some may get the joke; others may just find it distracting... So for the greater good it makes sense for moderators to trim the flagged comments to just constructive ones.
- So finally... a joke in a comment is most likely to survive the onslaught of the moderator's trusty
deleteif it includes some information that adds some meaning to the discussion... and if you can't do that then just get Chuck Norris to post it for you.