Programming Language Concepts R Sebesta Chap 1 Sample Problem

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

7. Java uses a right brace to mark the end of all compound statements.

What are the arguments for and against this design? -Java uses a right brace to mark the end of all compound statements. What are the arguments for and against this design The argument for using the right brace to close all compounds is simplicity a right brace always terminates a compound. The argument against it is that when you see a right brace in a program the location of its matching left brace is not always obvious in part because all multiple-statement control constructs end with a right brace

8. Many languages distinguish between uppercase and lowercase letters in user-defined names. What are the pros and cons of this design decision? -In favour is that it can give clarity and it expands the number of such names (for any given length limit of such names). Against is that it is prone to error by users.

10. What are the arguments for writing efficient programs even though hardware is relatively inexpensive?

One of the main arguments is that regardless of the cost of hardware, it is not free. Why write a program that executes slower than is necessary. Furthermore, the difference between a well-written efficient program and one that is poorly written can be a factor of two or three. In many other fields of endeavor, the difference between a good job and a poor job may be 10 or 20 percent. In programming, the difference is much greater.

18. Many contemporary languages allow two kinds of comments: one in which delimiters are used on both ends (multiple-line comments), and one in which a delimiter marks only the beginning of the comment (oneline comments). Discuss the advantages and disadvantages of each of these with respect to our criteria.

The main disadvantage of using paired delimiters for comments is that it results in diminished reliability. It is easy to inadvertently leave off the final delimiter, which extends the comment to the end of the next comment,

effectively removing code from the program. The advantage of paired delimiters is that you can comment out areas of a program. The disadvantage of using only beginning delimiters is that they must be repeated on every line of a block of comments. This can be tedious and therefore error prone. The advantage is that you cannot make the mistake of forgetting the closing delimiter.

You might also like