Download as pdf or txt
Download as pdf or txt
You are on page 1of 38

PRELIMINARIES

WMSU
Outline
1.1 Reasons for Studying Concepts of Programming Languages
1.2 Programming Domains
1.3 Language Evaluation Criteria
1.4 Influences on Language Design
1.5 Language Categories
1.6 Implementation Methods
1.7 Programming Environment (IDE)
Reasons for Studying Concepts of Programming Languages

• Increased capacity to express ideas


• Improved background for choosing appropriate language
• Increased ability to learn new languages
• Better understanding of the significance of implementation
• Better use of languages that are already known
• Overall advancement of computing.
What is a Programming Language?
• a vocabulary and set of grammatical rules, commands, instructions and
other syntax for instructing a computer or any computing device to
perform specific tasks.
• Languages that programmers use to write code are called High-Level
Languages.
• This code can be compiled into a Low-Level Language which is
recognized directly by the computer hardware.
Programming Domains
1. Scientific Applications
▪ Required large numbers of floating-point arithmetic computations.
▪ First language for scientific applications:
▪ Fortran (Formula Translator)
▪ ALGOL 60 and most of its descendants
2. Business Applications
▪ To produce reports
▪ Uses Decimal numbers & characters
▪ First successful high-level language was:
▪ COBOL (Common Business Oriented Language)
3. Artificial Intelligence
▪ Uses symbolic computation
▪ Requires more flexibility that other programming domains
▪ First widely used language was:
▪ LISP (List Processing)
4. Web Software
▪ Eclectic collection of languages:
▪ Markup, e.g., XHTML (Extensible Hypertext Markup Language)
▪ Scripting, e.g., PHP (Hypertext Preprocessor (HTMLembedded scripting
language))
▪ General-purpose (e.g., Java)
Language Evaluation Criteria
Language Evaluation Criteria
1. Readability – The ease with which programs can be read and
understood
a. Overall Simplicity - A language with a large number of basic
constructs is more difficult to learn
❖ Feature Multiplicity
1. Readability
❖ Operator Overloading - redefining the meaning of an operator making it user-
defined. #include <iostream> //overload – when used as prefix
using namespace std;
class TestClass {
private:
int count;
public:
TestClass() : count(5) {} //initializa constructor count to 5
void operator --() { //overload – as prefix
--count;
}
void Display() {
cout << "Count: " << count;
}
};

int main() {
TestClass tc;
--tc;
tc.Display();
return 0;
}
1. Readability
b. Orthogonality - "Changing A does not change B”
Ex: A+B
c. Data Types – significant aid for readability
timeOut = 1
timeOut = true

d. Syntax Design
Ex: In Ada, it uses end if to end selection construct
and end loop to terminate loop construct
Language Evaluation Criteria
2. Writability – measure of how easily a language can be used
to create programs for a chosen problem domain
a. Simplicity and Orthogonality – too many programming constructs
may lead to misuse of some features and disuse of others that can be
more elegant and sufficient.

b. Expressivity
Language Evaluation Criteria
3. Reliability – a program is reliable if it performs to its
specifications under all conditions.

a. Type Checking - testing for type errors in a given program, either by


the compiler or during the program execution.

b. Exception Handling - The ability of a program to intercept run-time


errors, take corrective measures, then just continue.
Example of Exception Handling
3. Reliability
c. Aliasing - having 2 or more distinct names in a program
that can be used to access the same memory cell.

d. Readability and Writability - Programs that are


difficult to read are difficult both to write and to modify.
Language Evaluation Criteria
other criteria that should be considered…

4. Cost
– Cost of training programmers to use the language
– Cost of writing programs in the language
– Cost of compiling programs in the language
– Cost of executing programs written in a language
– Cost of language implementation system
– Cost of poor reliability
– Cost of maintaining programs
Language Evaluation Criteria
5. Other Criteria
A. Portability – the ease with which programs can be moved from one
implementation to another.
B. Generality – applicability to a wide range of applications.
C. Well-definedness – the completeness and precision of the
language’s official defining document.
Influences on Language Design
Computer Architecture
• von Neumann architecture by John von Neumann
• Data and programs stored in memory
• Memory is separate from CPU
• Instructions and data are piped from
memory to CPU
• Basis for imperative languages
von Neumann Architecture
Language Categories
• Imperative
– Central features are variables, assignment statements, and iteration
– Include languages that support object-oriented programming
– Include scripting languages
– Include the visual languages
• Examples: C, Java, Perl, JavaScript, Visual BASIC .NET, C++
• Functional
– Main means of making computations is by applying functions to
given parameters
• Examples: LISP, Scheme
Language Categories
• Logic
– Rule-based (rules are specified in no particular order)
– Example: Prolog
• Markup/programming hybrid
– Markup languages extended to support some programming
– Examples: JSTL (Java Standard Tag Library), XSLT (Extensible
Stylesheet Language Transformations)
Implementation Methods
1. Compilation Implementation – when programs are being
translated into machine language
Lexical Analyzer
• Gathers characters of the source program into
lexical units.
• Lexical units:
– Identifiers
– Special words
– Operators
– Punctuation marks
Syntax Analyzer
• takes the lexical units from the lexical analyzer
• uses them to construct hierarchical structures
called parse trees.
Semantic Analyzer
• semantic analyzer checks for errors, such as
type errors, that are difficult, if not impossible,
to detect during syntax analysis.
Symbol Table
• a database for the compilation process.
• The primary contents of the symbol table are
the type and attribute information

Optimization
• which improves programs by making them
smaller or faster or both.
Code Generator
• translates the optimized intermediate code
version of the program into an equivalent
machine language program.
Implementation Methods
2. Pure Implementation
– easy implementation of many source-level
debugging operations
– 10 to 100 times slower that in compiled
systems
– Rare for high-level languages
– Significant comeback with some Web
Scripting languages (i.e., JavaScript, PHP)
Implementation Methods
3. Hybrid Implementation Systems
– A high-level language program is
translated to an intermediate language
that allows easy interpretation
– Faster than pure interpretation
• Examples
– Perl programs are partially compiled to
detect errors before interpretation
– Initial implementations of Java were
hybrid
Implementation Methods
4. Preprocessor
– processes a program immediately before the program is compiled to
expand embedded preprocessor macros
Programming Environments (IDE)
• The collection of tools used in the development of software.
• This collection may consist of only a file system, a text editor, a
linker, and a compiler.
• Or it may include a large collection of integrated tools, each
accessed through a uniform user interface.
Examples:
1. UNIX
• an older programming environment, first distributed in the middle
1970s, built around a portable multiprogramming operating system.
• Nowadays often used through a GUI (e.g., CDE, KDE, or GNOME)
that runs on top of UNIX
Examples:
2. Borland JBuilder
• programming environment
that provides an integrated
compiler, editor, debugger,
and file system for Java
development, where all four
are accessed through a
graphical interface.
Examples:
3. Microsoft Visual Studio .NET
• is Microsoft's visual programming environment. The product suite provides a
visual interface for identifying a program as a Web service, forms for building a
user interface (including support for mobile device interfaces), features for
integrating existing application data, and for debugging. Visual Studio .NET comes
with the .NET Framework, including the Common Language Runtime, and includes
several programming languages including Visual Basic, Visual C++, and Visual C#.
Examples:
4. NetBeans
• development
environment that is
primarily used for
Java application
development but
also supports
JavaScript, Ruby, and
PHP
End of Presentation

You might also like