Binus Alam Sutera

Binus Alam Sutera

Tuesday, September 30, 2014

Chapter 2 Answers

Nama : Christian Gunawan
NIM : 1801384174


Post kali ini berisi tentang Assignment #2 dari chapter 2 Programming Language Concepts R Sebesta E- Book :

Review Questions #6 - 10 :
6. What hardware capability that first appeared in the IBM 704 computer strongly affected the evolution of programming languages? Explain why.

One of the greatest single advances in computing came with the introduction of the IBM 704 in 1954, in large measure because its capabilities prompted the development of Fortran.

The announcement of the IBM 704 system, with both indexing and floating-point instructions in hardware, heralded the end of the interpretive era, at least for scientific computation. The inclusion of floating-point hardware removed the hiding place for the cost of interpretation.

7. In what year was the Fortran design project begun?

Before the 704 system was announced in May 1954, plans were begun for Fortran. By November 1954, John Backus and his group at IBM had produced the report titled “The IBM Mathematical FORmula TRANslating System: FORTRAN” (IBM, 1954).

This document described the first version of Fortran, which we refer to as Fortran 0, prior to its implementation.


8. What was the primary application area of computers at the time Fortran was designed?

Computer's application at the time Fortran was designed (in general) was for scientific computations only.

Here was the detailed conditions when Fortran was designed :
(1) Computers had small memories and were slow and relatively unreliable;
(2) The primary use of computers was for scientific computations;
(3) There were no existing efficient and effective ways to program computers; and
(4) Because of the high cost of computers compared to the cost of programmers, speed of the generated object code was the primary goal of the first Fortran compilers.


9. What was the source of all of the control flow statements of Fortran I?

All of Fortran I’s control statements were based on 704 instructions. It is not clear whether the 704 designers dictated the control statement design of Fortran I or whether the designers of Fortran I suggested these instructions to the 704 designers.


10. What was the most significant feature added to Fortran I to get Fortran II?

The Fortran II compiler was distributed in the spring of 1958. It fixed many of the bugs in the Fortran I compilation system and added some significant features to the language, the most important being the independent compilation of subroutines.



Problem set #6 - 10 :
6. Make an educated guess as to the most common syntax error in LISP programs.

The most common syntax error in LISP programs is probably the Incorrect placement or Number of parentheses.


7. LISP began as a pure functional language but gradually acquired more and more imperative features. Why?

Because most programming has been done in the imperative style, we have many good imperative algorithms. For example, the Sieve of Eratosthenes is an efficient way to find the primes up to some maximum number.

If you look at the book on functional algorithms and data structures written by Chris Okasaki (an extension of his Ph.D. thesis), you'll see that coming up with efficient functional algorithms seems to be harder than coming up with imperative algorithms of the same "big Oh" complexity. Dr. Okasaki's work is also pretty recent.

So in order to build efficient code (e.g. all the '70s AI work that used LISP), different LISP implementations provided more and more imperative features. The Common Lisp standard is big - it combines the features of many of those LISP implementations and provides something like 1,500 functions for you in the standard.


8. Describe in detail the three most important reasons, in your opinion, why ALGOL 60 did not become a very widely used language.
The Algol 60 language and report included several mathematical symbols which are available on modern computers and operating systems, but, unfortunately, were not supported on most computing systems at the time,and resulting ALGOL 60 didn't become a very widely used language.


9. Why, in your opinion, did COBOL allow long identifiers when Fortran and ALGOL did not?

COBOL is more of a reporting language than Fortran. Since Fortran handles calculations much better, there is not a real need for long identifiers. As a reporting language, COBOL uses long identifiers in tagging the source to the reports it is writing. Also, COBOL is the closest language to a fully, self documenting language, that it gets, and long identifiers provides one more case for it.

10. Outline the major motivation of IBM in developing PL/I.

In early 1963 when the PL/I story begins, Business applications people began to use regression analysis to build management information systems, which required floating-point data and arrays.

It began to appear that computing installations would soon require two separate computers and technical staffs, supporting two very different programming languages.

Thursday, September 25, 2014

Chapter 1 Answers

Nama : Christian Gunawan 
NIM : 1801384174

Kali ini saya akan menjawab Assignment #1 dari chapter 1 Programming Language Concepts R Sebesta E-book :

Review Questions : #6-10
6. In what language is most of UNIX written?

The UNIX operating system is written almost entirely in C (ISO, 1999),
which has made it relatively easy to port, or move, to different machines. Some of the characteristics of C make it a good choice for systems programming. It is low level, execution efficient, and does not burden the user with many safety restrictions.


7. What is the disadvantage of having too many features in a language?

Many features now available in programming languages were not widely known at the time. The result is that many programmers, hard to adapt to a new language and when given a choice of languages for a new project,they use the language with which they are most familiar, even if it is poorly suited for the project at hand.


8. How can user-defined operator overloading harm the readability of a program?

Operator overloading makes single operator symbol has more than one meaning. Although this is often useful, it can lead to reduced readability if users are allowed to create their own overloading and do not do it sensibly.


9. What is one example of a lack of orthogonality in the design of C?

As examples of the lack of orthogonality in C that Although C has two kinds of structured data types, arrays and records (structs), records can be returned from functions but arrays cannot.

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

Functional languages offer a good combination of simplicity and orthogonality. 
A functional language, such as LISP, is one in which computations are made primarily by applying functions to given parameters.



Problem Set : #6-10
6. What common programming language statement, in your opinion, is most detrimental to readability?

I think rarely-stated statement or strange data types and syntax designs that makes the user and computer's readability low.

7. Java uses a right brace to mark the end of all compound statements. What are the arguments for and against this design?

C and its descendants (Java) use braces to specify compound statements. All of these languages suffer because statement groups are always terminated in the same way, which makes it difficult to determine which group is being ended when an end or a right brace appears.

Fortran 95 and Ada make this clearer by using a distinct closing syntax for each type of statement group. For example, Ada uses end if to terminate a selection construct and end loop to terminate a loop construct.


8.Many languages distinguish between uppercase and lowercase letters in user-defined names. What are the pros and cons of this design decision?

Pros : So that variable identifiers may look different than identifiers that are names for constants, such as the convention of using upper case for constant names and using lowercase for variable names in C.

Cons : The primary reason why a language would not distinguish between uppercase and lowercase in identifiers is it makes programs less readable. because words that look very similar are actually completely different, such as set and SET


9. Explain the different aspects of the cost of a programming language.

First, there is the cost of training programmers to use the language, which is a function of the simplicity and orthogonality of the language and the experience of the programmers.

Second, there is the cost of writing programs in the language. This is a function of the writability of the language, which depends in part on its closeness in purpose to the particular application.

Third, there is the cost of compiling programs in the language. A major impediment to the early use of Ada was the prohibitively high cost of running the first-generation Ada compilers.

Fourth, the cost of executing programs written in a language is greatly influenced by that language’s design. A language that requires many run-time type checks will prohibit fast code execution, regardless of the quality of the compiler.

The fifth factor in the cost of a language is the cost of the language implementationsystem. One of the factors that explains the rapid acceptance of Java is that free compiler/interpreter systems became available for it soon after its design was released.

Sixth, there is the cost of poor reliability. If the software fails in a critical system, such as a nuclear power plant or an X-ray machine for medical use, the cost could be very high.

The final consideration is the cost of maintaining programs, which includes both corrections and modifications to add new functionality. The cost of software maintenance depends on a number of language characteristics, primarily readability.

10. What are the arguments for writing efficient programs even though hardware is relatively inexpensive?

One of the main arguments is that regardless of the cost of hardware, it is not free. Why write a program that executes slower than is necessary. Furthermore, the difference between a well-written efficient program and one that is poorly written can be a factor of two or three. In many other fields of endeavor, the difference between a good job and a poor job may be 10 or 20 percent. In programming, the difference is much greater.


Bonus Question:
1.What's the difference between "Imperative Language" and "Procedural Language"?


Imperative Language is any programming language that specifies explicit manipulation of the state of the computer system, not to be confused with a procedural language,which specifies an explicit sequence of steps to perform. 


An example of an imperative (but non-procedural) language is a data manipulation language for a relational database management system. Thisspecifies changes to the database but does not necessarily require anyoneto specify a sequence of steps.
Both contrast with declarative languages, which specify neither explicitstate manipulation nor a sequence of steps. 


Procedural language, as the name implies, relies on predefined and well-organized procedures, functions or sub-routines in a program’s architecture by specifying all the steps that the computer must take to reach a desired state or output. 
Procedural language segregates a program within variables, functions, statements and conditional operators. Procedures or functions are implemented on the data and variables to perform a task.
Procedural language is one of the most common programming languages in use with notable languages such as C/C++, Java, ColdFusion and PASCAL.