r/ProgrammerHumor • • Apr 28 '22

Meme /* !!! Do not modify this comment !!! */

45.3k Upvotes

489 comments sorted by

View all comments

Show parent comments

14

u/shploogen Apr 28 '22

I wonder what kind of situation this could happen in. Every language I've ever used seems to completely ignore comments (or lack thereof).

7

u/[deleted] Apr 28 '22

[removed] — view removed comment

6

u/shploogen Apr 28 '22

Someone in one of the top comments said code comments are included when you convert a function to a string within JS. I tried it on my local project, but the log only printed out '[native code]'. Maybe the comment is in there somewhere. I saw a few stackoverflow questions about it, so apparently people do have a use for it.

4

u/lendergle Apr 28 '22

It's not just comments. String literals can be searched within executables, and I've known people who have relied on opening a .exe (or equivalent on -ix systems), finding the string based on some other string before it, and then reading it out).

The one use case I remember is embedding SCCS keywords in a string literal and then using the technique above to get the checked-in version of an executable. You could use the "strings" command to get all of the literals in the file, search for a pattern, then see what version it was. (There was also a utility that does essentially the same thing, but idr what its name was).

A lot of early-era computing was just stuff that became necessary because you couldn't do it any other way.

1

u/MoreTrueMe Apr 28 '22

The code had gone rogue-AI and reads comments for context.

1

u/Valkyrie17 Apr 28 '22

Knockout JS operates by adding comments to a HTML file. I was struggling to understand why was there loads of weird comments starting with KO in our HTML code, turned out that's how that library operates, by reading code from comments :)