## Chapter 7

Concepts of Programming Languages 10th Edition – Robert W. Sebesta
Page 362-365
Lecturer : Tri Djoko Wahjono

Review Questions (Randomly 10 of 28)

1. Define operator precedence and operator associativity. (Number 1)
Operator precedence is a rule used to clarify which procedures should be performed first in a given mathematical expression. Operator associativity is a property that determines how operators of the same precedence are grouped in the absence of parentheses.
2. What is a ternary operator? (Number 2)
– O
perator with three operands.
3. What is a prefix operator ? (Number 3)
An operator which precede their operands.
4. What operator usually has right associativity ? (Number 4)
The “*” (pointer) operator.
5. What is a nonassociative operator ? (Number 5)
An operator that have no defined behavior when used in sequence in an expression.
6. What associativity rules are used by APL? (Number 6)
All operators have equal precedence and all operators associate right to left.
7. Define functional side effect (Number 8)
A condition where a function changes either one of its parameters or a global variable.
8. What is an overloaded operator? (Number 11)
The multiple use of an operator is called operator overloading.
9. What is a mixed-mode expression? (Number 14)
There are more than one type of operand in the expression.
10. What is short-circuit evaluation? (Number 18)
The result of expression is determined without all of the operands and/or operators.

Problem Sets (Randomly 7 of 22)

1. When might you want the compiler to ignore type differences in an expression ? (Number 1)
When you want to evaluate a string as a number and vice-versa.
2. State your own arguments for and against allowing mixed-mode arithmetic expressions. (Number 2)
FOR : A mixed mode arithmetic expression is needed in calculating expressions that might have decimal results. It is compulsory as it allows two different type of number data type such as float and integer to be summed without losing the precision of the float. Against : While it is compulsory to have mixed-mode expressions, it is more error prone when expressions made are more likely to have non-decimal results. A mixed mode might produce a decimal result even though the result wanted is a non-decimal.
3. Do you think the elimination of overloaded operators in your favorite language would be beneficial ? why or why not ? (Number 3)
No, it would not be beneficial. Overloading operator would be a helpful feature in developing a complex program with complex arithmetic operation as well. It allows developers to create a class whose function can replace countless lines of codes with an operator. This clearly will help a readability and writability of a program. Eliminating overloaded operators would null this advantage.
4. Would it be a good idea to eliminate all operator precedence rules and require parentheses to show the desired precedence in expressions? Why or why not? (Number 4)
No , it would not be a good idea. Although this custom precedence sounds like increasing flexibility, requiring parentheses to show a custom precedence would impact in readability and writability of a program.
5. Should C’s assigning operations (for example, +=) be included in other languages (that do not already have them)? Why or why not? (Number 5)
Yes, because it’s simpler than the normal <operand> = <operand> + <some values> form, and it can save much time.
6. Should C’s single-operand assignment forms (for example, ++count) be included in other languages (that do not already have them)? Why or why not? (Number 6)
Yes, because it’s simpler than the normal addition <operand> = <operand> + 1; and it can save much time.
7. Describe a situation in which the ad operator in a programming language would not be communicative. (Number 7)
An expression such as : x + fun(y), and fun(y) changes x.
Posted in KBP | 2 Comments

## Chapter 6

Concepts of Programming Languages 10th Edition – Robert W. Sebesta
Page 332-335
Lecturer : Tri Djoko Wahjono

Review Questions (Randomly 20 of 55)

1. What is a descriptor? (Number 1)
A descriptor is the collection of attributes of a variable.
2. What are the design issues for character string types ? (Number 3)
Should strings be simply a special kind of character array or a primitive type ? and Should strings have static or dynamic length ?
3. Describe the three string length options. (Number 4)
Static length string : the length is static and set when created. Limited dynamic length string : the length can vary up to the declared and fixed maximum set by the variable’s definition. Dynamic length string : The length varies without maximum. Stored in dynamic storage.
4. Define ordinal, enumeration, and subrange types. (Number 5)
An ordinal type is one in which the range of possible values can be easily associated with the set of positive integers. An enumeration type is one in which all of the possible values, which are named constants, are provided in the definition. Enumeration types proved a way of defining and grouping collections of name constants, which are called enumeration constants. A subrange type is a contiguous subsequence of an ordinal type. For example, 12..14 is a subrange of integer type.
5. What are the advantages of user-defined enumeration types ? (Number 6)
Improved writability and readibility, No arithmetic operations are legal on enum types and no enumeration types can be assigned values outside its defined range.
6. In what ways are the user-defined enumeration types of C# more reliable than those of C++? (Number 7)
The enumeration types in C# are better than those of C++, because enumeration type variables in C# are never coerced to integer types.
7. What are the design issues for arrays ? (Number 8)
What types are legal for subscripts ? Are subscripting expressions in element references range checked ? When are subscripts ranges bound ? When does array allocation take place ? Are ragged or rectangular multidimensional arrays allowed, or both ? Can arrays be initialized when they have their storage allocated ? What kinds of slices are allowed, if any ?
8. Define static, fixed stack-dinamic, stack-dynamic, fixed heap-dynamic, and heap-dynamic arrays. What are the advantages of each? (Number 9)
1. Static: subscript ranges are statically bound and storage allocation is static (before run-time). Advantage: efficiency (no dynamic allocation). 2. Fixed stack-dynamic: subscript ranges are statically bound, but the allocation is done at declaration time. Advantage: space efficiency. 3. Stack-dynamic: subscript ranges are dynamically bound and the storage allocation is dynamic (done at run-time). Advantage: flexibility (the size of an array need not be known until the array is to be used). 4. Fixed heap-dynamic: similar to fixed stack-dynamic: storage binding is dynamic but fixed after allocation. Advantage: space efficiency, storage is allocated from heap, and binding is done when requested. 5. Heap-dynamic: binding of subscript ranges and storage allocation is dynamic and can change any number of times. Advantage: flexibility (arrays can grow or shrink during program execution).
9. What happens when an nonexistent element of an array is referenced in Perl ? (Number 10)
–
If you try to append non-existent elements from an array to another one, the initial array will grow as needed, even though the elements to append do not exist.
10. How does JavaScript support sparse arrays ? (Number 11)
The value of subscripts need not to be contiguous.
11. What languages support negative subscripts ? (Number 12)
Ruby and Lua support negative subscripts.
12. What languages support array slices with stepsizes ? (Number 13)
Python,Perl and Ruby languages.
13. What array initialization feature is available in Ada that is not available in other common imperative languages ? (Number 14)
Listing arrays in order in which they are to be stored or direcly assigning them to an index position using the => operator.
14. What is an aggregate constant ? (Number 15)
Nonscalar constant which value never change or are not changed during execution of the program.
15. What array operations are provided specifically for single-dimensioned arrays in Ada ? (Number 16)
Ada allows array assignments, including those where the right side is an aggregate value rather than an array name. Ada also provides catenation, which is defined between two single-dimensioned arrays and between a single-dimensioned array and a scalar. Nearly all types in Ada have built-in relational operators for equality and inequality.
16. Define row major order and column major order. (Number 17)
Row major order is where elements of the array that have as their first subscript the lower bound value of the subscript are stored first. Column major order has elements of an array that have as their last subscript the lower bound value of that subscript are stored first.
17. What is an access function for an array ? (Number 18)
An access function for a multidimensional array is the mapping of its base address and a set of index values to the address in memory of the element specified by the index values.
18. What is the structure of an associative array? (Number 20)
An associative array is an unordered collection of data elements that are indexed by an equal number of values called keys. User-defined keys must be stored.
19. What is the purpose of level numbers in COBOL records ? (Number 21)
The level numbers in COBOL records are used to establish a hierarchical structure of related records.
20. Are the tuples of Python mutable ? (Number 24)
Python includes an immutable tuple type. So, No.

Problem Sets (Randomly 10 of 22)

1. What are the arguments for and against four signed integer sizes in Java? (Number 1)
Bytes (1 byte), short (2 bytes), integer (4 bytes), long (8 bytes). As a result, depending on the domain of the variable required and data types are used.
2. How are negative integers stored in memory? (Number 2)
In the number, the leftmost bit is considered as a “sign bit”, which signifies whether the integers are negative or not. If it’s negative, then that bit must store 1, and 0 otherwise.
3. What disadvantages are there in implicit dereferencing of pointers, but only in sertain contexts? For example, consider the implicit dereference of a pointer to a record in Ada when it is used to reference a record field. (Number 5)
When implicit dereferencing of pointers occurs only in certain contexts, it makes the language slightly less orthogonal. The context of the reference to the pointers determines its meaning. This detracts from the readability of the language and makes it slightly more difficult to learn.
4. Compare the use of Boolean data types C++ and Java. Give emphasis on their use in conditional statements and conditional loops. (Number 6)
Basically, both data types indicates the value true / false. In C++, the name is bool while in Java it’s Boolean. Boolean values and expressions are used to determine a condition statement or loop. The main difference is that Boolean in Java can only have values true/false, while in C++, other than true/false, integer values can be used to represent true/false statement – the value 0 is false and other values are considered as true.
5. Compare the pointer and reference type variable in C++. (Number 7)
A pointer can be re-assigned any number of times while a reference can’t be re-assigned after initialization. A pointer can point to NULL while reference can never point to NULL. You can’t take the address of a reference like you can with pointers. There’s no “reference arithmetics” (but you can take the address of an object pointed by a reference and do pointer arithmetics on it as in &obj +5).
6. C provides to derived data types both for name and structure type equivalence: struct and union. Make a study on when to use struct type variable and union type variables! (Number 9)
If all data members of the variables are to be used at once, then struct type variables are required, otherwise union type variables should be used.
7. In the Burroughs Extended ALGOL language, matrices are stored as a single-dimensional array of pointers to the rows of the matrix, which are treated as single-dimensional arrays of values. What are the advantages and disadvantages of such a scheme? (Number 11)
The advantages of this scheme is that accesses that are done in order of the rows can be made very fast; once the pointer to a row is gotten, all of the elements of the row can be fetched very quickly. The disadvantages, the elements of a matrix must be accessed in column order, these accesses will be much slower; every access requires the fetch of a row pointer and an address computation from there.
8. What are the arguments for the inclusion of strong type checking in Java, although they were not included in C or C++? (Number 16)
Java are strongly typed in the same sense as Ada. Types can be explicitly cast, which could result in a type error. However, there are rules of a language have an important effect on the value of an arithmetic operator with one floating-point operand and one integer operand is legal. The value of the integer operand is coerced to floating-point, and a floating point operation takes place. This is what is usually intended by the programmer.
9. Any type defined with typedef is type equivalent to its parent type. How does the use of typedef differ in C and C++? (Number 19)
C does not allow a given typedef to appear more than once in the same scope. C++ handles typedefs and type names differently than C, and allows redundant occurrences of a given typedef within the same scope.
10. In what way is dynamic type checking better than static type checking? (Number 21)
Dynamic type checking is done at compile time instead of run time, so dynamic type checking allows programmers to be more flexible. Moreover, static type checking do corrections later, which runs during runtime, and this is more costly compared to the dynamic type checking.
Posted in KBP | 1 Comment

## Chapter 5

Concepts of Programming Languages 10th Edition – Robert W. Sebesta
Page 255-260
Lecturer : Tri Djoko Wahjono

Review Questions (Randomly 8 of 23)

1. What are the design issues for names ? (Number 1)
Are names case sensitive ? and Are the special words of the language reserved words or keywords ?
2. What is the potential danger of case-sensitive names ? (Number 2)
The danger is that you might not be able to find the name in a reference even if you have spelled it correctly, because you haven’t got the case right. Therefore, you won’t find information that you need, or you might incorrectly create a new record with a different case, which nobody else will be able to find because it isn’t with the rest of the information.
3. What is an alias ? (Number 4)
An alternative name for an object, such as variable, file, or device.
4. Define binding and binding time. (Number 7)
Binding is an association between an attribute and an entity, such as between a variable and its type or value, or between an operation and a symbol. Binding Time is The time at which a binding takes place.
5. Define static binding and dynamic binding. (Number 9)
Static Binding is the process of mapping a message to a specific sequence of code (method) at compile-time. Dynamic Binding is the process of mapping a message to a specific sequence of code (method) at runtime.
6. What is the general problem with static scoping? (Number 15)
It’s usually too much access. Scope structure destroyed as program evolves.
7. What is a block? (Number 18)
The storage of a variable is allocated when the section is entered and deallocated when the section is exited.
8. What are the advantages of named constants? (Number 23)

Problem Sets (Randomly 4 of 12)

1. Decide which of the following identifier names is valid in C language. Support your decision. (Number 1)
_Student = valid, it starts with an underline and it is allowed.
Int = invalid. It is a reserved name for integer data type.
Student = valid. It uses capital letter which is allowed.
123Student=invalid. Variable names in C cannot be started with numbers.
Student123=valid. Variable in C can contain numbers as long it is not on the front.
2. What is l-value ? Write a statement in C language which gives the compile time error “l-value required” (Number 2)
L-value is memory address that are programmatically accessible to the running program.
printf(“%s\n”,*words++);
3. Why is the type declaration of a variable necessary? What is the value range of the int type variable in Java? (Number 4)
The type of a variable determines the range of values the variable can store and the set of operations that are defined for values of the type.
The int type in Java have a value range of –2147483648 to 2147483647.
4. Assume the following JavaScript program was interpreted using static-scoping rules. What value of x is displayed in function sub1? Under dynamic scoping rules, what value of x is displayed in function sub1?
var x;
function sub1(){
document.write(“x = ” + x + “<br />”);
}
function sub2(){
var x;
x = 10;
sub1();
}
x = 5;
sub2(); (Number 7)
Static scoping: x=5; Dynamic scoping: x=10;

## Chapter 4

Concepts of Programming Languages 10th Edition – Robert W. Sebesta
Page 219-221
Lecturer : Tri Djoko Wahjono

Review Questions (Randomly 8 of 27)

1. What are three reasons why syntax analyzers are based on grammars? (Number 1)
First : Grammars are clear and concise.
Second : The grammar description can be use as a direct basis for  the  analyzer.
Third : Grammar are modular / easy to maintain.
2. Explain three reasons why lexical analysis is separated from syntax analysis. (Number 2)
Simplicity, Techniques for lexical analysis are less complex than those required for syntax analysis. Efficiency, Although it pays to optimize the lexical analyzer, because lexical analysis requires a significant portion of total compilation time. Portability, Because the lexical analyzer reads input program files and often includes buffering of that input, it is somewhat platform dependent.
3. Define lexeme and token. (Number 3)
A Lexeme is a string of characters that is a lowest-level syntatic unit in the programming language. These are the “words” and punctuation of the programming language. A Token is a syntactic category that forms a class of lexemes. These are the “nouns”, “verbs”, and other parts of speech for the programming language.
4. What is a state transition diagram? (Number 6)
State transition diagrams have been used right from the beginning in object-oriented modeling. The basic idea is to define a machine that has a number of states (hence the term finite state machine).
5. What are the two distinct goals of syntax analysis? (Number 8)
To detect syntax errors in a given program, and to produce a parse tree or possibly the information required to build such a tree for a given program.
6. Describe the pairwise disjointness test. (Number 17)
The pairwise test try to test whether a parsing subprogram can determine which RHS is being parsed on the basis of the next token of input.
7. What is left factoring? (Number 18)
Left factoring is the action taken when a grammar leads backtracking while marking parsing or syntax tree.
8. Describe three advantages of LR parsers. (Number 23)
They can be built for all programming languages. They can detect syntax errors as soon as it possible in a left-to-right scan. The LR class of grammars is a proper superset of the class parsable by LL parsers.

## Chapter 3

Concepts of Programming Languages 10th Edition – Robert W. Sebesta
Page 182-186
Lecturer : Tri Djoko Wahjono

Review Questions (Randomly 10 of 29)

1. Define syntax and semantics. (Number 1)
– Syntax is the form of its expressions, statements, and program units. Semantics is the meaning of those expressions, statements, and program units.
2. Who are language descriptions for? (Number 2)
– Language description is used to make a statement more bold and provide a better imagery.
3. What is the difference between a sentence and a sentential form? (Number 5)
– Sentence is the strings of a language. Sentential is each of the strings in the derivation, including <program>.
4. What three extensions are common to most EBNFs ? (Number 7)
– Denotes an optional part of an RHS, Use of braces in an RHS to indicate that the enclosed part can be repeated indefinitely or left out altogether, and Multi Choice options.
5. Distinguish between static and dynamic semantics. (Number 8)
– Static semantics is more on the legal forms of programs (syntax rather symantics) and is only indirectly related to the meaning of the programs during execution. Static semantics is so named because the analysis required to check these specifications can be done at compile time. In many cases, the semantic rules of language state its type constraints.
6. What is the difference between a synthesized and an inherited attribute ? (Number 10)
– Synthesized attributes are used to pass semantic information up a parse tree. Inherited attributes pass semantic information down and across a tree.
7. What is the primary use of attribute grammars ? (Number 12)
–  Attribute grammar is primary used to provide complete descriptions of the syntax and static semantics of programming languages.
8. Why can machine languages not be used to define statements in operational semantics? (Number 14)
– Because the individual steps in the execution of machine language and the resulting changes to the state of machine are too small and too numerous.
9. In denotational semantics, what are the syntactic and semantic domains?  (Number 16)
– 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.
10. Which semantics approach is most widely known? (Number 18)
Denotational semantics.

Problem Sets (Randomly 10 of 28)

1. Syntax error and semantic error are two types of compilation error. Explain the difference between the two in a program with examples. (Number 1)
– Syntax error : if (a==1) b=2
example : syntax error : there’s no semicolon (;) at the end of the statement
Semantic error : for (int i=0;i<=n;i++) i–;
example : semantic error : basically a logical error
2. Rewrite the BNF of Example 3.4 to represent operator – and operator / instead of operator + and operator *. (Number 3)
<assign>-> <id> = <expr>
<id> -> A| B| C
<expr>-> <expr> -<term>
|<term>
<term>-> <term> / <factor>
| <factor>
<factor> -> (<expr>)
|<id>
3. Prove that the following grammar is ambiguous
<S> -> <A>
<S> -> <A> * <A> | <id>
<id> -> x | y | z (Number 8)
– If the grammar generates a different parse tree, then we can say the grammar is ambiguous. The grammar generates two different parse trees.
4. Modify the grammar of Example 3.4 to add a unary minus operator that has higher precedence than either + or *. (Number 9)
We can assume that the operators can precede any operand. And than we can replace the rule.
<factor> → <id> with <factor> → + <id> | – <id>
5. Describe, in English, the language defined by the following grammar :
<S> -> <X><Y>
<X> -> x<X> | x
<Y> -> y<Y> | y (Number 10)
One or more x’s followed by one or more y’s.
6. Consider the following grammar:
<S> → <A> a <B> b
<A> → <A> b | b
<B> → a <B> | a
Which of the following sentences are in the language generated by this grammar?
a. bbaabb
b. bbaba
c. bbaaaabb
d. abaabb (Number 11)
– The answer is
bbaabb and bbaaaabb (a and c)
7. Write a grammar for the language consisting of strings that have n copies of the letter a followed by double the number of copies of the letter b, where n>0. For example, the strings abb, aabbbb, aaaabbbbbbbb, are in the language but a, aabb, ba, and aaabb are not. (Number 13)
<S> -> a<S>bb | abb
8. Convert the BNF of Example 3.3 to EBNF. (Number 16)
<assign> → <id> = <expr>
<id> → A | B | C
<expr> → <expr> (+ | -) <expr>
| (<expr>)
| <id>
9. Convert the following EBNF to BNF:
S -> A{bA}
A -> a[b]A (Number 17)
<S> -> <A> | <S>b<A>
<A> -> a<A> | ab<A>
10. What is a fully attributed parse tree ? (Number 18)
A parse tree whose attributes have been computed.

## Chapter 2

Concepts of Programming Languages 10th Edition – Robert W. Sebesta
Page 127-131
Lecturer : Tri Djoko Wahjono

Review Questions (Randomly 23 of 69)

1. What does Plankalkul mean? (Number 3)
– Plankalkul means “plan kalkulus” which means “formal system for planning”.
2. What hardware capability that first appeared in the IBM 704 computer strongly affected the evolution of programming languages ? Explain why. (Number 6)
Its capabilities prompted the development of Fortran because it was able to support floating-point operations hardware.
3. Under what environmental consideration was Fortran developed? Which is the first version of Fortran? (Number 9)
The environment in which Fortran was developed was as follows : Computers had small memories and were slow and relatively unreliable, the primary use of computers was for scientific computations, there were no existing efficient and effective ways to program computers, and because of the high cost of computers compared to the cost of programmers. The first version of Fortran is Fortran 0.
4. Which version of Fortran was the first to have any sort of dynamic variables? (Number 12)
Fortran 90.
5. What are the different data types and structures in Common LISP? (Number 15)
Atoms and Lists.
6. What two professional organizations together designed ALGOL 60? (Number 18)
ACM and GAMM.
7. What language was designed to describe the syntax of ALGOL 60? (Number 21)
BNF Language.
8. What data structure that appeared in COBOL originated with Plankalkul? (Number 24)
Hierarchichal data structures (records).
9. Why was BASIC an important language in the early 1980s? (Number 27)
Its smaller dialects could be implemented on computers with very small memories.
10. What features of SIMULA 67 are now important parts of some object-oriented languages? (Number 30)
The important feature is Data abstraction.
11. What language introduced the case statement? (Number 33)
ALGOL-W language introduced the case statement.
12. Why is Prolog called a non-procedural language? (Number 36)
Because Prolog is concerned with the WHAT not the HOW. We have to specify what conditions the answer should satisfy, but not how to obtain it.
13. What are the concurrent program units of Ada called? (Number 39)
Tasks (using the rendezvous mechanism).
14. What three concepts are the basis for object-oriented programming? (Number 42)
Classes, Objects, and Methods.
15. What programming paradigm that nearly all recently designed languages support is not supported by Go? (Number 45)
Doesn’t support traditional object-oriented programming, as it has no form of inheritance.
16. What do the Ada and COBOL languages have in common? (Number 48)
Both were popularized by the Department of Defense.
17. How does the typing system of PHP and JavaScript differ from that of Java? (Number 51)
The dynamic nature of its strings and arrays, and its use of dynamic typing.
18. For what application area is JavaScript most widely used? (Number 54)
The application area is Web.
19. What data types does Java support? (Number 57)
Primitive data types and Reference/Object Data Types.
20. How does Java provide storage deallocation? (Number 60)
Java uses implicit storage deallocation for its objects, often called garbage collection.
21. What deficiency of the switch statement of C is addressed with the changes made by C# to that statement? (Number 63)
The complex structure within the switch body.
22. What is the output of an XSLT processor? (Number 66)
XML document.
23. What are .jsp files executed? (Number 69)
A servlet and is executed on a Web server system.

Problem Sets (Randomly 9 of 25)

1. What features of Fortran IV do you think would have had the greatest influence on Java if the Java designers had been familiar with Fortran? (Number 1)
I think it’s the ability to passing subprograms as parameters to other subprograms. The programmers are allowed to pass a class to another class as parameters and help them to integrate classes so the modularity in programming can be completed.
2. Write a short history of the Fortran 0, Fortran I, Fortran II, and Fortran IV systems. (Number 3)
– Fortran 0 was described in the IBM report titled “The IBM Mathematical FORmula TRANslating System : FORTRAN”. It was boldly stated that FORTRAN would provide the efficiency of hand-coded programs and the ease of programming of the interpretive pseudocode systems.
– Fortran I was described in October 1956. It included input/output formatting, variable names of up to six characters, and user-defined subroutines. The early success of Fortran I was shown in results of a survey made in April 1958. Most of the code written for 704s was being written in Fortran, despite skepticism of most programming world a year earlier.
– Fortran II compiler was distributed on 1958. It fixed many bugs in the Fortran I and added some significant features to the language, the most important being the independent compilation of subroutines. Few years after, it also added support for double precision and complex data types.
– Fortran IV was developed in 1961 and released in 1962. It became the most used programming language of its time. IT contains many improvements from Fortran II, like explicit type declarations for variables, logical if construct and capability of passing subprograms as parameters to other subprograms.
3. Which of the three original goals of the Fortran design committee, in your opinion, was most difficult to achieve at that time? (Number 5)
Speed of the generated object code. Because at that time, hardware performance is not reliable, provided that there was still no language design that allows a language to fully use hardware capabilities to the efficient point, unless the design was done from scratch / uses an existing design that must be able to do simple functions as primitive syntaxes.
4. LISP began as a pure functional language but gradually acquired more and more imperative features. Why? (Number 7)
John McCarthy’s original interest in developing LISP was to meet the demand for artificial intelligence as a functional programming language, but there soon emerged different dialects, cleaners, more modern, and more imperative, that began to deviate from the functional form into Scheme. COMMON LISP combined the different forms into a single form that was more imperative, including assignment and iteration.
5. Why, in your opinion, did Fortran allow names that began with I, J, K, L, M and N as implicitly integer type? (Number 9)
– According to its history, Fortran designers chose those letters because scientists and engineers used letters as variable subscripts, usually i, j, and k and the designers threw three additional letters. In my opinion, what Fortran did was acceptable, thinking i j k was used in math for describing units in vectors and those additional letters were just additional so it does not matter much.
6. Was IBM’s assumption, on which it based its decision to develop PL/I, correct, given the history of computers and language developments since 1964? (Number 11)
The design of PL/I was based on the premise that any construct that was useful and could be implemented should be included, with insufficient concern about how a programmer could understand and make effective use of such a collection of constructs and features. But it turns out PL/I included a larger number of data structures, which made it harder to learn and difficult to implement, but it obviously could not provide an appropriate data structure for every need.
7. What is the primary reason why C became more widely used than Fortran? (Number 13)
Fortran can’t allocate new variables or space during execution time. This made recursive subprograms to run and made it difficult to implement a data structure that change shape dinamically. Kinds of program being built were simpler than recent. Thus Fortran are not able to accomodate the requirements of recent software developments. But, C is able to cover most of Fortran’s weakness on developing software that has advanced requirements. That is why C is more widely used.
8. Are there any non-procedural programming languages other than Prolog? (Number 15)
Yes. Such as : C++, COBOL, Algol, Fortran, SQL or Visual Basic.
9. What are the limitations of language design by committee? Support your opinion. (Number 17)
Committees tend to yield inconsistent designs. But I think the problem is that they won’t take risks. When one person is in charge he can take risks that a committee would never agree on. In everything else people do, reward is proportionate to risk. That’s why language design should be any different.
Posted in KBP | 3 Comments

## Chapter 1

Concepts of Programming Languages 10th Edition – Robert W. Sebesta
Page 52-54
Lecturer : Tri Djoko Wahjono

Review Questions (Randomly 10 of 30)

1. How can knowledge of programming language characteristic benefit the whole computer community? (Number 2)
– Programming language characteristic is a profound of it’s own understanding. If the programmers understand each of the programming language characteristic, they could create a more effective and efficient programming language which affects the whole computer community.
2. What programming language has dominated business applications over the past 50 years? (Number 4)
– COBOL.
3. In what language is UNIX written? (Number 6)
– C.
4. How can user-defined operator overloading harm the readability of a program? (Number 8)
If the operations are used in odd unintuitive ways.
5. What language used orthogonality as a primary design choice? (Number 10)
– Algol 68.
6. What construct of a programming language provides process abstraction? (Number 12)
Subprograms.
7. Why is type checking the parameter of a subprogram important? (Number 14)
It can lead to lots of hard to debug errors.
8. What is exception handling? (Number 16)
The ability of a program to intercept run time errors.
9. How is the cost of compilers for a given language related to the design of that language? (Number 18)
Many run time checks will prohibit fast code execution. If optimization is used compiling will be slower but execution will be faster.
10. What is the name of the category of programming languages whose structure is dictated by the von Neumann computer architecture? (Number 20)
Imperative languages.

Problem Sets (Randomly 6 of 18)

1. Who is said to be the first programmer in human history? Use the Internet for help. (Number 2)
The first computer programmer in human history was Lord Byron’s Daughter Ada Lovelace.
2. In what way do the languages for scientific applications differ from the languages for business applications? Support your view. (Number 4)
The way they’re different is that the languages for scientific applications uses relatively simple data structure while the languages for business applications is typically used for producing elaborate reports.
3. Which characteristics of programming languages do you think are the most important and why? (Number 6)
I think the most important characteristic is Reliability, because it performs to its specifications under all conditions. That conditions include Readability, Writability, Type Checking, Exception Handling, and Aliasing.
4. Most languages use functions and subroutines. What are the pros and cons of this design decision ? (Number 8)
The pros of using functions and subroutines are that the programmer doesn’t need to code the similar code multiple times instead allowing the programmer to use the code multiple times, the function could also be used by other programmer without needing to worries about the stack of the same variables. The cons are most of the function can only return one value, prone to errors if not coded properly.
5. Make a comparative study of the cost of software and hardware. (Number 10)
The cost of software and hardware depend on the performance, usage, etc. As for hardware only need to cost once whereas for the software cost could be expensive depending on the user’s need.
6. Can we call any programming language complete, in your opinion? Why or why not? (Number 12)
I don’t think any programming language could be called complete, because each programming language has their own superiority and flaw. Some will effective using a certain programming language, and some don’t.
Posted in KBP | 6 Comments