Wednesday, 29 October 2014

Assignment #4 (Concepts of Programming Languages Chapter 4 Review Questions)

REVIEW QUESTION :
A=Answer
16.  What is the FIRST set for a given grammar and sentential form ?
A=
FIRST( ) = {a => * a } (If => *  ,   is in FIRST( ))   
in which =>* means 0 or more derivation steps.

17.Describe the pairwise disjointness test.
A=It is a test of non-left recursive grammar that indicates whether left recursion can be done. It requires the ability to compute a set based on the RHSs of a given nonterminal symbol in a grammar.

18.What is left factoring ?
A=Left factoring is the action taken when a grammar leads backtracking while marking parsing/syntax tree.

19.What is a phrase of a sentential form ?
A=A phrase is a subsequence of a sentential form that is eventually reduced to a single non-terminal

20.What is a simple phrases of a sentential form?
A=simple phrases is just a phrase that takes a single derivation step from its root nonterminal node.

Tuesday, 14 October 2014

Assignment #3 (Concepts of Programming Languages Chapter 3 Problem Set)

Problem Set :
a=Answer
14. Draw parse trees for the sentences aabb and aaaabbbb, as derived from the grammar of Problem 13
a. 
14aproblemset14bproblemset

15. Convert the BNF of Example 3.1 to EBNF. 

a.
EBNF:
<program> → begin <stmt_list> end
<stmt_list> → <stmt> { ;  <stmt_list>}
<stmt> → <var> = <expression>
<var> → A | B | C
<expression> → <var> { (+|-) <var>}

16. Convert the BNF of Example 3.3 to EBNF. 

a.
<assign> → <id> = <expr>
<id> → A | B | C
<expr> → <expr> {(+ | *) <expr>}
| <id>



17. Convert the following EBNF to BNF: S → A{bA} A → a[b]A 

a. 
S -> A | AX
X -> bA | bAX
A -> aA | abA

18. What is the difference between an intrinsic attribute and a nonintrinsic synthesized attribute?

a. An intrinsic attribute is an inherent characteristic of a terminal symbol in the grammar. So the value of the attribute is determined solely from the terminal symbol. A nonintrinsic synthesized attribute is an attribute of a non-terminal symbol in the grammar.

Assignment #3 (Concepts of Programming Languages Chapter 3 Review Questions)

Review Questions :
a=Answer

16. In denotational semantics, what are the syntactic and semantic domains? 

a. The mapping functions of a denotational semantics programming language specification, like all functions in math, have a domain and a range, the domain is called the syntactic domain, and the range is called the semantic domain.

17. What is stored in the state of a program for denotational semantics? 



a. The state of a program for denotational semantics is the value of all its current variable.

18. Which semantics approach is most widely known?


a. The Denotational semantics is the most widely known semantics approach.

19. What two things must be defined for each language entity in order to construct a denotational description of the language? 

a. objects and functions 


20. Which part of an inference rule is the antecedent? 
a. The antecedent is the top part of an inference rule.


21. What is a predicate transformer function? 

a. wp(statement, postcondition) = precondition A wp function is often called a predicate transformer, because it takes a predicate, or assertion, as a parameter and returns another predicate.


22. What does partial correctness mean for a loop construct? 

a. If loop termination can be shown, the axiomatic description of the loop is called total correctness. If the other conditions can be met but termination is not guaranteed, it is called partial correctness. computing the precondition for a while loop depends on finding a loop invariant, proving the correctness of programs with while loops using axiomatic semantics can be difficult.


23. On what branch of mathematics is axiomatic semantics based? 
a. Axiomatic semantics, thus named because it is based on mathematical logic.

24. On what branch of mathematics is denotational semantics based?

a. mathematical objects (called denotations). 

Assignment #2 (Concepts of Programming Languages Chapter 2 Problem Set)

Problem Set :

a=Answer
14. What are the arguments both for and against the idea of a typeless language? 
Arguments for the idea:

a. Flexibility, Brevity of syntax. It places stricter controls on what objects can receive and send, so making it easier to enforce design strategies throughout the application. When there are errors in types, there can be picked up during precompilation or in the IDE.

Arguments against the idea:

a. Without type checking, there is no means to verify the integrity of the data without executing the application. The syntax of typed languages can be viewed as overly long or verbose. Typed languages aren’t as flexible as untyped languages, as data structures need to be cast to the correct type before another object can receive them. It is also said that by using typed languages, the compiler spends less time dynamically typing objects and so executes faster. However, this point is a grey area and that the main area of argument is how these language differences play out when designing applications where more then a few people are working on the code.

15. Are there any logic programming languages other than Prolog? 

a. Yes, there are Fortran, C++, COBOL, Algol.

16. What is your opinion of the argument that languages that are too complex are too dangerous to use, and we should therefore keep all languages small and simple? 

a. Languages are too complex are too dangerous to use because of its meaning itself. Ambiguous languages can cause trouble and misunderstanding among people.    So, we must keep it small and simple to avoid ambiguation and misunderstanding.

17. Do you think language design by committee is a good idea? Support your opinion. 

a. Language design by committee definitely has its advantages, with varying points of view from different domains, different programming backgrounds, and even different language backgrounds all contributing for the better of the language like ALGOL 58. Knowledge of Plankalkul enhanced ALGOL 58 because members from Europe were familiar with the language. Improvements like variable length identifiers and array dimensions were improved upon previous languages. Even though many arguments and conflicts arise, like whether to use a comma (European) or a period (American) for a decimal point took place, it is beneficial to have options. I think history would show that the best use of committees would be after a language has been invented and accepted. At this point a better evaluation is possible and committee members would be better conditioned to make improvements than initial discoveries.

18. Languages continually evolve. What sort of restrictions do you think are appropriate for changes in programming languages? Compare your answers with the evolution of Fortran.
a. A good deal of restraint must be used in revising programming languages. The greatest danger is that the revision process will continually add new features, so that the language grows more and more complex. Compounding the problem is the reluctance, because of existing software, to remove obsolete features.

Assignment #2 (Concepts of Programming Languages Chapter 2 Review Questions)

Review Questions :
a=Answer
16. In what way are Scheme and Common LISP opposites of each other? 

a. In its sizes, complexity, adn scoping(scheme: static scoping, Common LISP: both dynamic and static scoping).

17. What dialect of LISP is used for introductory programming courses at some universities?

a. Scheme

18. What two professional organizations together designed ALGOL 60?


a. The two professional organizations are Association for Computing Machinery (ACM) and GAMM

19. In what version of ALGOL did block structure appear?


a. ALGOL 60

20. What missing language element of ALGOL 60 damaged its chances for widespread use?


a. The lack of input and output statements with formatting

21. What language was designed to describe the syntax of ALGOL 60?


a. The language was  Backus Naur Form (BNF), which was Backus’s new notation for describing syntax of programming languages.

22. On what language was COBOL based?


a. FLOW-MATIC

23. In what year did the COBOL design process begin?


a. The beginning of COBOL similar to ALGOL 60 that was designed by a committee of people meeting for relatively short periods of time and in 1959, the design process of COBOL began and sponsored by the Department of Defense.

24. What data structure that appeared in COBOL originated with Plankalkül? 


a. Hierarchical data structure

Monday, 29 September 2014

Assignment #1 (Concepts of Programming Languages Chapter 1 Problem Set)

a=Answer

Problem Set:

14.    Describe the advantages and disadvantages of some programming environment you have used?

a.    ~C~  
=Disadvantages=
does not have concept of OOPs(Object Oriented Programming)
There is no runtime checking in C language

=Advantages=
C language has variety of data types and powerful operators. Due to this, programs written in C language are efficient, fast and easy to understand.

15.    How do type declaration statements for simple variables affect the readability of a language, considering that some languages do not require them?

a.    maybe have affect on readability of a language and user or reader  must be found type variables before used the language

16.    Write an evaluation of some programming language you know, using the criteria described in this chapter.

Readability

C has two kinds of structured data types, arrays and records (structs), records can be returned from functions but arrays cannot   

Writability

C language has relatively convenient, rather than cumbersome, ways of specifying computations(For example,the notation count++ is more convenient and shorter than count = count + 1).

Reliability

In different compiler c have different option for compiling and running.c give only the concepts.

17.    Some programming languages—for example, Pascal—have used the semicolon to separate statements, while Java uses it to terminate statements.Which of these, in your opinion, is most natural and least likely to result in syntax errors? Support your answer.

a.    in my opinion, the possibility of a second language can result in a syntax errors, but the java language more or less result in than the pascal syntax errors because the user is more effective to use a semicolon at the end of the statement compared with each statement

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 (online comments). Discuss the advantages and disadvantages of each of these with respect to our criteria


a.    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

Assignment #1 (Concepts of Programming Languages Chapter 1 Review Questions)


a=Answer
Review Questions:

16.  What is exception handling?

a.    Exception handling is The ability of a program to intercept run-time errors (as well as other unusual conditions detectable by the program).

17.  Why is readability important to writability?

a.    because readability affects a program and  Programs that are difficult to read are difficult both to write and to modify.

18.  How is the cost of compilers for a given language related to the design of that language?

a.    A language that requires many run-time type checks will prohibit fast code execution, regardless of the quality of the compiler.

19.  What have been the strongest influences on programming language design over the past 50 years?

a.    Von Neumann architecture

20.  What is the name of the category of programming languages whose structure is dictated by the von Neumann computer architecture?

a.    Imperative language

21.  What two programming language deficiencies were discovered as a result of the research in software development in the 1970s?

a.    in the 1970s discovered were incompleteness of type checking and inadequacy of control statements

22.  What are the three fundamental features of an object-oriented programming language?

a.    Abstraction, encapsulation and polymorphism are the three fundamental features of an object oriented programming language.

23.  What language was the first to support the three fundamental features of object-oriented programming?

a.    Smalltalk (Goldberg and Robson, 1989).

24.  What is an example of two language design criteria that are in direct conflict with each other?

a.    Two criteria that conflict are reliability and cost of execution