ICS-2204-PPL Main
ICS-2204-PPL Main
QUESTION TWO
a) Explain four aspects of readability (8 marks)
b) State and defend 4 arguments against having a single language for all domains (8 marks)
c) Explain one advantage and disadvantage of having typeless language (4marks)
QUESTION THREE
a) Explain three aspects of writability (6 marks)
b) State three language requirements for implementing Abstract Data Types (3 marks)
c) In object oriented languages there are three ways a subclass can differ from its parent.
Outline them. (3 marks)
d) Draw and explain the Stack Allocation Scheme diagram used in activation record (8 marks)
QUESTION FOUR
a) Explain four aspects of reliability (8 marks)
b) State and expound on two properties of pure functions (6 marks)
c) Define ‘State typechecking’ and explain why it is better than dynamic typechecking. (4 marks)
d) Distinguish between data abstraction and control abstraction (2 marks)
QUESTION FIVE
a) Differentiate between static semantics and dynamic semantics. (4 marks)
b) State and explain 5 programing language categories, giving an example to each (10marks)
QUESTION ONE:
QUESTION TWO
Repeated practice: It cultivate a style of programming and code writing, the purpose of
which is to ensure the clarity, clarity and artistry of the program or code
Refinement and optimization of the code: Involves thinking and solving the same specific
problem from different methods, and finding the most effective code through comparative
analysis and temporal and spatial examination.
Use of some pre-compilation processing operations: that is, file inclusion, macro definition
and conditional compilation, etc., to ensure better readability of the program in large-scale
complex programs
Notes or instructions to the program: So that people who read the program can better
understand.
Simplicity and Orthogonality
– Few constructs, a small number of primitives, a small set of rules for
combining them
Support for abstraction
– The ability to define and use complex structures or operations in ways that
allow details to be ignored
Expressivity
– A set of relatively convenient ways of specifying operations
– Example: the inclusion of for statement in many modern languages
2b) Arguments against the idea of a single language for all programming domains
The language would necessarily be huge and complex
Compilers would be expensive and costly to maintain
The language would probably not be very good for any programming domain, either in
compiler efficiency or in the efficiency of the code it generated.
More importantly, it would not be easy to use, because regardless of the application area, the
language would include many unnecessary and confusing features and constructs meant for
other application areas.
Different users would learn different subsets, making maintenance difficult.
QUESTION THREE
3a) aspects of writability:
Simplicity and Orthogonality
– Few constructs, a small number of primitives, a small set of rules for
combining them
Support for abstraction
– The ability to define and use complex structures or operations in ways that
allow details to be ignored
Expressivity
– A set of relatively convenient ways of specifying operations
– Example: the inclusion of for statement in many modern languages
Stack Pointer (SP) − It points to the activation record of the currently active procedure.
In the figure, procedure C is currently an active procedure. So, pointer SP will point to the
activation record for C.
Pointer SP on activation record for procedure C contains the value of old SP.
The space for global data is fixed and statically allocated at the corner of the stack.
Actual Parameter− It is used by the calling procedure to supply parameters to the called
procedure.
Return value: This field is used by the called procedure to return a value to the calling
procedure.
QUESTION FOUR
4a) Aspects of reliability
Type checking
– Testing for type errors
Exception handling
– Intercept run-time errors and take corrective measures
Aliasing
– Presence of two or more distinct referencing methods for the same memory location
Optimize Code Efficiency
– Code that is efficient and executes quickly takes additional skills, achieved by the use of loops,
arrays, and use of Boolean functions.
4b) properties of pure functions
The function always returns the same value for the same inputs. A pure function’s return
value is based only on its inputs and has no other dependencies or effects on the overall
program. For any given input, a pure function must return exactly one possible value.
Evaluation of the function has no side effects. Side effects refer to changing other attributes of
the program not contained within the function, such as changing global variable values or using
I/O streams.
4c) Definition of static type checking and why it’s better than dynamic type checking.
Static type checking is a type checking performed at compile time. It checks the type variables
at compile-time, which means the type of the variable is known at the compile time.
With static type checking, the type of variable is known at compile time (it checks the type of
variable before running) while with dynamic type checking, the type of variable is known at
runtime (it checks the type of variable while executing).
4d) Data abstraction is a set of data that specifies and describes a data object, while Control
abstraction is a program control mechanism where interior details are not specified.
QUESTION FIVE
5a) In static semantics, knowing the meaning of a sentence amounts to knowing when it is true;
in dynamic semantics, knowing the meaning of a sentence means knowing "the change it brings
about in the information state of anyone who accepts the news conveyed by it."