Zuckerberg Just Made a Mistake Trusting Elon Musk.

Then he stormed out of the room in less than three seconds to provide psychological support for his team members at Reality Labs, the company department responsible for the metaverse. This is, like…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Code comments as a work of art

Welcome all developers and everyone who commiserate. Everyone commented their code at least once — that’s for sure. Was it your code or someone else’s? Were these comments useful? Or were they made to cheer up teammates and team leads at the next code review? Let’s try to discuss a bit and find answers to these questions. Try to understand the motives of people who leave comments in their program. In this article, we focus on non-standard and funny comments. We have some really cool examples for you. Let’s go!

Major research usually starts with history. The deeper in history researchers go, the better. Let’s follow this tradition. But first, we’ll inspect programming and code commenting.

I don’t think anyone would argue that programming is art. It’s almost like writing but with a bit of technology and philosophy. A modern program is, in fact, a book with instructions for a compiler or a virtual machine with a compiler. However, this code “book” is read not only by machine but also by a human. They not only look, but also edit the code, and this takes time and effort. Therefore, despite elements of creativity, a developer’s work is still a routine. So, the emotional component is very important.

A human is a social being, we need communication. And it’s really hard to communicate with a machine. How joyful it is to read a message to yourself with explanations or funny comments! It’s even better if another developer left the message too. They probably didn’t expect that you would read it. Feel the drama? Here you are, communicating. Often, you’re complete strangers. But at these moments you are almost working together. You wander through the code maze and try to figure out how the code works. Leave each other hints and easter eggs. Teamwork!

Besides, you often need to blow off the steam. And if this ‘steam’ was caused by the code, comments allow you to blow it like this:

Let’s return to history (preferably ancient) and, of course, writing. What can be more ancient than the word? Especially the one that was in the beginning. However, the scientists believe that in the beginning there was the cave painting. This is a caveman’s subconscious desire to leave a message to their fellows or descendants. Capture life, customs, scenes of hunting or holidays. Sort of a comment to their daily (and hard) life. Yes, they did their best. But they did!

And here comes the XX century with a rapid development of technology. The first mechanical and electronic computers. Did you know that Mercedes also made arithmometers? I didn’t.

Of course, the first program comments weren’t that good. I’m not sure people thought about them at all. For a long time, developers used punched card for programming. Of course, they could write something funny on those cards, like: “Hey, guys, look at this cool pattern of holes”. But would anybody appreciate it?

First computers were huge, complex, and were used for very serious calculations. Developers were serious too.

How could they leave funny comments? Although the gentleman in the following photo is clearly pleased with something in the printout.

Finally — the contemporary history. Computers are in every house, and programming is not a specific job. Now, the program’s code is easy to create, correct, and comment.

The main thing is to use this opportunity wisely. Because there’s nothing worse than a map that doesn’t match the terrain, or a comment that doesn’t match the code:

But how often do developers leave comments, especially funny ones? There are no exact statistics. For the sake of interest, I calculated the comments’ percentage (of the total number of lines) in our analyzer. Here are the statistics by every programming language:

I don’t know what conclusions can be drawn here. Does that mean that the C# developers are lazier than the C++ ones, and therefore they rarely comment the code? :) Or is their code so cool and readable that they don’t need to comment anything? I looked at some comments, and they are all quite serious. Except that in many places I saw the classic “Don’t touch!!!”. I’m glad to see that nothing human is alien to our developers.

At first, I wanted to rate the most epic comments here. But after I looked through the low-rated answers, I realized they were quite funny too. That’s why in this article I’ll show you the answers I like the most. This is not a rating; the list is arbitrary.

Poetry

A great example of how to bring a powerful emotional component to a soulless code. Of course, you should not get carried away with such messages on a regular basis. But I am sure — such a comment, when met, will cause only positive emotions.

Interactive

The author wrote that they didn’t publish the code with this counter. But even if it’s made for themselves, it’s a great example of a comment that encourages communication.

Code magic

By the way, I copied my “magic” code from somewhere, but I never figured out how it works. :)

The Unknown

The ninth circle.

Don’t you dare!

If it ain’t broke, don’t fix it.

Digital loneliness

Yes, that’s who the programmers are — inventive, with a great sense of humor. However, sometimes they feel lonely and try to talk to the machine.

Grumpy comments

Yes, everything was better these days.

I’ll do it tomorrow

I don’t support this behavior in any way. But we’re all humans, after all.

I’d rather get some sleep.

Make it clear

Yes, it is clearly impossible to understand anything here without explanations. Thanks, Cap.

Funny code

Well, the minus would have been sadder.

Not guilty!

No one will distract you at night, though.

Coffee time

We are for a healthy lifestyle.

Not mine — not sorry

When you’re Carmack.

Sometimes text is not enough

And they’re surprised that the source code is large.

Worth more than a thousand words

Save energy to coding.

Scary (or not)

Whatever, just don’t summon the disassembler.

Other

A couple of comments that don’t belong to any category.

Well, they got the present, after all.

For all occasions. I checked.

When your whole life is just comments.

Fired!

That’s all. I think it’s clear that code comments are infinite. You can find a million more funny and not funny examples. Comment your code, comment someone else’s, don’t keep it to yourself. Make it fun. And of course, remember to correct grammatical errors in comments on the release day! (it’s an old joke)

Add a comment

Related posts:

Diplomatic Discrimination

Every time something is happening all around the world. This regularity states that people are prone to justice. They are well aware of what is wrong, what is right, what is needed, and what should…

How About a World Without Suffering

I was literally just watching the penultimate episode of the fifth season of the Lucifer show that came out a couple days ago. Spoiler alert, it ends on Lucifer being very hurt because of a…

How much would i pay for car Insurance?

How much would i pay for car Insurance for cheap car that cost me honda accord 2000,I am 25 Years old, never been in any accident,I got my license 7 years ago ANSWER: I suggest one to try this site…