Hi, Habrovsk. I havenโt written much here yet, but managed to try several formats of articles. Here were interviews with some IT specialists from the company in which I work, translations, guides ... Something went in, something did not. And so, today I decided to try a new format for myself.
In my free time I sometimes like to sit on Quora - I answer questions from other participants, or just read answers to interesting questions. The other day I came across one rather popular question. The thread has more than a thousand subscribers and 100+ responses. And the question is: what is the best comment you have seen in the source code? (Orig. What is the best comment in source code that you have ever encountered?)I know that there are such threads on both stackoverflow and reddit, but since I was inspired by the answers from Quora, I decided to make a selection from there. I looked through most of the answers and chose the couple that came in the most.Answer by Costya Perepelitsa
Best comment I've ever seen, probably, Safety Pig ( Security Pig ):
I've never been entirely sure exactly how it was supposed to help me in the code processing, but whatever it was, it worked.In the end, we included Safety Pig as part of our debugging and security process:โThe way this code is structured makes it especially difficult to detect memory leaks. Add a Safety Pig and push your changes through Valgrind before each commit. โโThe compiler cannot provide type safety here, so we added Safety Pig just in case.โโI don't have unit tests yet, but I added a pig to them.โ (almost worked)For those of you who would like to have your own Safety Pig, ignore the first line. Quora code blocks automatically remove leading spaces in the first line.1. .
2. _
3. _._ _..._ .-', _.._(`))
4.'-. ` ' /-._.-' ',/
5. ) \ '.
6. / _ _ | \
7. | a a / |
8. \ .-. ;
9. '-('' ).-' ,' ;
10. '-; | .'
11. \ \ /
12. | 7 .__ _.-\ \
13. | | | ``/ /` /
14. /,_| | /,_/ /
15. /,_/ '`-'
Reply by Sasha Krassovsky
Once I was looking at the source code of some random student games that I found on DigiPen when I suddenly saw this:
Naturally, I had to see what happens if I delete the comment. I deleted it and tried to recompile. Did not work. When I returned the comment, it compiled as if by magic.There was an error LNK1000: "unknown error; See the documentation for technical support options. โ Why this comment was necessary will forever remain a mystery.Answer by Rishi Kumar
The best I've seen is in a complicated program:1.
And then, after about five lines, this:
Reply by Chen Xu
Once I saw this:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
19.
20.
21.
22.
23.
24.
Buddha statue blesses your code to be free from bugs. Laughing at it for a while.From a response from Somnath Mishra
Once upon a time I saw a similar thread on Stackoverflow and there shared some of the funniest comments I came across. Yes, I myself wrote a lot of funny comments, but I will not share them here for obvious reasons.This comment is not just fun, but brilliant. Some people give up their literary dreams when working as programmers:1.
2.
3. $str = str_replace(array("\{","\}")," ",$str);
(lane. Replaces spaces between brackets in those places where they cause stasis)It sounds impressive in English - two lines of commentary, and there are 6 rhyming words in them.
A bit of black humor:1. double penetration;
The code can make a person an atheist:1.
2.
3.
When cleaning up old code, programmers often encounter parts that are not used, but do not delete, for fear of possible consequences:1.
Annoyed programmer:1.
2.
(lane. I am not responsible for this code. They forced me to write it against my will)Angry programmer:1.
2.
3.
Conclusion
The thread still had a lot of interesting things, you can read everything in English here . In general, if this post comes in, I think that later I will collect a list of the most interesting comments that were found in my practice. And which ones have you met? I will be glad to read in the comments.