Comments: Leaving Notes in Your Code
Little notes the computer ignores, but people read
- say what a comment is in simple words,
- explain why the computer ignores comments but people read them,
- give good reasons to leave notes in your code.
1. What is a comment?
Code is full of instructions — steps the computer follows. But a program can also hold a special kind of line called a comment. A comment is a note for humans. The computer treats it like it is invisible: it reads past it and runs only the real instructions.
You mark a comment with a special sign so the computer knows to skip it. In many languages that sign is // or # at the start of the note. You do not need to memorise the signs yet — the important idea is simple: a comment is a note the computer ignores and people read.
2. Why leave notes in your code?
Comments do not make the program run faster or do anything new. So why write them? Because code is read by people, not just computers. Good notes help in many ways:
- Explain the "why". The code shows what happens; a comment can say why you did it that way.
- Help future-you. When you come back weeks later, a note reminds you what you were thinking.
- Help teammates. Other people can read your note and understand your code faster.
- Leave reminders. A short "TODO" note can remind you to finish something later.
- Turn code off for a moment. You can turn a line into a comment to hide it while you test — without deleting it.
Leaving clear notes is part of being a kind, careful coder. It is a gift to the next person who reads your code — and that person is often you!