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.


16. What is exception handling ?
Exception handling is ability of a program to intercept run time errors as well other unusual conditions, take corrective / repairing measures then resume its function.

17. Why is readability important to writability ?
Readability affects whether it is possible to read a written program and how easy to read and user friendly a code is. A program that is easy to read means it is also easy to maintain the program in case of errors and also makes it easy to write the program. Readibility is very important when we as a programmers work on a team, so that our code can be read easily by another programmers.

18. How is the cost of compilers for a given language related to the design of that language ?
The cost of compilers for a given language is influenced by that language’s design. A language that needs many run-time type checks will execute slower regardless of the quality of the compiler. The execution efficiency is now considered less important

19. What have been the strongest influences on programming language design over the past 50 years ?
The shift in major cost of computing from hardware to software. The cost of hardware decreased and programmer cost increased, while th increase of productivity were relatively small. In addition, larger and more complex problems were solved by computers, such as providing airline reservation system.

20. What is the name of the category of programming languages whose structure is dictated by the von Neumann computer architecture ?
A language is called Imperative if it is designed around the prevalent computer architecture. In von Neumann computer, both data and programs are stored in the same memory. While The CPU is separated. Therefore, the instructions and data must be transmitted to the CPU and sent back to the memory after it is processed in the CPU

21. What two programming language deficiencies were discovered as a result of the research in software development in the 1970s ?
The deficiencies of the programming language found in the research were incompeteness of type checking, and inadequacy of control statements (requiring extensive of gotos)

22. What are the three fundamental features of an object-oriented programming language ?
-Encapsulation, which encapsulates processing with data objects and controls access to data

-Inheritance is a powerful concept that greatly enhances the potential reuse of existing software, thereby providing the possibility of significant increases in software development productivity

-Dynamic method binding is a method that allows more flexible use of inheritance

23. What language was the first to support the three fundamental features of object-oriented programming ?
Smalltalk is the first object-oriented programming language that supports its concepts. It was designed and created at LRG of Xerox PARC during 1970s. In smalltalk, there’s no difference between values which are objects and values which are primitive types.

25. What are the three general methods of implementing a programming language ?
– Compilation is the method of implementation that translate programs into machine language that can be executed directly on the computer. Compilation has the advantage of very fast program execution once the translation is complete.

– Pure Interpretation is method of implementation by using another program called interpreter to interpret a program with no translation whatsoever. The interpreter program acts as a software simulation of a machine whose fetch-execute cycle deals with high-level language program statements rather than machine instructions

– Hybird Implementation system is a method to implement a program by translating highlevel language programs into an intermediate language designed to allow easy interpretation. This method is faster than pure interpretation because the source language statements are decoded only once.

26. Which produces faster program execution, a compiler or a pure interpreter ?
Compiler is faster than a pure interpreter. It is because a compiler translates the whole code into machine language then executes it, while pure interpreter translates each statement to machine code each time the statement is executed.

28. What is the utility of byte code ?
Byte code provides portability to any machine that has a byte code interpreter and an associated run-time system. Together, these are called the Java Virtual Machine.

30. What are the advantages of using Borland Jbuilder ?
Borland JBuilder is a programming environment that provides an integrated compiler, editor, debugger, and file system for Java development, where all four are accessed through a graphical interface. JBuilder is a complex and powerful system for creating Java software.



Problem Set


1. Do you believe that solving a problem in a particular algorithmic step requires programming language skills ? Support your opinion!
Yes, I do believe. Because it is not useful if we just know the algorithm, but cannot applicable that algorithm to solve particular problem. Programming language skill is the way to implement our algorithm to solve problems.


2. Who is said to be the first programmer in human history ? use the Internet for help.
Ada Lovelace is said to be the first programmer in human history. She was an English mathematician and a writer. Her notes on the engine include what is recognized as the first algorithm intended to be the process of machine. So she is considered to be the first programmer in the world.


3. What are the disadvantages of multiple programming languages ?
The programmer needs to adaptation on every programming environment and indeed it will take time, also the programmer must know a lot of syntax that usually different one another.


4. In what way do the languages for scientific applications differ from the languages for web software ? Support your view.
Languages for scientific applications uses simple data structures, but requires large numbers of floating-point arithmetic computations. The most common data structure were arrays and matrices, while the most common control structures were counting loops and selections. Language for business applications is oriented on special english like statements that has the ability to produce elaborate reports, precise ways of describing and storing decimal numbers and character data, and the ability to specifiy decimal arithmetic operations


6. Which characteristics of programming languages do you think are the most important and why ?
I think, the most important is reliability. A programming language must be reliable, it needs to check every line of code is running properly without having memory leak.

7. Java uses a semicolon to mark the end of all statements. What are the advantages for and against this design ?
The advantages of this design make interpreter easy to knowing whether it is a line of statement or not. It also allows compilers to quickly recognize line of statements and also enhances readability of the language. Otherwise, the disadvantage is that the semicolon cannot be used for another purposes but, to end a line of statement.


15. Name some languages which use preprocessor directive and some which don’t. What are the advantage and disadvantages of preprocessor directive?
C and C++ programming languages use preprocessor directive while Java is not using preprocessor directive. 
 Advantages: Preprocessor makes us be able to include another code that has been written by another programmers to linking with our code. So, it will reduce compiling time, reduce program length and save time in defining a lot of function.
Disadvantages:  The disadvantage of the macro is the size of the program. The reason is, the pre-processor will replace all the macros in the program by its real definition prior to the compilation process of the program.


1 comments:

  1. Hello, i think that i saw you visited my web site so i came to “return the favor”.
    I'm attempting to find things to enhance my site!I suppose its ok to use a few of your ideas!!

    Feel free to surf to my web page :: pokemon games mmo

    ReplyDelete