Q & A
1. Why is it useful for a programmer to have some background in language
design, even though he or she may never actually design a programming language
Increased capacity to express ideas
Improved background for choosing appropriate languages.
Increased ability to learn new languages.
Better understanding of the significance of an implementation.
2. How can knowledge of programming language characteristics benefit the
whole computing community?
If those who choose a language,
are better informed, then perhaps better languages would eventually squeeze out
poorer ones.
3. What programming language has dominated scientific computing
over the past 45 years?
FORTRAN - FORTRAN has been used for
a long time for scientific computing. It was the first language for scientific
applications because FORTRAN provides efficiency which was the primary concern
for scientific applications.
4. What programming language has dominated business applications over the
past 45 years?
COBOL - COBOL was the first
successful high-level language for business. It is the most commonly used
language for business applications because business languages are
characterized by facilities for producing elaborate reports, precise ways of
describing, strong decimal numbers, character data and the ability to
specify decimal arithmetic operations.
5. What programming language has dominated artificial intelligence over
the past 45 years?
LISP - LISP which appeared in
1959.Artificial Intelligence (AI) is a broad area of computer applications
characterized by the used of symbolic rather than numeric computations.
6. In what language was UNIX written?
The UNIX operating system is written almost
entirely in C which has made it relatively easy to port, or move to different
machines. Some of the characteristics of C make it a good choice for systems
programming. It is low level, execution efficient and doesn’t burden the user
with many safety restrictions.
7.What is the disadvantage of having to many features in a language?
If a language has to many features, some programmers wont be familiar with them
all, leading to the misuse of some features and disuse of others.
8.How can user-defined operator overloading harm readability of a
program?
If a programmer doesn't do it sensibly, it can reduce readability.
9. What is one example of lack of orthogonality in the design of C?
Consider the following rules and exceptions in C. Although C has two kinds
of structured data-types arrays and records (structs). records can be any data
type except void or a structure of the same type. An array element can be any
data type except a void or a function. Parameters are passed by value, unless
they are arrays, in which they are , in effect, passed by reference.
10. What language used orthogonality as a primary design criterion?
ALGOL 68 - ALGOL 68 is the most
orthogonal programming language because every language constructs in ALGOL 68
has a type, and there are no restrictions on those types. But LISP can also be
said as a good combination of simplicity and orthogonality. LISP a functional
language is one in which computations are made primarily by applying a function
to a given program.
11. What primitive control statement is used to build more complicated
control statements in languages that lack them?
It is “goto”, but in the 1970s, the use of “goto”
statements was replaced by structured programming, which could be read from top
to bottom. (While, in newer languages)
12. What construct of a programming language provides process
abstractions?
Programming languages usually contain
abstractions for defining and manipulating data structures or
controlling the flow
of execution. The practical necessity that a programming language supports
adequate abstractions is expressed by the abstraction principal. This principle
is sometimes formulated as recommendation to the programmer to make proper use
of such abstractions.
13.What does it mean for a program to be reliable?
A program is said to be reliable if it performs to
its specifications under all conditions. Factors that affect reliability are
type checking, exception handling, aliasing, readability and write-ability
14. Why is
type checking the parameters of a subprogram important?
Type checking is important because run-time type
checking is expensive, compile-time type checking is more desirable.
Furthermore, the earlier errors in programs are detected, the less expensive it
is to make the required repairs..
15. What is
aliasing?
Aliasing is having two or more distinct names that
can be used to access the same memory cell. It is now widely accepted that
aliasing is a dangerous feature in a programming language. In some languages,
aliasing is used to overcome deficiencies in the language’s data abstraction
facilities.
16.What is
exception handling?
Exception handling is the ability of a program to
intercept run-time errors (as well as the unusual conditions detectable by the
program), take corrective measures, and then continue in an obvious aid to
reliability.
17. Why is
reliability important to write-ability?
Readability is important to write-ability because if
a programming language is difficult to read and understand then it can be
difficult for a programmer to create new code that might need to interact or
use other code. Often times code needs to be modified and if a program is
difficult to read then it is difficult to add new code to it.
18.How is the cost of compilers for a given language related to the design
of that language.
A language that requires many run-time type checks will prohibit fast code
execution, regardless of the quality of the compiler.
19. What has
been the strongest influence of programming language design over the past 50
years.
Most of the past 50 years have been designed
around the prevalent computer architecture, called the von Neumann
architecture, after one of its originators, John von Neumann.
20. What is
the name of the category of programming languages whose structure is dedicated
by the Von Neumann computer architecture?
These languages are called the imperative
languages.
21 What two
programming language deficiencies were discovered as a result of the research
in software development in the 1970s.
The late 1960s and early 70s brought intense analysis of software development. the result in
large begun the structure programming movement of both the software development
process and program language design.
An important reason for this research was the shift in the major cost of
computing from hardware to software. The primary
programming language deficiencies that were discovered were in-completeness of
type checking and inadequacy of control statements (requiring the extensive use
of gotos).
22. What are
the three fundamental features of Object-orientated programming language.
The three fundamentals features of an
object-oriented programming language are data abstraction, which encapsulates
processing with data objects and controls access to data, adds inheritance
and dynamic method binding. Inheritance is a powerful concept that greatly
enhances the potential reuse of existing software, thereby providing the
possibility of significant increases in software development productivity.
Dynamic (run-time) method binding allows more flexible use of inheritance.
23. What
language was the first to support the three fundamental features of the
object-orientated programming?
The first language that supported the three
fundamental features of object-oriented programming was Smalltalk. Although Smalltalk
never became as widely used as many other languages, support for
object-oriented programming is now part of most popular imperative languages,
including Ada 95, Java, C++ , and C#.
24. What is an
example of two language design criteria that are in direct conflict with each
other?
The example of two language design criteria that
are in direct conflict with each other are reliability and cost of execution.
For example the Java language definition demands that all references to array
elements be checked to ensure that the index or indices are in their legal
ranges. This step adds a great deal to the cost of execution of Java programs
that contain large numbers of references to array elements. C does not require
index range checking, so C programs execute faster than semantically equivalent
Java programs, although Java programs are more reliable. The designers of Java
traded execution efficiency for reliability.
25. What are
the three general methods of implementing a programming language?
The three general methods of implementing a
programming language are compilation (programs are translated into machine
language), pure interpretation (programs are translated by another programs
known as interpreter), and Hybrid Implementation (a compromise between compilers
and pure interpreter).
26. Which
produces faster program execution, a compiler or pure interpreter?
A compiler, as a compiler translates directly into machine code.
27. What role
does a symbol table play in a compiler?
The symbol table serves as a database for the
compilation process. The primary contents of the symbol table are the type and
attribute information of each user-defined name in the program. This
information is placed in the symbol table by the lexical and syntax analyzers
and is used by the semantic analyzer and the code generator.
28. What does
a linker do?
Most user programs also require programs from the operating system. Among
the most common of these are programs for input and output. The compiler builds
calls to required system programs when they are needed by the user program.
Before the machine language programs produced by a compiler can be executed. The required programs from the operating system must be found and linked to the
user program. The process of collecting system programs and linking them to
user programs is called linking and loading or just linking. in addition user
programs may have to be linked to other user programs.
29.Why is the
Von Neumann bottleneck important?
The speed of the connection between a computers memory and its processor
usually determines the the speed of the computer, because instructions often
can be executed faster than they can be moved to the processor for
execution. This connection is called the von Neumann bottleneck; it is the
primary limiting factor in the speed of von Neuman architecture computers, The
von Neumann bottleneck has been one of the primary motivations for the research
and development of parallel computers.
30. What are
the advantages of implementing a language with pure interpreter?
The advantages of a pure interpreter, is allowing easy implementation of many source level debugging
operations, because all run time errors messages can refer to source level
units.
Wednesday, 21 January 2015
Wednesday, 31 December 2014
1.0 - Programming Languages Concepts Notes
Programming Languages Concepts
Sometimes to succeed in something, we need to go back to the basics, to re-develop a solid foundation on which everything else can sit on.
1.1 Reasons for studying the concepts of programming languages
The following is a compelling list of potential benefits for studying concepts of programming.
- Increased capacity to express ideas - Having a better understanding of the concepts of programming languages, will enable a programmer to communicate their thoughts, verbally or in writing.
- Improved background for choosing appropriate languages. When given a choice of programming languages for a new project, many programmers will continue to use the language with which they are most familiar with, even if its poorly suited to the project. If these programmers were familiar with a wider range of languages and language contracts, they would be better able to choose the language that includes the features that best address the characteristics of the problem at hand.
- Increase ability to learn a new languages. Computer programming is still a relatively young discipline and design methodologies, software development tools and programming languages are still in a state of continues evolution. This makes software development an exciting profession, but also means that continues learning is essential. Through understanding of the fundamental concepts of languages, can ease the burden.
|
- Better understanding of the significance of implementation. Helps us understand why programming languages are designed the way they are. Gives us an ability to use a language more intelligently, as it was designed to be. Helps us understand the choices among programming language constructs and the consequences of making those choices.
1.2 Language Evaluation Criteria
How to evaluate programming language via its readability, writ-ability and reliability.Readability
Since maintenance has been recognized as major concept of the software life cycle.The ease of maintenance is determined in a large part by the readability of code. Readability is an important language evaluation criteria.
The bullet points below describe characteristics that contribute to the readability of a programming language
- Overall simplicity, is there a small amount of basic constructs, a small amount of ways to accomplish the same particular operation. Readability problems occur whenever the programs author has learned a different subset from that subset with which the reader is familiar.
- Orthogonality, Meaning that a relativity small set of primitive constructs can be combined in a relatively small number of ways to build the control and data-structures of the language. further more every possible combination of primitives is legal and meaningful. Enables a large amount of data structures can be defined.
- Control Statements, A program that can be read top to bottom is much easier than a program that requires the reader to jump from one statement to some nonadjacent statement in order to follow the execution order. ie. the use of a while loop statement in C, compared to the FORTRAN goto statement.
- Data types and structures, The presence of adequate facilities for defining data types and data structures in a language is another significant aid to readability. For example suppose a numeric type in the language is used for an indicator flag because there is no Boolean type in the language. In such a language, we might have an assignment like 'timeout = 1' whose meaning is unclear vs 'timeout = true' which is clear.
- Syntax design, ie. not restricting a identifier to six characters. using 'end if' instead of just '}'
Writ-ability
The bullet points below describe the most important characteristics influencing the write-ability of a programming language- Simplicity and Orthogonality, If a language has a large number of different constructs, some programmers might not be familiar with all of them. this situation can lead to a misuse of some features and a disuse of others that may be either more elegant or more efficient.
- Support and Abstraction, is the ability to define and then use complicated structures or operations in ways that allow many of the details to be ignored.
- Expressivity, Convenient ways of expressing an operation. like i++ (increment a number)
Reliability
The program is said to be reliable if it performs to its specifications under all conditions.The bullet points below describe several language features that have a significant effect on reliability of programs in a given language.
- Type Checking, simply testing for type errors in a given program, preferable at compile time, as at run-time it can be expensive.
- Exception Handling, the ability of a program to intercept run-time errors. ie javascipt is bad at this.
- Aliasing, is having two or more distinct names that can be used to access the same memory cell. (dangerous feature)
- Readability & Writ-ability, the easier a program is to write, the more likely it is correct, also making it more reliable. Programs that are difficult to read are also difficult to write/modify.
- Cost, the ultimate cost of training programmers to use language.
Effort in writing application.
Cost of executing code, required add on frameworks, environments.
cost of maintainability over a lifetime.
----------------------
The two primary components of a computer are its internal memory and its
processor.
The internal memory is to store programs and data
The processor is a collection of circuits that provides a realization of a set of primitive operations or machine instructions, such as those for arithmetic and logic operations.
The machine language of the computer is a set of instructions.
In absence of other supporting software the machine language is the only language that most computer hardware "understand"
The most practical design choice is to implement hardware with a very low-level language
A language implementation system cannot be the only software on a computer.
An operating system is required supplies higher level primitives then those of a machine language. These primitives provide system resource management, input and output operations, a file management system, text and or program editors and a variety of other commonly needed functions.
The operating
system and language implementations are laid over the machine language
interface of a computer.
Programming
languages can be implemented by any of three general methods.
Compilation
(compiler implementation)
- At one extreme, programs can be translated into machine language, which can be executed directly on the computer.
- Has an advantage of very fast program execution, once translation process is complete.
- Most production implementations of languages such as C are by compilers.
Pure-interpretation
- Opposite end (from compilation) of implementation methods.
- Programs are interpreted by another program called an interpreter, with no translation what so ever.
- The interpreter acts as a simulation of a machine whose fetch-execute cycle deals with high level language program statements rather than machine instructions.
- This software simulation obviously provides a virtual machine for the language.
- Advantage is allowing easy implementation of many source level debugging operations, because all run time errors messages can refer to source level units.
- Disadvantage - runs 10 - 100 times slow than in compiled systems
- Java script and PHP
- Regardless of how many times a statement is executed, it must be decoded every time.
Hybrid
Implementation Systems
- Compromise between compilers and pure interpreters.
- They translate a high level language program to an intermediate language design to allow easy interpretations.
- Makes it faster, because source statements are only decoded once
- A Just In Time (JIT) implementation system initially translates programs to an intermediate language. Then during execution, it compiles intermediate language methods into machine code when they are called. The machine code version is kept for subsequent calls.
- Used with .NET languages , JAVA
- Sometimes an implementer may provide both compiled and interpreted implementation for a language. in these cases, the interpreter is used to develop and debug program. Then after a (relatively) bug free state is reached, the programs are compile to increase their execution speed.
Pre-processors
- A
pre-processor is a program that processes a program immediately before
the program is compiled. Preprocessor instructions are embedded in
programs. Preprocesser instructions are commonly used to specify that
the code from another file is to be included. for example.using mylib.cs
causing the preprocessor to copy the contents of my lib to the top
Subscribe to:
Posts (Atom)