Chapter 5: A Passing Comment

Mull It Over

  1. How might the need for and the content of comments differ in the following types of code:

    1. Low-level assembly language (machine code)

    2. Shell scripts

    3. A single-file test harness

    4. A large C/C++ project

Assembly language is less expressive, providing fewer opportunities for self-documenting code. Therefore, you'd expect more comments in assembly code, and you'd expect those comments to be at a much lower level than comments in other languages—assembly language comments generally would explain how as well as why.

There isn't an enormous a difference between the remaining three. Shell scripts can be quite hard to read back; they are proto-Perl in this respect. Careful commenting helps. You're more likely to use literate ...

Get Code Craft now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.