hi
Yin and Yang Surfboard

Minggu, 19 Oktober 2014

Chapter 1 : Preliminaries


From Book : Concept Of Programming  Languages 
By : Robert W. Sebesta


REVIEW QUESTION :

16. What is exception handling ?
Answer :
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.
Exception handling is the process of responding to the occurrence, during computation, of exceptions – anomalous or exceptional events requiring special processing – often changing the normal flow of program execution. It is provided by specialized programming language constructs or computer hardware mechanisms.
In general, an exception is handled (resolved) by saving the current state of execution in a predefined place and switching the execution to a specific subroutine known as an exception handler. If exceptions are continuable, the handler may later resume the execution at the original location using the saved information. For example, a floating point divide by zero exception will typically, by default, allow the program to be resumed, while an out of memory condition might not be resolvable transparently.

17. Why is readability important to writability ?
Answer :
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.

Read More


18. How is the cost of compilers for a given language related to the design of that language ?
Answer :
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 ?
Answer :
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 ?
Answer :
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.



PROBLEM SET :

14. Describe the advantages and disadvantages of some programming environment you have used
Answer :
Java – Works best as a high level Enterprise Web applications.
Advantages: Huge, Robust, Infinitely scalable for web applications, high level, marketable skill, mixes with xml like peanut butter and jelly, platform independent, will handle all the hardware you can throw at it, A lot of code that you need is usually already published and free on the Internet.
Disadvantages: May not be suited for low level programming. A resource hog. May not perform well on older computers. May be overly complex for very small programs.
ActionScript – Works best for animating movies, adds and cool applications that work as if they are applications on the computer, but the application plays inside the browser.
Advantages: Can get visual and interactive effects like no other language within a web browser. Highly marketable skills. A lot of pizazz, most people use it on the index.html page for commercial web sites.
Disadvantage: Not really suited for non web applications. Not suited for low level programming. This language resides inside of html code mainly. Does not venture from there.
C++ – Best suited for general purpose and low level programming.
Advantages: Extremely fast, works very well for GUI programming on a computer. Good language to write operating systems, drivers, and platform dependent applications with. Good language to learn to program with. Good language for engineers.
Disadvantages: Although it is platform independent, it is mostly used for platform specific applications. A library set is usually chosen that locks you into a single platform or operating system. Overly complex for very large high level programs. Overly complex and difficult to debug when used for web applications. Marketable skills are low level programming, vendor software, and video games, making it difficult to find jobs unless you have are very advanced in a target area.
C# – new language to take advantage of C++ foundation and add new features.
Advantages: Can be used for web applications on Microsoft computers. Works well with the Microsoft product line. Marketable skill set.
Disadvantages: Almost completely locks you into the Microsoft Platform. New language, so not a great deal of published free code yet.
VB – Used mainly to modify and complement the Microsoft product line.
Advantages: Extremely easy to use, even for people who are not computer programmers. Allows the typical computer user to modify MS Office applications to suite their needs. Works very well on a Microsoft intranet to complement the network shares and permissions. Can be used for low level programming on Microsoft computers. A marketable skill set. Excellent for writing little programs and pieces of programs.
Disadvantages: Completely locks you into using the Microsoft product line. Not a true Object oriented language although it claims to be. VB .Net is an object oriented language. Becomes overly complex and difficult to manage on very large programs.


15. How do type declaration statements for simple variables affect the readability of a language, considering that some languages do not require them? 
Answer :
The use of type declaration statements for simple scalar variables may have very little effect on the readability of programs. If a language has no type declarations at all, it may be an aid to readability, because regardless of where a variable is seen in the program text, its type can be determined without looking elsewhere. Unfortunately, most languages that allow implicitly declared variables also include explicit declarations. In a program in such a language, the declaration of a variable must be found before the reader can determine the type of that variable when it is used in the program.

16. Write an evaluation of some programming language you know, using the criteria described in this chapter.
Answer :
Java has some issues with simplicity with respect to readability. There is feature multiplicity in Java as shown in the textbook, example count=count + 1, count ++, count +=1 and ++count. Control statements in Java have higher readibility than BASIC and Fortran because they can use more complex conditionals like for loops
Writability
Java has a fair bit of orthogonality in that its primitive constructs can be used in various different ways
Reliability
Java uses a type checker at compile time which virtually eliminate most of the type errors during run time

17. Some programming languages—for example, Pascal—have used the semicolon to separate statements, while Java uses it to terminate state-ments. Which of these, in your opinion, is most natural and least likely to result in syntax errors? Support your answer.
Answer :
Personally i feel that pascal’s usage of the semicolon to separate statements is rather counterintuitive but possibly it’s because I learned the usage of semicolon to terminate statements in C before I learned pascal. In pascal one needs to look ahead and identify weather or not the next line is a statements before putting a semicolon. For example if use had a program in pascal that had a simple if statements.
If x = 0 then
Answer:=1;
Then in pascal if you wanted to add an else clause you would have to go back and delete the semicolon because an else clause is not considered a new statements.
If x = 0 then
Answer:=1
Else
Answer:=2;
Some pascal compilers will catch wrongly placed semicolons and declare them as errors. It also means that a programmer needs to be able to recognize what is and what is not a statements thus it hurts writability. Of course, other requirements in java such us the usage of parenthesis around the conditional or the usage of braces around the compound statements can also be confusing. However i think it’s easier to remember not to put a semicolon after a right braces than it is to have to watch out for not putting it after each statements. The relative consistency of java is more intuitive than the structural of pascal.

18. Many contemporary languages allow two kinds of comments: one in which delimiters are used on both ends (multiple-line comments), and one in which a delimiter marks only the beginning of the comment (oneline comments). Discuss the advantages and disadvantages of each of these with respect to our criteria.
Answer :
The main disadvantage of using paired delimiters for comments is that it results in diminished reliability. It is easy to inadvertently leave off the final delimiter, which extends the comment to the end of the next comment, effectively removing code from the program. The advantage of paired delimiters is that you can comment out areas of a program. The disadvantage of using only beginning delimiters is that they must be repeated on every line of a block of comments. This can be tedious and therefore errorprone. The advantage is that you cannot make the mistake of forgetting the closing delimiter.

Tidak ada komentar:

Posting Komentar