The purpose of code comments need not be explained to the programmer. Sometimes when you look at someone else’s code, you see comments that make you laugh.

1. Adon sharing

Or:

When I wrote this code, only God and I knew what it didCopy the code

1. 2. Smart Trashcan

When Sergey Brin got his PhD in computer science at Stanford university, his resume didn’t have the word “Objective” in it. But when you look at the HTML source code of his resume, you will see that (he clearly stated the “salary requirements” in the HTML source file of his resume, but annotated it, it will not show on the browser page).

(The “salary requirements” are: a big office, more money and less work. It would be even better if you could travel to fantastic places regularly and still get paid for it.)

3.Share by Liu Wei

I saw a lot of people talking about this site on social networking sites a week ago, and the source code for the site includes these comments.

Some say the company should strengthen its code review system. Others suspect that the company may not have enough human resources to do the code review because it takes at least two programmers to do it.

📍Facebook big guy take you to disassemble the big factory original problem, straighten out the solution idea, efficient preparation algorithm interview in January.

  • Analyze more than 40 2020 algorithm real questions +99 matching consolidation exercises of five first-line manufacturers (Bytedance/Meituan/Kuaishou/netease/Blibli)

  • Build the necessary knowledge framework for interview, so that you can quickly master the core soft and hard skills of interview.

Click on the link for free audition immediately: www.jiuzhang.com/course/73/?…

4.Shared by Abhinav Upadhyay

/* You are not expected to understand this */ * We are not expected to understand this */Copy the code

I didn’t see the note myself, but it’s circulating pretty well online. This comment is from bell LABS ‘Unix system Release 6 and is noted in the book Lions’ Commentary on Unix 6th Edition, with Source Code.

Details of the code and annotations are as follows:

/* * retu(rp->p_addr); sureg(); /* * If the new process is suspended because it was swapped out, set its stack level to last call and pass it to sayu(u_ssay). * This is done to ensure that the value returned immediately after aretu is called is essentially the value returned by the method that last called Sayu. * * You are not expected to understand this. * * We don't expect You to understand thisif(rp->p_flag&SSWAP) {

   rp->p_flag =& ~SSWAP;

   aretu(u.u_ssav);

}

 /*

 * The value returned here has many subtle implications.

 * See the newproc comments.

 */

return(1);
Copy the code

5.By Sasha Krassovsky

Once, I looked at a random piece of code given to me by a student and found this comment:

/* Do NOT delete this comment */Copy the code

Of course, I’m just going to see what happens if I delete the comment. So I just deleted it and recompiled it. As a result, the program really doesn’t work. Then I put the comment back in, and it was fine again.

After deleting the comment will report an error LINK1000, according to the description of the linker error document, the reason for the error is directly: “unknown error; Please refer to the documentation or seek technical support.

Why can’t this comment be removed? I guess it’s always been a mystery to me.

6.Edwin Romero

I’m not sure how many people are familiar with the robots.txt file in the site. This file doesn’t actually run the necessary code, but it does declare what the crawler/search engine can crawl/find on the site.

I found the robots.txt file on the Nike website very interesting and added an interesting pattern:

7.Shared by Terry Lambert

My favorite notes are two, both by Bill Paul. This guy did a lot of work for FreeBSD and is now employed by Wind River System. I heard the company was recently acquired by Intel. Bill is a very talented programmer, but he also has a surprisingly low tolerance for stupidity and an unusual sense of humor.

Here is the first comment I like, which I found in the RelTek 8129/8139 PCI NIC driver.

 /*
 
 * The RealTek 8139 PCI NIC redefines the meaning of 'low end.'RealTek 8139 PCI NIC rebrush the low limit * This is probably the worst written PCI Ethernet controller driver ever * with the possible exception of the FEAST chip made by SMC.> * The 8139 supports bus-master DMA, but it has a terrible * interface that nullifies any performance gains that * bus-master DMA usually offers. * * For transmission, the chip offers a series of four TX * descriptor registers. Each transmit frame must bein a
 
 * contiguous buffer, aligned on a longword (32-bit) boundary.
 
 * This means we almost always have to do mbuf copies in order
 
 * to transmit a frame, except in the unlikely case where a)
 
 * the packet fits into a single mbuf, and b) the packet is
 
 * 32-bit aligned within the mbuf's data area. The presence of * only four descriptor registers means that we can never have * more than four packets queued for transmission at any one * time. * * Reception is not much better. The driver has to allocate a * single large  buffer area (up to 64K in size) into which the * chip will DMA received frames. Because we don't know where
 
 * within this region received packets will begin or end, we

 * have no choice but to copy data from the buffer area into
 
 * mbufs in order to pass the packets up to the higher
 
 * protocol levels.
 
 *
 
 * ItIt's impossible given this rotten rotten design to really achieve 100Mbps for decent performance at 100Mbps, Unless you happen to have a COMPUTER with a strong CPU to drive * 400Mhz PII or some equally overmuscled CPU to drive it. * * On the bright side, the 8139 does have a built-in PHY, * although rather than using an MDIO serial interface like * most other NICs, the PHY registers are directly accessible * through the 8139's register space. The 8139 supports
 
 * autonegotiation, as well as a 64-bit multicast filter.
 
 *
Copy the code

This is definitely a cool note. Legend has it that Bill was tempted to delete/revise/modify/update the comment, but he refused.

The second comment is in the “harm limitation” clause of a modified BSD license that Bill references in his code. In fact, it does not make any major changes to the original agreement, so many people read the agreement, it looks like a template, and then skip it. Few people read the whole text carefully.

 IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD BE LIABLE
 
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
 CONSEQUENTIAL DAMAGES
Copy the code

What do you think? I don’t think you’ve seen this. It’s actually pretty easy to get rid of. Here’s where it gets interesting:

“In no way did Bill Paul or the ideas in his mind directly, indirectly, accidentally, specifically, typically or materially cause any harm.”

Anyway, this guy’s a genius.