Jump to content

Does all programming use comments?

Baby Astronaut

Recommended Posts

1) Are there any program languages that don't let you insert comments? By this I mean the extra notes and whatever that have no additional effect or function other than to be reading material for anyone viewing the underlying source code.


2) Do all files types let you place comments in them? For example, putting comments into a .jpeg, .txt, .exe, .ogg, .whatever, and they're only viewable if you check the header info or wherever they'd normally go (and the comment doesn't interfere with the normal viewing or executing of the file).


3) Is there a size limit to the comment you're able to put in #1 or #2?


4) Can you do a plain text comment for all instances of #1 or #2?

Edited by Baby Astronaut
Link to comment
Share on other sites

1) I can't think of a language that does not allow for comments in it's specification. Comments are not however, placed into compiled code. There are ways to embed comments into compiled code. There is a special form of notes in some languages, libraries, or variants called annotations. Annotations are an active form of notes that can affect the way a program operates and is mostly used to help ensure correct program execution.


2) No! Notepad(Windows) files do not have a header that allows you to place a comment on the file. This is an awkward question because the explanation of all the different background and inner workings involves specifications created by both the file type creator, and also specifications created by the OS.


3) There are size restrictions on anything you do on a computer. Sometimes these only manifest as hardware considerations, where other times they are explicitly stated as part of a specification. I think it is safe to say that you will only encounter headers whose comments have a defined maximum string length.


4) Isn't this the same as asking questions #1 and #2?

Link to comment
Share on other sites

1. I'll begin by saying I haven't programmed in all languages so I can't answer this definitively. I have programmed in many languages and I have not encountered an interpreted or compiled language that doesn't allow comments in the source code. I have programmed in both assembly code and directly in machine code and using comments in those instances would defeat the space saving, speed achievement reasons for using those methods of programming. FWIW, early on in BASIC it was a handy trick to put a remark or comment in the BASIC code to reserve space that was then filled with directly executable machine code. BASIC ran very slowly and it could take close to a minute to paint the screen with it but you could bury machine code inside BASIC comments that could paint the screen so fast it appeared instantaneous. I used this in some early experiments with subliminal messages back in the 1980s.


2. No

3. Yes

4. No

Link to comment
Share on other sites

1. I'm not sure, but I'd check Functional Programming languages


2. (.txt) is a text file where "comments" are meaningless, in (.exe) files, you can't add any more bits, note that comments in source codes are


excluded when compiled, media files (.ogg), (.jpeg), ..etc are all data, but there is a method called Stenography in Cryptography field where


you use bits that doesn't ruin the details in the image\sound\video where you can insert data, and retrieve it from within ...


3. everything recorded is limited by the medium


4. I've mentioned details above, I think you misused the term "comment" which is related to programming languages

Edited by khaled
Link to comment
Share on other sites

  • 5 weeks later...

I believe all language have comment enabling and rightly so, because a programmer has to know what each line or a block of code does when writing long, complicated codes.


The only comment you can put inside of a picture is in the alt text when placing comments on a website. Other than that, pictures don't accept comments.










Edited by Cap'n Refsmmat
remove spam links
Link to comment
Share on other sites

I am unsure if all languages allow comments but I am under the impression that all good programmers use comments.

Comments make updates easier to perform and after 20 years helps you to understand what you tried to do and why.

(yes I do have code that is more than 20 years old and yesI am glad I used comments)

If you are very good you can make sence of most code but it is still easier if comments are there to help.



Link to comment
Share on other sites

I'm just wondering if you can leave comments anywhere, in whatever format. Even just inserting them in the header portion of files, such as video or images. Without corrupting the file. Or maybe attach a file or program into the header or comment area, but it'd be entirely inactive and wouldn't even be noticed -- the image, video, or whatever file would open normally and the embedded file/program would be inert....thus it has to be extracted in order to be functional.

Link to comment
Share on other sites

As capn said, not all file formats support metadata or other information that won't affect the output.

Even in some that don't, it is possible to hide a message. You can put your message in the least significant bits of a picture or audio file, they will not change the color/sound perceptably, but would allow you to write something someone else could later read (perhaps in a text editor if you were very clever, or maybe a hex editor or some custom encoding). This process is called stenography.


I've also been wracking my brains trying to remember the source, but I recall reading about some early programmers putting messages in areas of the machine/source code that they prevented the machine from ever getting to. Something like:

if (1== 0) {
       int The_code_below_this_block_does_something_complicated_and_hard_to_understand

Although I'm certain the language was not a c-like one.

You could probably even do this with raw machine code (so that it was a message when encoded in -- say -- ascii) if you prevented the computer from executing that section.

Similar tricks could/probably have been employed in many circumstances.

This being said, there are formats that don't have metadata and in which every bit of the file makes a significant difference to the output (raw text comes to mind, although there is probably room in there somewhere to hide a message -- access times, permissions and such; although it wouldn't all be preserved when you copied the file/accessed it etc).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.