Monday, September 29, 2014

Assignment 1

Hai semua. Welcome to my blog :)

Blog ini ditulis atas permintaan dosen terkece saya Mr. Tri Djoko Wahjono, yang mengajar mata kuliah Konsep Bahasa Pemrograman di Binus University, khususnya di kampus Alam Sutera, Tangerang.

Pada post kali ini, saya akan menjawab pertanyaan-pertanyaan Assignment #1 dari Chapter 1, dari buku "Concepts of Programming Languages" karya Robert W. Sebesta.

Review Questions

        1. In what language is most of UNIX written ?
The UNIX operating system was first written in assembly language, but by 1973 had been almost entirely coded in C language. Why in C language? It is a good choice to use C language for system programming because of its low level, execution efficient and also, C language does not burden the user with many safety restrictions.

        2. What is the disadvantage of having too many features in a language ?
If there’s too many features then the simplicity of reading a program will be lost. And it will be more difficult to create a documentation of a language, as there is usually more than one programmer working on a program.

        3. How can user-defined operator overloading harm the readability 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. For example, a user defines “&” to mean the logical operator. Other person who read the program could think that & is the address of a variable just like in C. It would make the code hard to understand and even it would make a compiler catch an error when the functions of “&” gets mixed up.

        4. What is one example of a lack of orthogonality in the design of C ?
In case structured data type (record and array), record can be returned from function but arrays can’t.

        5. What language used orthogonality as a primary design criterion ?
It is ALGOL 68. Every language construct in ALGOL 68 has its own type, and there’s no restriction on those types. In addition, most of the constructs produce values. This allows extremely complex code to be implemented.

Problem Sets

        6. What common programming language statement, in your opinion, is most detrimental to readability?
randomly, poorly-written, and undocumented code will be extremely hard to follow. But a well written, well commented code, should have a good readability for those who are fluent in the language that being used.

        7. Java uses a right brace to mark the end of all compound statements. What are the arguments for and against this design ?
  • Arguments for using the right brace
In Java, a right brace always used to terminate a compound, so it's relative simpe.
  • Arguments againts using the right brace
When you see a right brace in a program, the location of its matching left brace is not always obvious, because all multiple-statement control constructs end with a right brace.

        8. Many languages distinguish between uppercase and lowercase letters in user-defined names. What are the pros and cons of this design decision?
  • The pros
To differentiate between the variable identifiers and the identifiers for constants. For example, in C, the convention of using uppercase for constant names and using lowercase for variable names.
  • The cons
It decrease programs readability, because the variables that has the same spelling are actually have a completely different meaning in programming language, for example, SUM and sum are different.

        9. Explain the different aspects of the cost of a programming language.
The different aspects of the cost of programming languages lies in their complexities. The complexities of the data structure and data type are the cost of programming language.

        10. What are the arguments for writing efficient programs even though hardware is relatively inexpensive?
One of the main arguments is that even though hardware is relatively inexpensive, 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.


Extra Question

What is the difference between imperative language and procedural language?

Imperative language is a type of programming language that use computation as statements and directly change a program state. Imperative language main characteristics are direct assignments, common data structures, and global variables. Examples of imperative programming language : C, C++, Java, PHP, Python.
Procedural language (derived from structured programming), is based on the concept of modular programming or the procedure call. Procedural language main characteristics are local variables, sequence, selection, iteration, and modularization. Examples of procedural programming language : C, C++, Lisp, PHP, Pyton.

No comments:

Post a Comment