tag:blogger.com,1999:blog-27824744023390979982024-03-12T23:44:06.096-07:00My First Blog!Ryanhttp://www.blogger.com/profile/09159563307966653917noreply@blogger.comBlogger16125tag:blogger.com,1999:blog-2782474402339097998.post-37537028592216822082013-06-27T05:45:00.002-07:002013-06-27T05:45:47.628-07:00Concepts of Programming Languages Assignment - Chapter 15<b>Review Questions</b><br />
<br />
<i>2. What does a lambda expression specify?</i><br />
The predicate function is often given as a lambda expression, which in
ML is defined exactly like a function, except with the fn reserved word,
instead of fun, and of course the lambda expression is nameless.<br />
<br />
<i>5. Explain why QUOTE is needed for a parameter that is a data list.</i><br />
To avoid evaluating a parameter, it is first given as a parameter to the
primitive function QUOTE, which simply returns it without change.<br />
<br />
<i>6. What is a simple list?</i><br />
A list which membership of a given atom in a given list that does not include sublists.<br />
<br />
<i>7. What does the abbreviation REPL stand for?</i><br />
REPL stand for read-evaluate-print loop.<br />
<br />
<i>11. What are the two forms of DEFINE?</i><br />
The simplest form of DEFINE is one used to bind a name to the value of an expression. This form is<br />
(DEFINE symbol expression)<br />
The general form of such a DEFINE is<br />
(DEFINE (function_name parameters)<br />
(expression)<br />
)<br />
<br />
<i>13. Why are CAR and CDR so named?</i><br />
The names of the CAR and CDR functions are peculiar at best. The origin
of these names lies in the first implementation of LISP, which was on an
IBM 704 computer. The 704’s memory words had two fields, named
decrement and address, that were used in various operand addressing
strategies. Each of<br />
these fields could store a machine memory address. The 704 also included
two machine instructions, also named CAR (contents of the address part
of a register) and CDR (contents of the decrement part of a register),
that extracted the associated fields. It was natural to use the two
fields to store the two pointers<br />
of a list node so that a memory word could neatly store a node. Using
these conventions, the CAR and CDR instructions of the 704 provided
efficient list selectors. The names carried over into the primitives of
all dialects of LISP.<br />
<br />
<i>18. What is tail recursion? Why is it important to define
functions that use recursion to specify repetition to be tail recursive?</i><br />
A function is tail recursive if its recursive call is the last operation
in the function. This means that the return value of the recursive call
is the return value of the nonrecursive call to the function. It is
important to specify repetition to be tail recursive because it is more
efficient(increase the efficiency).<br />
<br />
<i>19. Why were imperative features added to most dialects of LISP?</i><br />
LISP began as a pure functional language but soon acquired some
important imperative features to increased its execution efficiency.<br />
<br />
<i>26. What is type inferencing, as used in ML?<br />
</i>Type inference refers to the automatic deduction of the type of an
expression in a programming language. If some, but not all, type
annotations are already present it is referred to as type
reconstruction.<br />
<br />
<i>29. What is a curried function?</i><br />
Curried functions a function which a new functions can be constructed from them by partial evaluation.<br />
<br />
<i>30. What does partial evaluation mean?</i><br />
Partial evaluation means that the function is evaluated with actual
parameters for one or more of the leftmost formal parameters.<br />
<br />
<i>32. What is the use of the evaluation environment table?</i><br />
A table called the evaluation environment stores the names of all
implicitly and explicitly declared identifiers in a program, along with
their types. This is like a run-time symbol table.<br />
<br />
<i>33. Explain the process of currying.</i><br />
The process of currying replaces a function with more than one parameter
with a function with one parameter that returns a function that takes
the other parameters of the initial function.<br />
<br />
<b>Problem Set</b>
<br />
<br />
<i>8. How is the functional operator pipeline ( |> ) used in F#?</i><br />
The pipeline operator is a binary operator that sends the value of
its left operand, which is an expression, to the last parameter of the
function call, which is the right operand. It is used to chain together
function calls while flowing the data being processed to each call.<br />
<br />
<i>9. What does the following Scheme function do?</i><br />
(define ( y s lis)<br />
(cond<br />
(( null? lis) ‘ () )<br />
((equal? s (car lis)) lis)<br />
(else (y s (cdr lis)))<br />
))<br />
y returns the given list with leading elements removed up to but not
including the first occurrence of the first given parameter.<br />
<br />
<i>10.What does the following Scheme function do?</i><br />
(define ( x lis)<br />
(cond<br />
(( null? lis) 0 )<br />
(( not(list? (car lis)))<br />
(cond<br />
((eq? (car lis) #f) (x (cdr lis)))<br />
(else (+1 (x (cdr lis))))))<br />
(else (+ (x (car lis)) (x (cdr lis))))<br />
x returns the number of non-#f atoms in the given listRyanhttp://www.blogger.com/profile/09159563307966653917noreply@blogger.com0tag:blogger.com,1999:blog-2782474402339097998.post-11695555654709113352013-06-27T05:43:00.000-07:002013-06-27T05:43:23.613-07:00Concepts of Programming Languages Assignment - Chapter 14<b>Review Questions</b><br />
<br />
<i>1. Define exception, exception handler, raising an exception,
disabling an exception, continuation, finalization, and built-in
exception.</i><br />
An exception is an unusual event that is detectable by either
hardware or software and that may require special processing. The
special processing that may be required when an exception is detected is
called exception handling. The processing is done by a code unit
or segment called an exception handler. An exception is raised when its
associated event occurs. In some situations, it may be desirable to
ignore certain hardware-detectable exceptions—for example, division by
zero—for a time. This action would be done by disabling the exception.
After an exception handler executes, either control can transfer to
somewhere in the program outside of the handler code or<br />
Program
execution can simply terminate. We term this the question of control
continuation after handler execution, or simply continuation. In some
situations, it is necessary to complete some computation regardless of
how subprogram
execution terminates. The ability to specify such a computation is
called finalization. Built-in exceptions have a built-in meaning, it is
generally inadvisable to use these to signal program-specific error
conditions. Instead we introduce a new exception using an exception
declaration, and signal it using a raise expression when a run-time
violation occurs. That way we can associate specific exceptions with
specific pieces of code, easing the process of tracking down the source
of the error.<br />
<br />
<i>7. Where are unhandled exceptions propagated in Ada if raised in a subprogram?</i><br />
<i>
</i><i>A block? A package body? A task?</i><br />
When an exception is raised in a block, in either its declarations or
executable statements, and the block has no handler for it, the
exception is propagated to the next larger enclosing static scope,
which is the code that “called” it. The point to which the exception is
propagated is just after the end of the block in which it occurred,
which is its “return” point. When an exception is raised in a package
body and the package body has no handler for the exception, the
exception is propagated to the declaration section of the unit
containing the package declaration. If the package happens to be a
library unit (which is separately compiled), the program is terminated.<br />
If an exception occurs at the outermost level in a task body (not in a
nested block) and the task contains a handler for the exception, that
handler is executed and the task is marked as being completed. If the
task does not have a handler for the exception, the task is simply
marked as being completed; the exception is not propagated. The control
mechanism of a task is too complex to lend itself to a reasonable and
simple answer to the question of where its unhandled exceptions should
be propagated.<br />
<br />
<i>10. What are the four exceptions defined in the Standard package of Ada?</i><br />
The four exception defined in the standard package of Ada are Constraint_Error, Program_Error, Storage_Error, Tasking_Error<br />
<br />
<i>11. What is the use of suppress pragma in Ada?</i><br />
An Ada pragma is a directive to the compiler. Certain run-time checks
that are parts of the built-in exceptions can be disabled in Ada
programs by use of the Suppress pragma, the simple form of which is
pragma Suppress(check_name)<br />
where check_name is the name of a particular exception check. The
Suppress pragma can appear only in declaration sections. When it
appears, the specified check may be suspended in the associated block or
program unit of which the declaration section is a part. Explicit
raises are not affected by Suppress. Although it is not required, most
Ada compilers implement the Suppress pragma.<br />
<br />
<i>13. Describe three problems with Ada’s exception handling.</i><br />
There are several problems with Ada’s exception handling. One problem
is the propagation model, which allows exceptions to be propagated to
an outer scope in which the exception is not visible. Also, it is not
always possible to determine the origin of propagated exceptions.
Another problem is the inadequacy of exception handling for tasks. For
example, a task that raises an exception but does not handle it simply
dies. Finally, when support for object-oriented programming was added in
Ada 95,
its exception handling was not extended to deal with the new
constructs. For example, when several objects of a class are created and
used in a block and one of them propagates an exception, it is
impossible to determine which one raised the exception.<br />
<br />
<i>14. What is the name of all C++ exception handlers?</i><br />
Each catch function is an exception handler. A catch function can have only a single formal parameter,
which is similar to a formal parameter in a function definition in C++,
including the possibility of it being an ellipsis (. . .). A handler
with an ellipsis formal parameter is the catch-all handler; it is
enacted for any raised exception if no appropriate handler was found.
The formal parameter also can be a naked type specifier, such as float,
as in a function prototype. In such a case, the only purpose of the
formal parameter is to make the handler uniquely identifiable. When
information about the exception is to be passed to the handler, the
formal parameter includes a variable name that is used for that purpose.
Because the class of the parameter can be any user-defined class, the
parameter can include as many data members as are<br />
necessary.<br />
<br />
<i>15. Which standard libraries define and throw the exception out_of_range in C++?</i><br />
The exception out_of_range in C++ thrown by library container classes<br />
<br />
<i>16. Which standard libraries define and throw the exception overflow_error in C++?</i><br />
the exception overflow_error in C++ thrown by math library functions<br />
<br />
<i>19. State the similarity between the exception handling mechanism in C++ and Ada</i><br />
In some ways, the C++ exception-handling mechanism is similar to that
of Ada. For example, unhandled exceptions in functions are propagated
to the function’s caller.<br />
<br />
<i>20. State the differences between the exception handling mechanism in C++ and Ada</i><br />
There are no predefined hardware-detectable exceptions that can be
handled by the user, and exceptions are not named. Exceptions are
connected to handlers through a parameter type in which the formal
parameter may be omitted. The type of the formal parameter of a handler
determines the condition under which it is called but may have nothing
whatsoever to do with the nature of the raised exception.<br />
<br />
<i>24. What is the difference between checked and unchecked exceptions in Java?</i><br />
Exceptions of class Error and RuntimeException and their descendants
are called unchecked exceptions. All other exceptions are called checked
exceptions. Unchecked exceptions are never a concern of the compiler.
However, the compiler ensures that all checked exceptions a method can
throw are either listed in its throws clause or handled in the method.
Note that checking this at compile time differs from C++, in which it is
done at run time. The reason why exceptions of the classes Error and
RuntimeException and their descendants are unchecked is that any method
could throw them. A program can catch unchecked exceptions, but it is
not required.<br />
<br />
<i>26. How can an exception handler be written in Java so that it handles any exception?</i><br />
The exception handlers of Java have the same form as those of C++,
except that every catch must have a parameter and the class of the
parameter must be a descendant of the predefined class Throwable. The
syntax of the try construct in Java is exactly as that of C++, except
for the finally clause.<br />
<br />
<i>28. What is the purpose of Java finally clause?</i><br />
A finally clause is placed at the end of the list of handlers just
after a complete try construct. The semantics of this construct is as
follows: If the try clause throws no exceptions, the finally clause is
executed before execution continues after the try construct. If the try
clause throws an exception and it is caught by a following handler, the
finally clause is executed after the handler completes its execution. If
the try clause throws an exception but it is not caught by a handler
following the try construct, the finally clause is executed before the
exception is propagated<br />
<br />
<b>Problem Set</b>
<br />
<br />
<i>1 . What mechanism did early programming languages provide to detect or attempt to deal with errors?</i><br />
Early programming languages were designed and implemented in such a way that the user program<br />
could neither detect nor attempt to deal with such errors. In these
languages, the occurrence of such an error simply causes the program to
be terminated and control to be transferred to the operating system. The
typical operating system reaction to a run-time error is to display a
diagnostic message, which may be meaningful and therefore useful, or
highly cryptic. After displaying the message, the program is terminated.<br />
<br />
<i>2. Describe the approach for the detection of subscript range errors used in C and Java.</i><br />
Java compilers usually generate code to check the correctness of
every subscript expression (they do not generate such code when it can
be determined at compile time that a subscript expression cannot have an
out-of-range value, for example, if the subscript is a literal).<br />
In C, subscript ranges are not checked because the cost of such
checking was (and still is) not believed to be worth the benefit of
detecting such errors. In some compilers for some languages, subscript
range checking can be selected (if not turned on by default) or turned
off (if it is on by default) as desired in the program or in the command
that executes the compiler.<br />
<br />
<i>5. From a textbook on FORTRAN, determine how exception handling is done in FORTRAN programs.</i><br />
For example, a Fortran “Read” statement can intercept inputerrors and
end-of-file conditions, both of which are detected by the input device
hardware. In both cases, the Read statement can specify the label of
some statement in the user program that deals with the condition. In the
case of the end-of-file, it is clear that the condition is not always
considered an error. In most cases, it is nothing more than a signal
that one kind of processing is completed and another kind must begin. In
spite of the obvious difference between end-of-file and events that are
always errors, such as a failed input process, Fortran handles both
situations with the same mechanism.<br />
<br />
<i>6. In languages without exception-handling facilities, it is
common to have most subprograms include an “error” parameter, which can
be set to some value representing “OK” or some other value representing
“error in procedure”. What advantage does a linguistic
exception-handling facility like that of Ada have over this method?</i><br />
There are several advantages of a linguistic mechanism for handling
exceptions, such as that found in Ada, over simply using a flag error
parameter in all subprograms. One advantage is that the code to test the
flag after every call is eliminated. Such testing makes programs longer
and harder to read. Another advantage is that exceptions can be
propagated farther than one level of control in a uniform and implicit
way. Finally, there is the advantage that all programs use a uniform
method for dealing with unusual circumstances, leading to enhanced
readability.<br />
<br />
<i>7. In a language without exception handling facilities, we could
send an error-handling procedure as a parameter to each procedure that
can detect errors that must be handled. What disadvantages are there to
this method?</i><br />
There are several disadvantages of sending error handling subprograms
to other subprograms. One is that it may be necessary to send several
error handlers to some subprograms, greatly complicating both the
writing and execution of calls. Another is that there is no method of
propagating exceptions, meaning that they must all be handled locally.
This complicates exception handling, because it requires more attention
to handling in more places.Ryanhttp://www.blogger.com/profile/09159563307966653917noreply@blogger.com0tag:blogger.com,1999:blog-2782474402339097998.post-4997906152227900982013-06-27T05:40:00.001-07:002013-06-27T05:40:53.587-07:00Concepts of Programming Languages Assignment - Chapter 13<strong>Review Questions</strong><br />
<br />
<i>1. What are the three possible levels of concurrency in programs?</i><br />
Concurrency in software execution can occur at four different levels:
instruction level (executing two or more machine instructions
simultaneously), statement level (executing two or more high-level
language statements simultaneously), unit level (executing two or more
subprogram units simultaneously), and program level (executing two or
more programs simultaneously).<br />
<br />
<i>2. Describe the logical architecture of an SIMD computer.</i><br />
In an SIMD computer, each processor has its own local memory. One
processor controls the operation of the other processors. Because all of
the processors, except the controller, execute the same instruction at
the same time, no synchronization is required in the software. Perhaps
the most widely used<br />
SIMD machines are a category of machines called vector processors.
They have groups of registers that store the operands of a vector
operation in which the same instruction is executed on the whole group
of operands simultaneously. Originally, the kinds of programs that could
most benefit from this architecture were in scientific computation, an
area of computing that is often the target of multiprocessor machines.
However, SIMD processors are now used for a variety of application
areas, among them graphics and video processing. Until recently, most
supercomputers were vector processors.<br />
<br />
<i>3. Describe the logical architecture of an MIMD computer.</i><br />
Computers that have multiple processors that operate independently
but whose operations can be synchronized are called Multiple-Instruction
Multiple- Data (MIMD) computers. Each processor in an MIMD computer
executes its own instruction stream. MIMD computers can appear in two
distinct configurations: distributed and shared memory systems. The
distributed MIMD machines, in which each processor has its own memory,
can be either built in a single chassis or distributed, perhaps over a
large area. The shared-memory MIMD machines obviously must provide some
means of synchronization to prevent memory access clashes. Even
distributed MIMD machines require synchronization to operate together on
single programs. MIMD computers, which are more general than SIMD
computers, support unit-level concurrency. The primary focus of this
chapter is on language design for shared memory MIMD computers, which
are often called multiprocessors.<br />
<br />
<i>4. What level of program concurrency is best supported by SIMD computers?</i><br />
Statement-level concurrency<br />
<br />
<i>5. What level of program concurrency is best supported by SIMD computers?</i><br />
Unit-level concurrency<br />
<br />
<i>6. Describe the logical architecture of a vector processor.</i><br />
Vector processor have groups of registers that store the operands of a
vector operation in which the same instruction is executed on the whole
group of operands simultaneously. Originally, the kinds of programs
that could most benefit from this architecture were in scientific
computation, an area of computing that is often the target of
multiprocessor machines.<br />
<br />
<i>7. What is the difference between physical and logical concurrency?</i><br />
There are two distinct categories of concurrent unit control. The
most natural category of concurrency is that in which, assuming that
more than one processor is available, several program units from the
same program literally execute simultaneously. This is physical concurrency.
A slight relaxation of this concept of concurrency allows the
programmer and the application software to assume that there are
multiple processors providing actual concurrency, when in fact the
actual execution of programs is taking place in interleaved fashion on a
single processor. This is logical concurrency.<br />
<br />
<i>8. what is the work of a scheduler?</i><br />
A run-time system program called a scheduler<b> </b>manages the sharing of processors among the tasks.<br />
<br />
<i>34. What does the Java sleep method do?</i><br />
The sleep method has a single parameter, which is the integer number
of milliseconds that the caller of sleep wants the thread to be blocked.
After the specified number of milliseconds has passed, the thread will
be put in the task-ready queue. Because there is no way to know how long
a thread will be in the task-ready queue before it runs, the parameter
to sleep is the minimum amount of time the thread will <i>not </i>be in execution. The sleep method can throw an InterruptedException, which must be handled in the method that calls sleep.<br />
<br />
<i>35. what does the Java yield method do?</i><br />
The yield method, which takes no parameters, is a request from the
running thread to surrender the processor voluntarily. The thread is put
immediately in the task-ready queue, making it ready to run. The
scheduler then chooses the highest-priority thread from the task-ready
queue. If there are no other ready threads with priority higher than the
one that just yielded the processor, it may also be the next thread to
get the processor.<br />
<br />
<i>36. what does the Java join method do?</i><br />
The join method is used to force a method to delay its execution
until the run method of another thread has completed its execution. join
is used when the processing of a method cannot continue until the work
of the other thread is complete.<br />
<br />
<i>37. What does the Java interrupt method do?</i><br />
The interrupt method is one way to communicate to a thread that it
should stop. This method does not stop the thread; rather, it sends the
thread a message that actually just sets a bit in the thread object,
which can be checked by the thread. The bit is checked with the
predicate method, isInterrupted. This is not a complete solution,
because the thread one is attempting to interrupt may be sleeping or
waiting at the time the interrupt method is called, which means that it
will not be checking to see if it has been interrupted. For these
situations, the interrupt method also throws an exception,
InterruptedException, which also causes the thread to awaken (from
sleeping or waiting). So, a thread can periodically check to see whether
it has been interrupted and if so, whether it can terminate. The thread
cannot miss the interrupt, because if it was asleep or waiting when the
interrupt occurred, it<br />
will be awakened by the interrupt.<br />
<br />
<i>42. What kind of Java object is a monitor?</i><br />
In Java, a monitor can be implemented in a class designed as an
abstract data type, with the shared data being the type. Accesses to
objects of the class are controlled by adding the synchronized<b> </b>modifier to the access methods.<br />
<br />
<i>47. How are explicit locks supported in Java?</i><br />
Java 5.0 introduced explicit locks as an alternative to synchronized<b> </b>method
and blocks, which provide implicit locks. The Lock interface declares
the lock, unlock, and tryLock methods. The predefined ReentrantLock
class implements the Lock interface. To lock a block of code, the
following idiom can be used:<br />
Lock lock = new ReentrantLock();<br />
. . .<br />
Lock.lock();<br />
try<b> </b>{<br />
// The code that accesses the shared data<br />
} finally<b> </b>{<br />
Lock.unlock();<br />
}<br />
<br />
<i>48. What kinds of methods can run in a C# thread?</i><br />
Rather than just methods named run, as in Java, any C# method can run in its own thread.<br />
<br />
<i>55. What is Concurrent ML?</i><br />
Concurrent ML (CML) is an extension to ML that includes a form of
threads and a form of synchronous message passing to support
concurrency. The language is completely described in Reppy (1999).<br />
<br />
<i>59. Who developed the monitor concept?</i><br />
The monitor concept is developed and its implementation in Concurrent Pascal is described by Brinch Hansen (1977)<br />
<br />
<strong>Problem Set</strong><br />
<br />
<i>1 . Explain why a race condition can create problems for a system.</i><br />
a race condition creates problem because when a race condition
happens two or more tasks are racing to use the shared resource and the
behavior of the program depends on which task arrives first (and wins
the race).<br />
<br />
<i>2. What are the different ways to handle deadlock?</i><br />
When deadlock occurs, assuming that only two program units are
causing the deadlock, one of the involved program units should be
gracefully terminated, thereby allowed the other to continue.<br />
<br />
<i>3. Busy waiting is a method whereby a task waits for a given
event by continuously checking for that event to occur. What is the main
problem with this approach?</i><br />
The main problem with busy waiting is that machine cycles are wasted in the process.<br />
<br />
<i>4. In the producer-consumer example of Section 13.3, suppose
that we incorrectly replaced the release(access) in the consumer process
with wait(access). What woud be the result of this error on execution
of the system?</i><br />
Deadlock would occur if the release(access) were replaced by a
wait(access) in the consumer process, because instead of relinquishing
access control, the consumer would wait for control that it already had.Ryanhttp://www.blogger.com/profile/09159563307966653917noreply@blogger.com0tag:blogger.com,1999:blog-2782474402339097998.post-1038253319921689522013-06-27T05:37:00.000-07:002013-06-27T05:37:20.016-07:00Concepts of Programming Languages Assignment - Chapter 12<b>Review Questions</b><br />
<br />
<i>4. What is message protocol?</i><br />
Message protocol is the entire collection of methods of an object.<br />
<br />
<i>5. What is an overriding method?</i><br />
Overriding method is method that overrides the inherited method.<br />
<br />
<i>7. What is dynamic dispatch?</i><br />
Dynamic dispatch is the third characteristic (after abstract data
types and inheritance) of object-oriented programming language which is a
kind of polymorhphism provided by the dynamic binding of messages to
method definitions.<br />
<br />
<i>12. From where are Smalltalk objects allocated?</i><br />
Smalltalk objects are allocated from the heap and are referenced through reference variables, which are implicitly dereferenced.<br />
<br />
<i>15. What kind of inheritance, single or multiple, does Smalltalk support?</i><br />
Smalltalk supports single inheritance; it does not allow multiple inheritance.<br />
<br />
<i>19. How are C++ heap-allocated objects deallocated?</i><br />
C++ heap-allocated objects are deallocated using destructor.<br />
<br />
<i>29. Does Objective-C support multiple inheritance?</i><br />
No Objective-C doesn’t support it. (It supports only single inheritance).<br />
<br />
<i>33. What is the purpose of an Objective-C category?</i><br />
The purpose of an Objective-C category is to add certain
functionalities to different classes and also to provide some of the
benefits of multiple inheritance, without the naming collisions that
could occur if modules did not require module names on their functions.<br />
<br />
<i>38. What is boxing?</i><br />
Boxing is primitive values in Java 5.0+ which is implicitly coerced
when they are put in object context. This coercion converts the
primitive value to an object of the wrapper class of the primitive
value’s type.<br />
<br />
<i>39. How are Java objects deallocated?</i><br />
By implicitly calling a <i>finalize</i>method when the garbage collector is about to reclaim the storage occupied by the object.<br />
<br />
<b>Problem Set</b>
<br />
<br />
<i>3. Compare the inheritance of C++ and Java.</i><br />
<i>
</i>- In Java, all classes inherit from the Object class directly or
indirectly. Therefore, there is always a single inheritance tree of
classes in Java, and Object class is root of the tree. In Java, if we
create a class that doesn’t inherit from any class then it automatically
inherits from Object Class. In C++, there is forest of classes; when we
create a class that doesn’t inherit from anything, we create a new tree
in forest.<br />
- In Java, members of the grandparent class are not directly accessible.<br />
- The meaning of protected member access specifier is somewhat
different in Java. In Java, protected members of a class “A” are
accessible in other class “B” of same package, even if B doesn’t inherit
from A (they both have to be in the same package)<br />
- Java uses <i>extends </i>keyword for inheritence. Unlike C++, Java
doesn’t provide an inheritance specifier like public, protected or
private. Therefore, we cannot change the protection level of members of
base class in Java, if some data member is public or protected in base
class then it remains public or protected in derived class. Like C++,
private members of base class are not accessible in derived class.<br />
Unlike C++, in Java, we don’t have to remember those rules of
inheritance which are combination of base class access specifier and
inheritance specifier.<br />
- In Java, methods are virtual by default. In C++, we explicitly use virtual keyword.<br />
<b>- </b>Java uses a separate keyword <i>interface </i>for interfaces, and <i>abstract </i>keyword for abstract classes and abstract functions.<br />
- Unlike C++, Java doesn’t support multiple inheritance. A class
cannot inherit from more than one class. A class can implement multiple
interfaces though.<br />
<b>– </b>In C++, default constructor of parent class is automatically
called, but if we want to call parametrized constructor of a parent
class, we must use Initalizer list. Like C++, default constructor of the
parent class is automatically called in Java, but if we want to call
parametrized constructor then we must use super to call the parent
constructor<br />
<br />
<i>5. Compare abstract class and interface in Java.</i><br />
- First and major difference between abstract class and interface is
that, abstract class is a class while interface is a interface, means by
extending abstract class you can not extend another class becauseJava
does not support multiple inheritance but you can implement multiple
inheritance in Java.<br />
- Second difference between interface and abstract class in Java is
that you can not create non abstract method in interface, every method
in interface is by default abstract, but you can create non abstract
method in abstract class. Even a class which doesn’t contain any
abstract method can be abstract by using abstract keyword.<br />
- Third difference between abstract class and interface in Java is
that abstract class are slightly faster than interface because interface
involves a search before calling any overridden method in Java. This is
not a significant difference in most of cases but if you are writing a
time critical application than you may not want to leave any stone
unturned.<br />
- Fourth difference between abstract class vs interface in Java is
that, interface are better suited for Type declaration and abstract
class is more suited for code reuse and evolution perspective.<br />
- Another notable difference between interface and abstract class is
that when you add a new method in existing interface it breaks all its
implementation and you need to provide an implementation in all clients
which is not good. By using abstract class you can provide default
implementation in super class.<br />
<br />
<i>7. What is one programming situation where multiple inheritance has a significant disadvantage over interfaces?</i><br />
A situation when there are two classes derived from a common parent and those two derived class has one child.<br />
<br />
<i>9. Give an example of inheritance in C++, where a subclass overrides the superclass methods.</i><br />
class plan{<br />
public:<br />
void fly(){<br />
cout << “fly” << endl;<br />
}<br />
};<br />
class jet:public class plan{<br />
public:<br />
void fly()<br />
{<br />
cout << “Fly! Rocket jet activated!” << endl;<br />
}<br />
}<br />
<br />
<i>10. Explain one advantage of inheritance.</i><br />
Inheritance offers a solution to both the modification problem posed
by abstract data type reuse and the program organization problem. If a
new abstract data type can inherit the data and functionality of some
existing type, and is also allowed to modify some of those entities and
add new entities, reuse and is also allowed to modify some of those
entities and add new entities, reuse is greatly facilitated without
requiring change to the reused abstract data type. Programmers can begin
with an existing abstract data type and design a modified descendant of
it to fit a new problem requirement. Furthermore, inheritance provides a
framework for the definition of hierarchies of related classes that can
reflect the descendant relationship in the problem space.<br />
<br />
<i>12. Compare inheritance and nested classes in C++. Which of these supports an is-a relationship?</i><br />
Inheritance is where one class (child class) inherits the members of
another class (parent class).Nested class is a class declared entirely
within the body of another class or interface.<br />
Inheritance does.<br />
<br />
<i>17. What are the different options for object destruction in Java?</i><br />
There is no explicit deallocation operator. A finalize method is
implicitly called when the garbage collector is about to reclaim the
storage occupied by the object.Ryanhttp://www.blogger.com/profile/09159563307966653917noreply@blogger.com0tag:blogger.com,1999:blog-2782474402339097998.post-12558944503416246322013-06-27T05:34:00.003-07:002013-06-27T05:34:44.955-07:00Concepts of Programming Languages Assignment - Chapter 11<b>Review question</b><br />
<br />
<i>2. Define <span style="color: black;">abstract data type.</span></i><br />
<span style="color: black;">data type that satisfies the following conditions:</span><br />
-The representation of objects of the type is hidden from the program
units that use the type, so the only direct operations possible on
those objects are those provided in the type’s definition.<br />
-The declarations of the type and the protocols of the operations on
objects of the type, which provide the type’s interface, are contained
in a single syntactic unit. The type’s interface does not depend on the
representation of the objects or the implementation of the operations.
Also, other program units are allowed to create variables of the defined
type.<br />
<br />
<i>8. What is the difference between private and limited private types in <span style="color: black;">Ada?</span></i><br />
Limited private is more restricted form and objects of a type that is declared limited private have no built-in operations.<br />
<br />
<i>10. What is the use of the Ada with clause?</i><br />
With clause makes the names defined in external packages visible; in
this case Ada. Text_IO, which provides functions for input of text.<br />
<br />
<i>11. What is the use of the Ada use clause?</i><br />
The with clause makes the names defined in external packages Visible.<br />
<br />
<i>12. What is the fundamental difference between a C++ class and an Ada package?</i><br />
Ada packages are more generalize encapsulations that can define any number of types.<br />
<br />
<i>15. What is the purpose of a C++ destructor?</i><br />
The purpose of a C++ desctructor is as a debugging aid, in which case
they simply display or print the values of some or all of the object’s
data members before those members are deallocated.<br />
<br />
<i>16. What are the legal return types of a desctructor?</i><br />
Destructor has no return types and doesn’t use return statements.<br />
<br />
<i>20. What is the use of limited private types?</i><br />
An alternative to private types is a more restricted form: limited
private types. Nonpointer limited private types are described in the
private section of a package specification, as are nonpointer private
types. The only syntactic difference is that limited private types are
declared to be limited private in the visible part of the package
specification. The semantic difference is that objects of a type that is
declared limited private have no built-in operations. Such a type is
useful when the usual predefined operations of assignment and comparison
are not meaningful or useful. For example, assignment and comparison
are rarely used for stacks.<br />
<br />
<i>21. What are initializers in <span style="color: black;">Objective-C?</span></i><br />
The initializers in Objective-C are constructors.<br />
<br />
<i>22. What is the use of @private and @public directives?</i><br />
The use is to specify the access levels of the instance variables in a <span style="color: black;">class definition.</span><br />
<br />
<i>27. Where are all Java methods defined?</i><br />
All Java methods are defined in a class.<br />
<br />
<i>30. What is a friend function? What is a <span style="color: black;">friend class?</span></i><br />
a “friend” of a given class is allowed access to public, private, or
protected data in that class. Normally, function that is defined outside
of a class cannot access such information.<br />
Class that can access the private and protected members of the class
in which it is declared as a friend. On declaration of friend class all <span style="color: black;">member function of the friend class become friends of the class in which the friend class was declared.</span><br />
<br />
<b>Problem set</b><br />
<br />
<i>4. What are the advantages of the nonpointer concept in Java?</i><br />
Any task that would require arrays, structures, and pointers in C can
be more easily and reliably performed by declaring objects and arrays
of objects. Instead of complex pointer manipulation on array pointers,
you access arrays by their arithmetic indices. The Java run-time system
checks all array indexing to ensure indices are within the bounds of the
array. You no longer have dangling pointers and trashing of memory
because of incorrect pointers, because there are no pointers in Java.<br />
<br />
<i>10. Which two conditions make data type “abstract”?</i><br />
The representation of objects of the type is hidden from the program
units that use the type, so the only direct operations possible on those
objects are those provided in the type’s definition.<br />
The declarations of the type and the protocols of the operations on
objects of the type, which provide the type’s interface, are contained
in a single syntactic unit. The type’s interface does not depend on the
representation of the objects or the implementation of the operations.
Also, other program units are allowed to create variables of the defined
type.<br />
<br />
<i>12. How are classes in Ruby made dynamic?</i><br />
Classes in Ruby are dynamic in the sense that members can be added at
any time. This is done by simply including additional class definitions
that specify the new members. Moreover, even predefined classes of the
language, such as String, can be extended.<br />
<br />
<i>13. Compare and contrast the data abstraction of Java and C++.</i><br />
Java support for abstract data types is similar to that of C++. There
are, however, a few important differences. All objects are allocated
from the heap and accessed through reference variables. Methods in Java
must be defined completely in a class. A method body must appear with
its corresponding method<br />
header. Therefore, a Java abstract data type is both declared and
defined in a single syntactic unit. A Java compiler can inline any
method that is not overridden. Definitions are hidden from clients by
declaring them to be private. Rather than having private and public
clauses in its class definitions, in Java <span style="color: black;"><span style="color: black;">access modifiers</span>
can be attached to method and variable definitions. If an instance
variable or method does not have an access modifier, it has package
access.</span><br />
<br />
<i>19. Compare Java’s packages with <span style="color: black;">Ruby’s modules.</span></i><br />
In Ruby, the require statement is used to import a package or a module. For example, the extensions package/module is imported as follows.<br />
require ‘extensions’<br />
External files may be included in a Ruby application by using load or require. For example, to include the external file catalog.rb, add the following require statement.<br />
require “catalog.rb”<br />
The difference between load and require is that load includes the specified Ruby file every time the method is executed and require includes the Ruby file only once.<br />
In Java, the import statement is used to load a package. For example, a <span style="color: black;">Java package java.sql is loaded as follows.</span><br />
import java.sql.*;Ryanhttp://www.blogger.com/profile/09159563307966653917noreply@blogger.com0tag:blogger.com,1999:blog-2782474402339097998.post-8648297253810088992013-06-27T05:30:00.002-07:002013-06-27T05:30:35.031-07:00Concepts of Programming Languages Assignment - Chapter 10<b>Review Questions</b><br />
<br />
<i>1. What are the two reasons why implementing subprograms with
stack-dynamic local variables is more difficult than implementing simple
sub-programs?</i><br />
<ul>
<li>A stack-dynamic local variable is more complex activation records.
The compiler must generate code to cause implicit allocation and
de-allocation of local variables</li>
<li>Recursion must be supported (adds the possibility of multiple simultaneous activations of a subprogram).</li>
</ul>
<i>2. What is the difference between an activation record and activation record instance?</i><br />
The Format, or layout, of the non-code part of a subprogram is called an activation record.<br />
An activation record stores all the information about subprogram
calls, activation records stores the following data (in the following
order)<br />
<ul>
<li>Return address</li>
<li>Static link – to the static parent (where the subprogram is declared).</li>
<li>Dynamic link – to the caller of this subprogram.</li>
<li>Parameters</li>
<li>Local variables.</li>
</ul>
<i>4. What are the two steps in locating a nonlocal variable in a
static-scoped language with stack-dynamic local variables and nested
subprograms?</i><br />
<ul>
<li>Find the correct activation record instance</li>
<li>Determine the correct offset within that activation record instance</li>
</ul>
<i>5. Define static chain, static depth, nesting_depth, and chain offset.</i><br />
A static chain is a chain of static links that connects certain activation record instances<br />
Static_depth is an integer associated with a static scope representing the scope’s nesting depth<br />
The chain_offset or nesting_depth of a non-local reference is the
difference between the static_depth of the reference and that of the
scope where it is declared<br />
<br />
<i>6. What are the two potential problems with the static chain methods?</i><br />
<ul>
<li>A nonlocal reference is slow if the number of scopes between the
reference and the declaration of the referenced variable is large</li>
<li>Time-critical code is difficult, because the costs of nonlocal
references are not equal, and can change with code upgrades and fixes</li>
</ul>
<i>7. What is display?</i><br />
One alternative to static chain is to use a display, for this
approach, the static links are collected in a single array called a
display. Display uses a pointer array to store the activation records
along the static chain.<br />
<br />
<i>10. Explain the two methods of implementing block?</i><br />
Blocks are treated as parameter less subprograms that are always called from the same place in the program.<br />
Block can also be implemented in a different and somewhat simpler and
more efficient way. The maximum amount of storage required for block
variables at any time during the exaction of program can be statically
determined, because block are entered and exited in strictly textual
order.<br />
<br />
<i>11. Describe the deep access method of implementing dynamic scoping?</i><br />
Deep Access – nonlocal references are found by searching the
activation record instances on the dynamic chain. Length of chain cannot
be statically determined every activation record instance must have
variable names<br />
<br />
<i>12. Describe the shallow access method of implementing dynamic scoping?</i><br />
In case of shallow access names and values are stored in a global
table. Using this method, space is allocated for every variable name
that is in the program (one space for variable temp though there might
be several declarations of temp in the different methods). When a
sub-routine is called it saves the current value of the variable and
replaces it with the value in its current scope and restores the value
of the variable while exiting.<br />
<br />
<i>14. Compare the efficiency of the deep access method to that of the
shallow access method, in term of both call and nonlocal access?</i><br />
The deep access methods provides fast subprogram linkage, but
references to nonlocal, especially references to distant nonlocals (in
term of the call chain), are costly. The shallow access methods provide
much faster references to nonlocals, especially distant nonlocals, but
are more costly in term of subprogram linkage.<br />
<br />
<b>Problem Set</b>
<br />
<br />
<i>7. It stated in this chapter that when nonlocal variables are
accessed in a dynamic-scoped language using the dynamic chain, variable
names must be stored in the activation records with the values. If this
were actually done, every nonlocal access would require a sequence of
costly string comparisons on names. Design an alternative to these
string comparisons that would be faster.</i><br />
One very simple alternative is to assign integer values to all
variable names used in the program. Then the integer values could be
used in the activation records, and the comparisons would be between
integer values, which are much faster than string comparisons.<br />
<br />
<i>8. Pascal allows gotos with nonlocal targets. How could such
statements be handled if static chains were used for nonlocal variable
access?</i><br />
Following the hint stated with the question, the target of every goto
in a program could be represented as an address and a nesting_depth,
where the nesting_depth is the difference between the nesting level of
the procedure that contains the goto and that of the procedure
containing the target. Then, when a goto is executed, the static chain
is followed by the number of links indicated in the nesting_depth of the
goto target. The stack top pointer is reset to the top of the
activation record at the end of the chain.<br />
<br />
<i>9. The static-chain method could be expanded slightly by using two
static links in each activation record instance where the second
points to the static grandparent activation record instance. How would
this approach affect the time required for subprogram linkage and
nonlocal references?</i><br />
Including two static links would reduce the access time to nonlocals
that are defined in scopes two steps away to be equal to that for
nonlocals that are one step away. Overall, because most nonlocal
references are relatively close, this could significantly increase
the execution efficiency of many programs.<br />
<br />
<i>11. If a compiler uses the static chain approach to implementing
blocks, which of the entries in the activation records for subprograms
are needed in the activation records for blocks?</i><br />
There are two options for implementing blocks as parameterless
subprograms: One way is to use the same activation record as a
subprogram that has no parameters. This is the most simple way, because
accesses to block variables will be exactly like accesses to local
variables. Of course, the space for the static and dynamic links and the
return address will be wasted. The alternative is to leave out the
static and dynamic links and the return address, which saves space but
makes accesses to block variables different from subprogram locals.Ryanhttp://www.blogger.com/profile/09159563307966653917noreply@blogger.com0tag:blogger.com,1999:blog-2782474402339097998.post-53269745078670910052013-06-27T05:26:00.000-07:002013-06-27T05:26:49.566-07:00Concepts of Programming Languages Assignment - Chapter 9<strong>Review Questions</strong><br />
<br />
<i>1. What are the three general characteristics of subprograms?</i><br />• Each subprogram has a single entry point.<br />• The calling program unit is suspended during the execution of the called<br />subprogram, which implies that there is only one subprogram in execution<br />at any given time.<br />• Control always returns to the caller when the subprogram execution<br />terminates.<br />
<br />
<i>2. What does it mean for a subprogram to be active?</i><br />A subprogram is said to be active if, after having been called, it has begun execution but has not yet completed that execution.<br />
<br />
<i>3. What is given in a header of a subprogram?</i><br />A
subprogram header, which is the first part of the definition, serves
several purposes. First, it specifies that the following syntactic unit
is a subprogram definition of some particular kind.1 In languages that
have more than one kind of subprogram, the kind of the subprogram is
usually specified with a special word. Second, if the subprogram is not
anonymous, the header provides a name for the subprogram. Third, it may
optionally specify a list of parameters.<br />
<br />
<i>4. What characteristic of Python subprograms sets them apart from those of other languages?</i><br />One
characteristic of Python functions that sets them apart from the
functions of other common programming languages is that function def
statements are executable. When a def statement is executed, it assigns
the given name to the given function body. Until a function’s def has
been executed, the function cannot be called. Consider the following
skeletal example:<br />if . . .<br />def fun(. . .):<br />. . .<br />else<br />def fun(. . .):<br />. . .<br />
<br />
<i>5. What languages allow a variable number of parameters?</i><br />C# allows methods to accept a variable number of parameters, as long as they are of the same type.<br />
<br />
<i>6. What is a Ruby array formal parameter?</i><br />Ruby
supports a complicated but highly flexible actual parameter
configuration. The initial parameters are expressions, whose value
objects are passed to the corresponding formal parameters. The initial
parameters can be following by a list of key => value pairs, which
are placed in an anonymous hash and a reference to that hash is passed
to the next formal parameter. These are used as a substitute for keyword
parameters, which Ruby does not support. The hash item can be followed
by a single parameter preceded by an asterisk. This parameter is called
the array formal parameter.<br />
<br />
<i>23. What is Automatic Generalization?</i><br />The type
inferencing system of F# is not always able to determine the type of
parameters or the return type of a function. When this is the case, for
some functions, F# infers a generic type for the parameters and the
return value. This is called automatic generalization.<br />
<br />
<i>24. What is an overloaded subprogram?</i><br />An overloaded subprogram is a subprogram that has the same name as another subprogram in the same referencing environment.<br />
<br />
<i>25. What is ad hoc binding?</i><br />Ad hoc binding is when the environment of the call statement that passed the subprogram as an actual parameter.<br />
<br />
<i>26. What is multicast delegate?</i><br />All of the
methods stored in a delegate instance are called in the order in which
they were placed in the instance. This is called a multicast delegate.<br />
<br />
<i>30. What are the design issues for functions?</i><br />The following design issues are specific to functions:<br />• Are side effects allowed?<br />• What types of values can be returned?<br />• How many values can be returned?<br />
<br />
<i>31. What two languages allow multiple values to be returned from a function?</i><br />Ruby allows the return of more than one value from a method. Lua also allows functions to return multiple values.<br />
<br />
<strong>Problem Set</strong><br />
<i>3. Argue in support of the template functions of C++. How is it different from the template functions in other languages?</i><br />C++
templated classes are instantiated to become typed classes at compile
time. For example, an instance of the templated Stack class, as well as
an instance of the typed class, can be created with the following
declaration:<br />Stack<int> myIntStack;<br />However, if an instance
of the templated Stack class has already been created for the int type,
the typed class need not be created.<br />
<br />
<i>6 . Compare and contrast PHP’s parameter passing with that of C#.</i><br />PHP’s
parameter passing is similar to that of C#, except that either the
actual parameter or the formal parameter can specify pass-by-reference.
Passby- reference is specified by preceding one or both of the
parameters with an ampersand.<br />
<br />
<i>8 . Argue against the Java design of not providing operator overloading</i><br />Arithmetic
operators are often used for more than one purpose. For example, +
usually is used to specify integer addition and floating-point addition.
Some languages—Java, for example—also use it for string catenation.
This multiple use of an operator is called operator overloading and is
generally thought to be acceptable, as long as neither readability nor
reliability suffers.<br />
<br />
<i>12 . Research Jensen’s Device, which was a widely known use
of pass-by-name parameters, and write a short description of what it is
and how it can be used.</i><br />
Implementing a pass-by-name parameter requires a subprogram to be
passed to the called subprogram to evaluate the address or value of the
formal parameter. The referencing environment of the passed subprogram
must also be passed. This subprogram/referencing environment is a
closure. Pass-by-name parameters are both complex to implement and
inefficient. They also add significant complexity to the program,
thereby lowering its readability and reliability. Because pass-by-name
is not part of any widely used language, it is not discussed further
here. However, it is used at compile time by the macros in assembly
languages and for the generic parameters of the generic subprograms in
C++, Java 5.0, and C# 2005.<br />
<br />
<i>15. How is the problem of passing multidimensional arrays handles by Ada?</i><br />Ada
compilers are able to determine the defined size of the dimensions of
all arrays that are used as parameters at the time subprograms are
compiled. In Ada, unconstrained array types can be formal parameters. An
unconstrained array type is one in which the index ranges are not given
in the array type definition. Definitions of variables of unconstrained
array types must include index ranges. The code in a subprogram that is
passed an unconstrained array can obtain the index range information of
the actual parameter associated with such parametersRyanhttp://www.blogger.com/profile/09159563307966653917noreply@blogger.com0tag:blogger.com,1999:blog-2782474402339097998.post-23636869217621537682013-06-27T05:21:00.000-07:002013-06-27T05:21:08.131-07:00Concepts of Programming Languages Assignment - Chapter 8<b>Review Questions</b><br />
<br />
<i>2. What did Bohm and Jocopini prove about flowcharts?</i><br />
It was proven that all algorithms that can be expressed by flowcharts
can be coded in a programming languages with only two control
statements: one for choosing between two control flow paths and one for
logically controlled iterations.<br />
<br />
<i>3. What is the definition of block?</i><br />
In Ruby, block is a sequence of code, delimited by either breves or the do and and reserved words.<br />
<br />
<i>4. What is/are the design issue(s) for all selection and iteration control statements?</i><br />
There is only one design issue that is relevant to all of the
selection and iteration control statements: Should the control structure
have multiple entries?<br />
<br />
<i>7. Under what circumstances must an F# selector have an else clause?</i><br />
An F# selector have an “else” clause if the “if” expression does return a value.<br />
<br />
<i>9. What are the design issues for multiple-selection statements?</i><br />
What is the form and type of the expression that controls the selection?<br />
How are the selectable segments specified?<br />
How are the case values specified?<br />
How should unrepresented selector expression values be handled, if at all?<br />
Is execution flow through the structure restricted to include just a single selectable segment?<br />
<br />
<i>14. What are the design issues for all iterative control statements?</i><br />
How is the iteration controlled?<br />
Where should the control mechanism appear in the loop statement?<br />
<br />
<i>15. What are the design issues for counter-controlled loop statements?</i><br />
What are the type and scope of the loop variable?<br />
Should it be legal for the loop variable or loop parameters to be
changed in the loop, and if so, does the change affect loop control?<br />
Should the loop parameters be evaluated only once, or once for every iteration?<br />
<br />
<i>21. What are the design issues for logically controlled loop statements?</i><br />
Should the control be pretest or post-test?<br />
Should the logically controlled loop be a special form of a counting loop or a separate statement?<br />
<br />
<i>23. What are the design issues for user-located loop control mechanisms?</i><br />
Should the conditional mechanism be an integral part of the exit?<br />
Should only one loop body be exited, or can enclosing loops also be exited?<br />
<br />
<b>Problem Set</b>
<br />
<i>1. What design issues should be considered for two-way selection statements?</i><br />
The design issues for two-way selectors can be summarized as follows:<br />
• What is the form and type of the expression that controls the selection?<br />
• How are the then and else clauses specified?<br />
• How should the meaning of nested selectors be specified?<br />
<br />
<i>4. What are the limitations of implementing a multiple selector from two-way selectors and gotos?</i><br />
A multiple selector can be built from two-way selectors and gotos, but the resulting<br />
structures are cumbersome, unreliable, and difficult to write and read.<br />
<br />
<i>5. What are the arguments pro and con, for Java’s approach to specify compound statements in control statements?</i><br />
• Compound statements are required in control statements when the body of the if<br />
or else clause requires multiple statements.<br />
• Java uses braces to form compound statements, which serve as the bodies of if<br />
and else clauses.<br />
<br />
<i>9. Boolean expressions are necessary in the control statements in
Java, as opposed to also allowing arithmetic expressions, as in C++.
Give a conditional statement that is correct in C++ but not in Java.</i><br />
int i=10;<br />
if( i )<br />
{<br />
// block of statements<br />
}<br />
This block of statement is valid in C++ but not in Java.<br />
<br />
<i>11. Explain the advantages and disadvantages of the Java switch statement, compared to C++’s switch statement.</i><br />
The Java variable in the argument of a switch statement can be of type integral ( byte,<br />
short etc.), char and String( JDK 1.7 onwards), whereas in C++ the argument can be int<br />
or char.Ryanhttp://www.blogger.com/profile/09159563307966653917noreply@blogger.com0tag:blogger.com,1999:blog-2782474402339097998.post-57597236102285035222013-04-08T09:19:00.002-07:002013-04-08T09:19:17.827-07:00Concepts of Programming Languages Assignment - Chapter 7<b>Review Questions</b><br />
<br />
<i>
</i><i>3. What is a prefix operator?</i><br />
prefix operators is the operators that precede the operands<br />
<br />
<i>
</i><i>5. What is a nonassociative operator?</i><br />
Operator with illegal expression<br />
<br />
<i>
</i><div>
<i> 9. What is a coercion?</i></div>
<div>
A coercion is the implicit type convertion</div>
<div>
</div>
<i>
</i><div>
<i>10. What is a conditional expression?</i></div>
<div>
Conditional expression is a statement that uses if-then-else statements</div>
<div>
<b> </b></div>
<i>
</i><div>
<i>11. What is an overloaded operator?</i></div>
<div>
An overloaded operator is the multiple uses of an operator</div>
<div>
</div>
<div>
<i>14. What is a mixed-mode expression?</i><br />
A mixed-mode expression is one that has operands of different types<br />
</div>
<div>
<i>21. What is the purpose of a compound assignment operator?</i><br />
To specifying a commonly needed form of assignment<br />
<br />
<i>24. What two languages include multiple assignments?</i><br />
Perl, Ruby and Lua<br />
</div>
<i>28. What is a cast?</i><br />
Cast is explicit type conversions. To specify a cast, the desired
type is placed in parentheses just before the expression to be
converted<br />
<br />
<b>Problem Set</b><br />
<br />
<i>1. Run the code given in Problem 13 (in the problem set) on some
system that supports C to determine the values of sum1 and sum2. Explain
the result.</i><br />
Suppose Type1 is a subrange of Integer. It may be useful for the
difference between Type1 and Integer to be ignored by the compiler in an
expression<br />
<br />
<i>3. Do you think the elimination of overloaded operators in your favorite language would be beneficial? Why or why not?</i><br />
Yes, I think that the elimination of overloaded operators in my
favorite language would be beneficial. Elimination of overloaded
operators will result in:<br />
- Enhance and increase readability.<br />
- Minimize the compiler overhead (choosing the correct operator meaning).<br />
<br />
<i>4. Would it be a good idea to eliminate all operator precedence
rules and require parentheses to show the desired precedence in
expressions? Why or why not?</i><br />
No, it's not a good idea to eliminate all operator
precedence rules. Although this idea sounds good, but in fact it affects
the flexibility provided by the language since only one way is used to
show the precedence in expressions. Moreover, using parentheses will
future more affects writability and in some cases readability.<br />
<br />
<i>7. Describe a situation in which the add operator in a programming language would not be commutative.</i><br />
An expression such as a + fun(b)<br />
<br />
<i>
</i><i>8. Describe a situation in which the add operator in a programming language would not be associative.</i><br />
Consider the integer expression A + B + C. Suppose the values of A,
B, and C are 20,000, 25,000, and -20,000, respectively. Further suppose
that the machine has a maximum integer value of 32,767. If the first
addition is computed first, it will result in overflow. If the second
addition is done first, the whole expression can be correctly computed.<br />
<br />
<i>11. Write an BNF description of precendence and associativity rules
defined for the expressions in Problem 9. Assume the only operands are
the names a, b, c, d, and e.</i><br />
<br />
<expr> → <expr> or <e1> | <expr> xor <e1> | <e1><br />
<e1> → <e1> and <e2> | <e2><br />
<e2> → <e2> = <e3> | <e2> /= <e3> | <e2> < <e3><br />
| <e2> <= <e3> | <e2> > <e3> | <e2> >= <e3> | <e3><br />
<e3> → <e4><br />
<e4> → <e4> + <e5> | <e4> – <e5> |
<e4> & <e5> | <e4> mod <e5> | <e5><br />
<e5> → <e5> * <e6> | <e5> / <e6> | not <e5> | <e6><br />
<e6> → a | b | c | d | e | const | ( <expr> )<br />
<br />
<i>15. Explain why it is difficult to eliminate functional side effects in C.</i><br />
One reason functional side effects would be difficult to remove from C
is that all of C’s subprograms are functions, providing the ability of
returning only a single data value (though it could be an array). The
problem is that in many cases it is necessary (or at least convenient)
to return more than one data value, which is done through the use of
pointer actual parameters, which are a means of creating functional side
effectsRyanhttp://www.blogger.com/profile/09159563307966653917noreply@blogger.com0tag:blogger.com,1999:blog-2782474402339097998.post-27869803727326571262013-04-08T09:07:00.000-07:002013-04-08T09:08:52.440-07:00Concepts of Programming Languages Assignment - Chapter 6<b>Review Questions</b><br />
<br />
<i>1. What is a descriptor?</i><br />
A descriptor is the collection of the attributes of a variable<br />
<br />
<i>2. What are the advantages and disadvantages of decimal data types?</i><br />
The advantages of decimal data types is being able to precisely store
decimal values, at least those within a restricted range, which can’t
be done with floating-point. And the disadvantages of decimal data types
are that the range of values is restricted because no exponents are
allowed, and their representation in memory is mildly wasteful<br />
<br />
<i>3. What are the design issues for character sting types?</i><br />
The two most important design issues that are specific to character string types are the following:<br />
- Should strings be simply a special kind of character array or a primitive type?<br />
- Should strings have static or dynamic length?<br />
<br />
<i>11.How does JavaScript support sparse arrays?</i><br />
JavaScript sparse arrays means that the subscript values need not be contiguous<br />
<br />
<i>12. What languages support negative superscripts?</i><br />
c++<br />
<br />
<i>13. What languages support array slices with stepsized?</i><br />
Phyton, Perl, and Ruby<br />
<br />
<i>14. What array initialization feature is available in Ada that is not available in other common imperative languages?</i><br />
Ada provides two mechanisms for initializing arrays in the
declaration statement: by listing them in the order in which they are to
be stored, or by directly assigning them to an index position using the
=> operator, which in Ada is called an arrow<br />
<br />
<i>17. Define row major order and column major order.</i><br />
Row major order = the elements of the array that have as their first subscript the lower bound value of<br />
that subscript are stored first, followed by the elements of the second value of the first subscript, and so forth.<br />
Column major order = the elements of an array that have as their last
sub-script the lower bound value of that subscript are stored first,
followed by the elements of the second value of the last subscript, and so forth<br />
<br />
<i>20.What is the structure of an associative array?</i><br />
hashes <br />
<br />
<i>23. What is the primary difference between a record and a tuple?</i><br />
In tuple, the elements are not named<br />
<br />
<i>32. What are the design issues for unions?</i><br />
The primary design issues that are particular to union types are the following:<br />
- Should type checking be required? Note that any such type checking must be dynamic.<br />
- Should unions be embedded in records?<br />
<br />
<i>35. What are the design issues for pointer types?</i><br />
The primary design issues particular to pointers are the following:<br />
- What are the scope and lifetime of a pointer variable?<br />
- What is the lifetime of a heap-dynamic variable?<br />
- Are pointers restricted as to the type of value to which they can point?<br />
- Are pointers used for dynamic storage management, indirect addressing, or both?<br />
- Should the language support pointer types, reference types, or both?<br />
<br />
<i>43. What is a compatible type?</i><br />
A compatible type is one that either is legal for the operator or is
allowed under language rules to be implicitly converted by
compiler-generated code to a legal type.<br />
<br />
<i>44. Define type error.</i><br />
type error the application of an operator to an operand of an inappropriate type<br />
<br />
<i>45. Define strongly typed.</i><br />
widely acknowledged as being a highly valuable language characteristic <br />
<br />
<b>Problem Set</b><br />
<br />
<i>1. What are the arguments for and against four signed integer sized in Java?</i><br />
Bytes =1 byte, short = 2 bytes, integer = 4 bytes, long = 8 bytes.
As a result, depending on the domain of the variable required, data
types are used.<br />
<br />
<i>2. How are negative integers stored in memory?</i><br />
A negative integer could be stored in sign-magnitude notation, in
which the sign bit is set to indicate negative and the remainder of the
bit string represents the absolute value of the number. Sign-magnitude
notation does not lend itself to computer arithmetic. Most computers now
use a notation called twos complement to store negative integers, which
is convenient for addition and subtraction.<br />
<br />
<i>5. What disadvantages are there in implicit dereferencing of
pointers, but only in certain contexts? For example, consider the
implicit dereference of a pointer to a record in Ada when it is used to
reference a record field.</i><br />
When implicit dereferencing of pointers occurs only in certain
contexts, it makes the language slightly less orthogonal. The context of
the reference to the pointer determines its meaning. This detracts from
the readability of the language and makes it slightly more difficult to
learn<br />
<br />
<i>7. Compare the pointer and reference type variable in C++.</i><br />
A C++ reference type variable is a constant pointer that’s always implicitly dereferenced<br />
<br />
<i>15. What are the arguments for and against Head management’s single-size cells and variable-size cells?</i><br />
Integer values stored in decimal waste storage in binary memory computers, simply as a result of the fact that it takes four binary bits to store a single decimal digit, but those four bits are capable of storing 16 different values. Therefore, the ability to store six out of every 16 possible values is wasted. Numeric values can be stored efficiently on binary memory computers only in number bases that are multiples of 2. If humans had<br />
developed hands with a number of fingers that was a power of 2, these kinds of problems would not occur<br />
<br />
<i>21. In what way is dynamic type checking better than static type checking?</i><br />
Static checking reduces programmer flexibility<br />
<br />
<i>22. Explain how the dangling-pointer problem can be removed using the locks-and-keys approach.</i><br />
In the locks-and-keys approach, pointer values are represented as
ordered pairs (key, address), where the key is an integer value.
Heap-dynamic variables are represented as the storage for the variable
plus a header cell that stores an integer lock value. When
a heap-dynamic variable is allocated, a lock value is created and placed
both in the lock cell of the heap-dynamic variable and in the key cell
of the pointer that is specified in the call to newRyanhttp://www.blogger.com/profile/09159563307966653917noreply@blogger.com0tag:blogger.com,1999:blog-2782474402339097998.post-62996702829770799592013-04-08T08:55:00.002-07:002013-04-08T08:55:29.246-07:00Concepts of Programming Languages Assignment - Chapter 5<b>Review Questions </b><br />
<br />
<i>1. What are the design issues for names?</i><br />- Are names case sensitive?<br />- Are the special words of the language reserved words or keywords?<br />
<br />
<i>4. What is an alias?</i><br />a hindrance to readability because it allows a variable to have its value changed by an assignment to a different variable<br />
<br />
<i>5. Which category of C++ reference variable is always aliases?</i><br />union types<br />
<br />
<i>6. What is the l-value of a variable? What is the r-value?</i><br />l-value is an address of a variable<br />r-value is a variable’s value<br />
<br />
<i>7. Define binding and binding time.</i><br />binding is an association between an attribute and an entity, such as between a variable and its type or value, or between an operation and a symbol. Binding time is the time at which a binding takes place<br />
<br />
<i>
</i><i>15. What is the general problem with static scoping?</i><br />First, in most cases it allows more access to both variables and subprograms than is necessary. It is simply<br />too crude a tool for concisely specifying such restrictions. Second, and perhaps more important, is a problem related to program evolution. Software is highly dynamic-programs that are used regularly continually change<br />
<br />
<i>16. What is the referencing environment of a statement?</i><br />referencing environment of a statement is the collection of all variables that are visible in the statement<br />
<br />
<i>18. What is block?</i><br />Such variables are typically stack dynamic, so their storage is allocated when the section<br />is entered and deallocated when the section is exited<br /><br />
<b>Problem set</b><br />
<br />
<i>1. Decide which of the following identifier names is valid in C language. Support your decision</i><br />Student & Student123<br />because no consist of special character and number at the first of names<br />
<br />
<i>2. What is l-value? Write a statement in C language which gives the compile time error “l-value required”.</i><br />
The address of a variable is sometimes called its l-value<br />scanf(“%d”,num);<br />
<br />
<i>4. Why is the type declaration of a variable necessary? What is the value range of the int type variable in Java?</i><br />because it must include an initial value, byte<br />
<br />
<i>5. Approaches to building a lexical analyzer:</i><br />
- Write a formal description of the token patterns of the language
using a descriptive language related to regular expressions. These
descriptions are used as input to a software tool that automatically
generates a lexical analyzer. There are many such tools available for
this. The oldest of these, named lex, is commonly included as part of
UNIX systems<br />
- Design a state transition diagram that describes the token
patterns of the language and write a program that implements the
diagram<br />
- Design a state transition diagram that describes the token
patterns of the language and hand-construct a table-driven
implementation of the state diagram<br />
<br />
<i>6. State transition diagram is a directed graph. The nodes of a
state diagram are labeled with state names.</i><br />
The arcs are labeled with
the input characters that cause transitions among the states<br />
<br />
<i>8.a.Assuming static scooping, in the following, which declaration of x is the correct one for a reference to x?<br />b.Repeat part a, but assume dynamic scoping.</i><br />(a) i. Sub1<br />ii. Sub126<br />iii. Main<br />(b) i. Sub1<br />ii. Sub1<br />iii. Sub1<br />
<br />
<i>9. The differences between top-down and bottom-up parsers:</i><br />
- Syntax analyzers are either top-down, meaning they construct
left most derivations and a parse tree in top-down order, which mean the
tree built from the root downward to the leaves<br />
- Bottom-up meaning case they construct the reverse of a rightmost
derivation and a parse tree in bottom-up order, which mean the parse
tree is built from leaves upward to the rootRyanhttp://www.blogger.com/profile/09159563307966653917noreply@blogger.com0tag:blogger.com,1999:blog-2782474402339097998.post-55839575589785958342013-03-26T04:51:00.001-07:002013-03-26T04:52:40.791-07:00Concepts of Programming Languages Assignment - Chapter 3<b>Review Questions</b><br />
<i><br /></i>
<i>1. Define syntax and semantics.</i><br />
Syntax in a programming language is the form of its expressions,
statements, and program units. Its semantics is the meaning of those
expressions, statements, and program units<br />
<i><br /></i>
<i>2. Who are language descriptions for?</i><br />
The language descriptions is important for the programming language
implementers to determine how the expressions, statements, and program
units of a language are formed, and also their intended effect when
executed<br />
<br />
<i>3. Describe the operation of a general language generator.</i><br />
Language generator is a device that can be used to generate the
sentences of languages. People prefer certain forms of generators over
recognizers because they can more easily read and understand them.
Language generator operates by generating a sentence of language,
however language generators is unpredictable<br />
<br />
<i>5. What is the difference between a sentence and a sentential form?</i><br />
A sentence is a sentential form that has only terminal symbols. A sentential form is every string of symbols in the derivation<br />
<br />
<i>6. Define a left-recursive grammar rule.</i><br />
A grammar is left-recursive if we can find some non-terminal A which
will eventually derive a sentential form with itself as the left-symbol<br />
<i><br /></i>
<i>12. What is the primary use of attribute grammar?</i><br />
Attribute grammar is primary used to provide complete descriptions of the syntax and static semantics of programming languages<br />
<i><br /></i>
<i>18. Which semantics approach is most widely known?</i><br />
Denotational semantics<br />
<br />
<i>23. On what branch of mathematics is axiomatic semantics based?</i><br />
mathematics logic<br />
<br />
<i>24. On what branch of mathematics is denotational semantics based?</i><br />
mathematical objects<br />
<br />
<i>29. Give the difference between total correctness and partial correctness.</i><br />
Total correctness requires that the algorithm terminates while partial
correctness requires that if an answer is returned it will be
correct<br />
<br />
<b>Problem Set</b><br />
<br />
<i>1. Syntax error and semantic error are two types of compilation
error. Explain the difference between the two in a program with
examples.</i><br />
Syntax error is a code error and semantic error is a logical error. Example of syntax error is forget to put a semicolon, bracket, etc. Example of semantic error is, <br />
<br />
<i>3. Rewrite the BNF of Example 3.4 to represent operator – and operator / instead of operator + and operator *.</i><br />
<assign> -> <id> = <expr><br />
<id> -> A | B | C<br />
<expr> -> <expr> -<term><br />
| <term><br />
<term> -><term> * <factor><br />
| <factor><br />
<factor> -> ( <expr> )<br />
| <id><br />
<br />
<i>8. Prove that the following grammar is ambiguous:</i><br />
<i><S> -> <A></i><br />
<i>
</i><i><S> -> <A> * <A> | <id></i><br />
<i>
</i><i><id> -> x | y | z</i><br />
<br />
The grammar generates a different parse tree, so the
grammar is ambiguous.<br />
<br />
<i>9. Modify the grammar of Example 3.4 to add a unary minus operator that has higher precedence than either + or *.</i><br />
<factor> → <id><br />
with<br />
<factor> → + <id><br />
| - <id><br />
<br />
<i>13. Write a grammar for the language consisting of strings that have n copies of the letter a followed by the same number of copies of the letter b, where n > 0. For example, the strings abb, aabbbb, and aaaabbbbbbbb are in the language but a, aabb, ba, and aaabb are not.</i><br />
S -> ab<br />
b ->bb<br />
<br />
<i>15. Convert the BNF of Example 3.1 to EBNF.</i><br />
<program> -> begin<b> </b><stmt_list> end<br />
<stmt_list> -> <stmt><br />
| <stmt> ; <stmt_list><br />
<stmt> -> <var> = <expression><br />
<var> -> A | B | C<br />
<expression> -> <var> {(+|-) <var>}<br />
<i><br /></i>
<i>16. Convert the BNF of Example 3.3 to EBNF.</i><br />
<assign> → <id> = <expr><br />
<id> → A | B | C<br />
<expr> → <expr> {(+ | *) <expr>}<br />
| <id><br />
<br />
<i>17. Convert the following EBNF to BNF:</i><br />
<i>
</i><i>S -> a{bA}</i><br />
<i>
</i><i>A ->a[b]A</i><br />
<br />
answer :<br />
S -> A | AX
<br />
X -> bA | bAX<br />
A -> aA | abA<br />
<br />
<i>18. What is a fully attributed parse tree?</i><br />
If all of the attribute values in a parse tree have been computed, the tree is said to be fully attributedRyanhttp://www.blogger.com/profile/09159563307966653917noreply@blogger.com0tag:blogger.com,1999:blog-2782474402339097998.post-30669015159385916712013-03-11T06:53:00.001-07:002013-03-26T04:08:41.695-07:00Concepts of Programming Languages Assignment - Chapter 2<b>Name : Ryanto Salim</b><br />
<b>Class : 02PCT</b><br />
<b>NIM : 1601231415</b><br />
<br />
<b><b>Review Questions</b></b><br />
<i><br /></i>
<i>1. In what year was Plankalkul designed? In what year was that design publishes?</i><br />
Designed in 1943 and Published in 1972<br />
<i><br /></i>
<i>3. What does Plankalkul mean?</i><br />
Program Calculus<br />
<i><br /></i>
<i>7. Who developed the Speedcoding system for the IBM 701?</i><br />
John Backus<br />
<i><br /></i>
<i>8. Who developed Short Code? Why is Short Code called automatic programming?</i><br />
John Mauchly. Because, it clearly simplified the programming process, but at the expense of execution time.<br />
<i><br /></i>
<i>10. What was the most significant feature added to Fortran I to get Fortran II?</i><br />
Independent compilation of subroutines<br />
<i><br /></i>
<i>11. What control flow statements were added to Fortran IV to get Fortran 77?</i><br />
Logical loop control statements<br />
<i><br /></i>
<i>12. Which version of Fortran was the first to have any sort of dynamic variables?</i><br />
Fortran IV<br />
<i><br /></i>
<i>13. Which version of Fortran was the first to have character string handling?</i><br />
Fortran 77<br />
<i><br /></i>
<i>14. Why were linguists interested in artificial intelligence in the late 1950s?</i><br />
Because, Linguists were concerned with natural language processing<br />
<i><br /></i>
<i>15. What are the different data types and structures in Common LISP?</i><br />
Records, arrays, complex numbers and character strings<br />
<i><br /></i>
<i>17. What dialect of LISP is used for introductory programming courses at some universities?</i><br />
Scheme <br />
<i><br /></i>
<i>18. What two professional organizations together designed ALGOL 60?</i><br />
GAMM and ACM<br />
<i><br /></i>
<i>22. On what language was COBOL based?</i><br />
English<br />
<i><br /></i>
<i>23. In what year did the COBOL design process begin?</i><br />
1959<br />
<i><br /></i>
<i>24. What data structure that appeared in COBOL originated with Plankalkul?</i><br />
Hierarchical data structures (records)<br />
<i><br /></i>
<i>26.Which data type does the original BASIC language support?</i><br />
Floating-point<br />
<i><br /></i>
<i>36. Why is Prolog called a nonprocedural language?</i><br />
Because, programming in logic programming languages is nonprocedural<br />
<br />
<b>Problem Set </b><br />
<b><br /></b>
<i>2. Determine the capabilities of Short Code, and compare them with those of a contemporary programmable hand calculator.</i><br />
Short Code clearly simplified the programming process, but at the expense of execution time. Short Code interpretation was approximately 50 times slower than machine code (hand calculator).<br />
<i><br /></i>
<i>6. Make an educated guess as to the most common syntax error in C programs.</i><br />
The most common syntax error in C i think is forget to end a statement with semicolon (;)<br />
<i><br /></i>
<i>8. Describe in detail the two most important reasons, in your opinion, why Speedcoding did not become a very widely used language.</i><br />
Because, Speedcoding fills up a lot of space on the disk so it's ineffective <br />
<i><br /></i>
<i>13. What is the primary reason why C became more widely used than Fortran?</i><br />
Because, C is flexible and well suited for various applications and also a compiler for C was part of the widely used UNIX operating system in 1980s <br />
<i><br /></i>
<i>14. What are the arguments both for and against the idea of a typeless language?</i><br />
Typeless language allowing more flexibility but it also can create an ambiguity as to the contents of a variable <br />
<i><br /></i>
<i>15. Are there any nonprocedural programming languages other than Prolog?</i><br />
Yes there are, like Visual Basic and SQL<br />
<i><br /></i>
<i>25.</i><span style="color: #0000ee;"><i> <span style="color: black;">Give a brief general description of the Java servlet.</span></i></span><br />
<span style="color: #0000ee;"><span style="color: black;">Java servlet is a Java programming language class used to extend the capabilities of a server. Although servlets can respond to any types of requests, they are commonly used to extend the applications hosted by web servers, so they can be thought of as Java Apllets that run on servers instead of in web browsers</span></span><br />
<br />
<br />Ryanhttp://www.blogger.com/profile/09159563307966653917noreply@blogger.com0tag:blogger.com,1999:blog-2782474402339097998.post-51820982615393900712013-03-04T10:46:00.003-08:002013-03-26T03:55:45.202-07:00Concepts of Programming Language Assignment - Chapter 1<b>Name : Ryanto Salim</b><br />
<b>Class : 02PCT</b><br />
<b>NIM : 1601231415</b><br />
<br />
<b>Review Questions</b> <br />
<i><br /></i>
<i>3. What programming language has dominated scientific computing over the past 50 years?</i><br />
Fortran<br />
<i><br /></i>
<i>4. What programming language has dominated business applications over the past 50 years?</i><br />
COBOL<br />
<i><br /></i>
<i>5. What programming language has dominated artificial intelligence over the pas 50 years?</i><br />
LISP<br />
<i><br /></i>
<i>6. In what language is most of UNIX written?</i><br />
C<br />
<i><br /></i>
<i>7. What is the disadvantage of having too many features in a language? </i><br />
Having too many features in a language will make it more difficult to learn and it may cause feature multiplicity.<br />
<i><br /></i>
<i>8. How can user-defined operator overloading harm and the readability of a program?</i><br />
Because, sometimes the user make the user-defined operator without being sensible which can reduce the readability.<br />
<i><br /></i>
<i>10. What language used orthogonality as a primary design criterion?</i><br />
ALGOL 68 <br />
<br />
<i>13. What does it mean for a program to be reliable?</i><br />
A program is said to be reliable if it performs to its specifications under all conditions.<br />
<br />
<i>15. What is aliasing?</i><br />
Aliasing is having two or more distinct names that can be used to access the same memory cell.<br />
<br />
<i>16. What is exception handling?</i><br />
Exception handling is the ability of a program to intercept run-time
errors, take corrective measures, and then continue is an obvious aid to
reliability.<br />
<br />
<b>Problem Set</b><br />
<br />
<i>1. Do you believe that solving a problem in a particular algorithmic step requires programming language skills?</i><br />
No, because people who can solve their problem properly(step by step)
like an algorithm steps doesn't guarantee that those people have
programming language skills.<br />
<i><br /></i>
<i>2. Who is said to be the first programmer in human history?</i><br />
Ada Lovelace<br />
<br />
<i>3. What are the disadvantages of multiple programming language?</i><br />
I think the main disadvantage of using multiple programming language is
it can make you confuse, especially for beginner programmer and if
people using multiple programming language usually they didn't really
skilled in those programming languages but only good or average.<br />
<br />
<i>4. In what way do the languages for scientific applications differ from the languages for business applications?</i><br />
Language for scientific applications is more complex i think, because
it must support many different calculations that related to scientific
uses and language for business application maybe simpler. But, of course the main difference between both of them is the functions itself.<br />
<br />
<i>6. Which characteristics of programming languages do you think are the most important and why?</i><br />
Readability, because it's one of the most important criteria for
judging a programming language whether it's easily read and understood
or not. Also, if a programming language have a high readability it will
make the user more easier to learn how to use that programming language.
<br />
<br />
<i>7. Java uses a semicolon to mark the end of all statements. What are the advantages for and against this design?</i><br />
The advantage is that you can easily identify
which is the end of one statement from your code, and the disadvantage
is sometimes it can cause an error if you forget to put it.Ryanhttp://www.blogger.com/profile/09159563307966653917noreply@blogger.com1tag:blogger.com,1999:blog-2782474402339097998.post-16425940257130209292013-03-04T06:45:00.001-08:002013-03-04T06:49:13.091-08:00Special PostThis post dedicated to :<span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;"></span><br />
<span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Mr. </span><span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Tri Djoko Wahjono, Ir., M.Sc. </span><br />
<span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Mr. </span><span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Tri Djoko Wahyono, Ir., M.Sc. </span><br />
<span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Mr. </span><span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Tri Djoko Wahjono, Ir., M.Sc. </span><br />
<span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Mr. </span><span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Tri Djoko Wahyono, Ir., M.Sc. </span><br />
<span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Mr. </span><span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Tri Djoko Wahjono, Ir., M.Sc. </span><br />
<span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Mr. </span><span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Tri Djoko Wahyono, Ir., M.Sc. </span><br />
<span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Mr. </span><span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Tri Djoko Wahjono, Ir., M.Sc. </span><br />
<span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Mr. </span><span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Tri Djoko Wahyono, Ir., M.Sc. </span><br />
<span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Mr. </span><span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Tri Djoko Wahjono, Ir., M.Sc. </span><br />
<span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Mr. </span><span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">Tri Djoko Wahyono, Ir., M.Sc.</span><br />
<br />
<br />
<span style="background-color: #f7f3ee; color: #333333; font-family: Georgia, serif; font-size: 16px; line-height: 26px;">From : Ryanto Salim / 02PCT / 1601231415 </span>Ryanhttp://www.blogger.com/profile/09159563307966653917noreply@blogger.com0tag:blogger.com,1999:blog-2782474402339097998.post-66193901631941537902012-10-13T06:23:00.001-07:002013-03-04T06:48:13.454-08:00PTI Assignment<h2>
</h2>
Hello guys! This is my very first blog and actually I don't know what to write, but because my group will have a presentation about E-Commerce, so i will write a little thing about it. Enjoy your time!<br />
<br />
<h3>
<b>E-Commerce</b></h3>
<h4>
<b>Definition</b></h4>
Electronic commerce is a wide range of online business activities for products and services. It also pertains to “any form of business transaction in which the
parties interact electronically rather than by physical exchanges or
direct physical contact.” E-commerce is usually associated with buying and selling over the
Internet, or conducting any transaction involving the transfer of
ownership or rights to use goods or services through a computer-mediated
network. Though popular, this definition is not comprehensive enough to capture
recent developments in this new and revolutionary business phenomenon. A
more complete definition is: E-commerce is the use of electronic
communications and digital information processing technology in business
transactions to create, transform, and redefine relationships for value
creation between or among organizations, and between organizations and
individuals.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2ROBClOhf3vuKAWm2uYY1a9iMiKh0lMfdxd7VCtSbo8bY3rZrlJKkfyjzu51yCgdnTobesFwjSONsVbnpqWk3ryeoZyn2Mih5pVKvsXVdPZg0W4iuObdqQ88v54ne5ZEqy3LnJJEVtyjV/s1600/ecommerce.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="175" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2ROBClOhf3vuKAWm2uYY1a9iMiKh0lMfdxd7VCtSbo8bY3rZrlJKkfyjzu51yCgdnTobesFwjSONsVbnpqWk3ryeoZyn2Mih5pVKvsXVdPZg0W4iuObdqQ88v54ne5ZEqy3LnJJEVtyjV/s200/ecommerce.png" width="200" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4ZrgQLKNnRQS8Yn3jLGl9ilh9GIOOhXJO3iJ8qkEC36TPgXc7MszuArBVWRPNQU4ApuPg897XGEP8iBllpNwczZ_STpjDOCycRtHfIlq0XkdHzdU4WK1o344oKgrnY8tNZKK-BSpcZpc0/s1600/ecommerce-strategy.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4ZrgQLKNnRQS8Yn3jLGl9ilh9GIOOhXJO3iJ8qkEC36TPgXc7MszuArBVWRPNQU4ApuPg897XGEP8iBllpNwczZ_STpjDOCycRtHfIlq0XkdHzdU4WK1o344oKgrnY8tNZKK-BSpcZpc0/s200/ecommerce-strategy.jpg" width="200" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<h4 class="separator" style="clear: both; text-align: left;">
<b>Advantages of E-Commerce</b></h4>
<ul class="disc">
<li>Faster buying/selling procedure, as well as easy to find products.</li>
<li>Buying/selling 24/7.</li>
<li>More reach to customers, there is no theoretical geographic limitations.</li>
<li>Low operational costs and better quality of services.</li>
<li>No need of physical company set-ups. </li>
<li>Easy to start and manage a business.</li>
<li>Customers can easily select products from different providers without moving around physically.</li>
</ul>
<h4>
<b>Disadvantages of E-Commerce</b></h4>
<ul class="disc">
<li>Any one, good or bad, can easily start a business. And there are many bad sites which eat up customers’ money. </li>
<li>There is no guarantee of product quality.</li>
<li>Mechanical failures can cause unpredictable effects on the total processes.</li>
<li>As there is minimum chance of direct customer to company interactions, customer loyalty is always on a check.</li>
<li>There
are many hackers who look for opportunities, and thus an e-commerce
site, service, payment gateways, all are always prone to attack.</li>
</ul>
<br />
Okay that's a little bit about E-Commerce i guess, hopefully it's not too boring to read about it.<br />
See you on my next post! <br />
<br />
<br />
<b>Assignment Detail</b><br />
<b>Lecturer : Daniel Nugraha (ID: D4748)</b><br />
<div>
<b>Course Code: T0604 </b></div>
<div>
<b>Class: 01PCT</b></div>
<b>Name: Ryanto Salim</b><br />
<b>NIM: 1601231415</b><br />
<b>GSLC - Creating a Blog</b><br />
<div class="separator" style="clear: both; text-align: left;">
<b> </b> </div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
Ryanhttp://www.blogger.com/profile/09159563307966653917noreply@blogger.com0