Tuesday, 26 March 2013

Chapter 3



Concept of Programming Languages by Robert W. Sebesta Answer

Review Questions

1. Define syntax and semantics.

Syntax is form of a programming language’s expressions, statements, and program units.

Semantics is meaning of expressions, statements and program units.

2.Who are language descriptions for ?
Language descriptions is for programming language implementors

 4. Describe the operation of a general language recognizer.
The general operation of language recognizers is it will scan whether inputted string is inside certain language. If it is, it will accept the string.

5. What is the difference between a sentence and a sentential form ?
Sentence is strings of a language while sentential form is strings in the derivation

7. What three extensions are common to most EBNFs ?
optional part of RHS is delimited by brackets, the enclosed part can be repeated indefinitely or left out left altogether.

8. Distinguish between static and dynamic semantics.

Static semantics is only indirectly related to the meaning of programs during execution.

Dynamic semantics is not universally accepted in notation.

9. What purpose do predicates serve in an attribute grammar ?

Predicates function as boolean expression on the union of the attribute set and a set of literal attribute values

10. What is the difference between a synthesized and an inherited attribute ?
Synthesized attributes are used to pass semantic information up a parse tree while inherited attributes pass smenatic information down and accross a tree.

11. How is the order of evaluation attributes determined for the trees of a given attribute grammar?
The parse tree is evaluated based on its underlying BNF grammar, wit a possibility of having empty set of attributes values attached to each node.

12. What is the primary use of attribute grammars ?
Attribute grammars are used to describe more of the structure of a programming language than can be described with a context-free grammar.

Monday, 11 March 2013

Chapter 2


Concept of Programming Languages by Robert W. Sebesta Answer

Review Questions

1. In what year was Plankalkul designed ? in what year was that design published ?
Plankalkul is a computer language designed for engineering purporses by Konrad Zuse between 1943 and 1945. 
It was the first high-level non-von Neumann  programming language to be designed for a computer. Also, notes survive with scribblings about such a plan calculation dating back to 1941.  It was published in year 1972.

2. Mention an interesting feature of Zuse’s programs.
It includes assignment statements, subroutines, conditional statements, iteration, floating point arithmetic, arrays, hierarchical record structures, assertions, exception handling, and other advanced features such as goal-directed execution.

3. What does Plankalkul mean ?
Plan Calculus (Plankalkul word is from Germany).

4. Speedcoding was invented to overcome two significant shortcomings of the computer hardware of the early 1950s. What were they ?
Speedcoding is a floating point three-address system which greatly simplifies programming, and checking out a program. Speedcoding provides convenient input-output operations, built-in checking, easy loading and printing. Therefore, Speedcoding reduces programming and testing expenses considerably. These expenses are often a large part of the cost of operating a computing installation. Thus Speedcoding is economical as well as convenient to use.

6. What hardware capability that first appeared in the IBM 704 computer strongly affected the evolution of programming languages ? Explain why.
The hardware has both indexing and floating-point instructions. It affects strongly because floating-point operations were simulated in software, and this operation is very time-consuming and the interpretation and the simulation of indexing were insignificant.

7. Who developed the Speedcoding system for the IBM 701 ?
The language was developed by John Backus in 1953 for the IBM.

10. What was the most significant feature added to Fortran 1 to get Fortran II ?
It added independent compilation of subroutines. Without it, any change in a program required the entire program to be recompiled.

11. What control flow statements were added to Fortran IV to get Fortran 77 ?
if-else

12. Which version of Fortran was the first to have any sort of dynamic variables ?
Fortran 90

Tuesday, 5 March 2013

Chapter 1



Concept of Programming Languages by Robert W. Sebesta Answer

Review Questions

1. Why is it useful for a programmer to have some background in language design, even though he or she may never actually design a programming language ?
Having some background in language design will help a programmer to learn about new programming language easily and make the programmer be able to select the most suitable language for particular project .

2. How can knowledge of programming language characteristics benefit the whole computing community ?
By knowing the fundamentals of a programming language, a programmer will know what happen in computer underneath the hood and making the programmer  to have an ability to understand any new programming language. This will give an insight on what functionality of certain languages works well and what doesn’t work well.

3. What programming language has dominated scientific computing over the past 50 years ?
FORTRAN is the language used in past 50 years for scientific applications.

4. What programming language has dominated business applications over the past 50 years ?
COBOL is the language used in past 50 years for business applications.

5. What programming language has dominated artificial intelligence over the past 50 years ?
LISP

6. In what language is most of UNIX written ?
C programming language.

7. What is the disadvantage of having too many features in a language ?
It will reduce the software development itself, since the programmers will not have a full control to the language.

8. How can user-defined operator overloading harm the readibility of a program ?
User-defined operator overloading can harm the readability in case that user doesn’t realize the difference in operands and a possible confusion between functions of an operator.

9. What is one example of a lack of orthogonality in the design of C ?
For example of the lack of orthogonality in C is that C has 2 types of structured data types, they are array and struct.

10. What language used orthogonality as a primary design criterion ?
ALGOL 68.

11. What primitive control statement is used to build more complicated control statements in languages that lack them ?
GO TO is used to build more complicated control statements such as the FOR loop statement.

12. What construct of a programming language provides process abstraction ?
The use of a subprogram to implement a sort algorithm that is required several times in a program. Without the subprogram, the algorithm would need to be copy-pasted at all places it need to be and thus making the code longer and harder to understand and read.

13. What does it mean for a program to be reliable ?
A program is said reliable if and only if it performs its normal function specified under all conditions including good memory management that means there will be no memory leak.

14. Why is type checking the parameters of a subprogram important ?
Because parameters of a subprogram is like a command-line arguments that means if the paremeter is wrong, it will make the program error or not run properly. Also it is possible for a subprogram to receive a type of variable that is different from what is expected that can make an error too.

15. What is aliasing ?
Aliasing is having two or more distinct name to access the same memory cell. It is considered dangerous feature. For example, assigning two pointers with different name into one variable. In some languages, aliasing is used to overcome deficiencies in the language’s data abstraction facilities.