Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Two contrasting viewpoints on the declaration of comments in a programming langu

ID: 3585846 • Letter: T

Question

Two contrasting viewpoints on the declaration of comments in a programming language are represented by Ada and C. In Ada, comments begin with adjacent hyphens and end with the end of the line.

-- this is an Ada comment

In C, comments begin with /* and proceed to a matching */ :

/* this is an C comment */


Compare these two comment features with respect to readability, writability, and reliability. C++ added a comment convention ( two forward slashes) similar to that of Ada. Why didn’t C++ use exactly the Ada conversation ?

Explanation / Answer

There is no multiline comment in Ada. There is only single line comment given by

                    -- Ada Comment untill the line ends

But in c++, there are both single line comments and multiline comments.

             // Single line comment untill the line ends

            /* Multiple

                 Line

                 Comments */

Readability : In terms of readability, c has better comment symbol. It is easier to distinguish a comment from a code with // rather than -- as double hyphen could also be confused with pre increment operator. But double forward slashes can't be confused as such.

Writability : If we have to write a multiline comment, the comment style used in c++ is better as we just have to add /* */ once only. But in Ada, we have to add adjacent hyphens in each line.

Reliability : Reliability of both are the same. If a comment is there, then it will be ignored. But maybe sometimes the compiler in Ada can confuse adjacent hyphen with pre decrement operator.

C++ didn't use the exactly the Ada conversation, because of the misinterpretin the operator -- and also there are no multiline comments in Ada.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote