Compare Two Criteria or Characteristics Using Visual Basic and Visual C++

1216 Words3 Pages

1. Compare two criteria or characteristics using Visual Basic and Visual C++.

Readability. Visual Basic is a programming language that can be easily read. Most constructs resemble plain English words and phrases. It also has low feature multiplicity. To increment a variable one must write: i = i + 1. Visual C++ has several ways of doing it though with slightly different meanings: i = i + 1 or i +=1 or i++ or ++i. This lowers the readability of Visual C++. Visual Basic still retains the 'goto' statement which allows for unconditional jump to a labelled code line. If misused, it can lead to unstructured programming and lower readability. Overall, Visual Basic has higher readability than Visual C++.

Writability. Visual C++ allows for more expressivity while writing code. As in the previous example, incrementing a value can be done in several different ways. Implementing a binary tree in Visual C++ comes natural with the use of pointers. While this can be accomplished in Visual Basic with the use of references, it is more cumbersome. Overall, Visual C++ has higher writability than Visual Basic.

2. Give one advantage and one disadvantage for each of the following language characteristics:

◦ Generality – advantage: a language with high generality can be used in a wide range of applications; disadvantage: a language with high generality may be more difficult to use in a specific application domain than a language build with that domain in mind

◦ Aliasing – advantage: allows for more flexibility in writing code; disadvantage: may increase the chance for program errors when the value pointed to by two references is changed.

◦ Type Checking – advantage: if type checking is done at compile time, possible errors are detected ...

... middle of paper ...

...r op;

Expression term1, term2;

}

9. Draw the abstract syntax tree of the following assignment expression: x = y + 1

Statement

Assignment

Variable Statement

x Binary

Expressions Operator Expressions

Value op Value

term1 term2

10. By an example, show that the following BNF is ambiguous. Show at least 2 different parse trees

-> |

->

-> + | -

Example 1:

=>

=> +

=> +

=> + +

=> a + + < id>

=> a + b + c

Example 2:

=>

=> +

=> + < id>

=> + + c

=> + < id> + c

=> a + b + c

Two distinct parse trees for the same sentence, a + b + c. The BNF is ambiguous.

Open Document