Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
33 views

Programming Domains Course Summary

1. The document discusses several programming domains and the languages typically used in each domain, including scientific applications using Fortran, business applications using COBOL, and artificial intelligence using LISP. 2. It then covers characteristics that contribute to the readability, writability, and reliability of programming languages. Main factors for readability include simplicity, orthogonality, and data types. For writability, simplicity, abstraction, and expressivity are key. For reliability, type checking, exception handling, and avoiding aliasing are important. 3. The total cost of a programming language depends on factors like training, writing, compiling, executing programs, implementation costs, maintenance, and reliability.

Uploaded by

jen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Programming Domains Course Summary

1. The document discusses several programming domains and the languages typically used in each domain, including scientific applications using Fortran, business applications using COBOL, and artificial intelligence using LISP. 2. It then covers characteristics that contribute to the readability, writability, and reliability of programming languages. Main factors for readability include simplicity, orthogonality, and data types. For writability, simplicity, abstraction, and expressivity are key. For reliability, type checking, exception handling, and avoiding aliasing are important. 3. The total cost of a programming language depends on factors like training, writing, compiling, executing programs, implementation costs, maintenance, and reliability.

Uploaded by

jen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Programming Domains (5)

• Scientific applications
use of arrays –Fortran
• Business applications
– COBOL
• Artificial intelligence
– Symbols rather than numbers manipulated;
– LISP
• Systems programming
– C, C++
• Web Software
– Eclectic collection of languages: markup (e.g., HTML), scripting (e.g.,
PHP), general-purpose (e.g., Java)

Readability: the ease with which programs can be read and understood.
Writability: the ease with which a language can be used to create programs.
Reliability: A program is said to be reliable if it performs to its
specifications under all conditions.
Cost:the ultimate total cost

Main characteristics that contribute to readability are(4):

• Overall simplicity
–A manageable set of features and constructs
–Minimal feature multiplicity
–Minimal operator overloading

• Orthogonality
–A relatively small set of primitive constructs can be combined in a
relatively small number of ways
–Every possible combination is legal

• Data types
–Adequate predefined data types

• Syntax considerations
–Special words
Main characteristics that contribute to writability are(3):

1. Simplicity and orthogonality


– Few constructs and a small set of rules for combining them.
2. Support for abstraction
– Abstraction means the ability to define and use complex structures or
operations in ways that allow details to be ignored.
– Example: subprogram for sort algorithm.
3. Expressivity
– A set of relatively convenient ways of specifying operations
– Strength and number of operators and predefined functions.

Main characteristics that contribute to Reliability are(4):

1. Type checking
– Testing for type errors either in Compiling time or running time.
– Compile-time type checking is more desrible than run-time type checking
becanse it is expensive.
– the earlier errors in programs are detected, the less expensive it is
to make the required repairs.
– Example of type checking failure (subprogram parameter checking
problem in original C).

2. Exception handling
– Intercept run-time errors and take corrective measures.
– Ada, C++, Java, and C# support exception handling

3. Aliasing
- Aliasing means having two or more distinct names that can be used to
access the same memory cell.
– E.g (two pointers point to same memory loc in c++).

4. Readability and writability


– Both readability and writability influence reliability.
- The easier a program is to write, the more likely it is to be correct.
- Programs that are difficult to read are difficult both to write and
to modify.
Total cost of programming language is a function of(7):

-Training programmers. -Writing programs.


-Compiling programs -Executing programs
-Language implementation -Reliability.
-Maintaining programs

Evaluation Criteria: Others (3)


• Portability
– The ease with which programs can be moved from one implementation to
another
• Generality
– The applicability to a wide range of applications
• Well-definedness
– The completeness and precision of the language’s official definition

Influences on Language Design(2):

Computer Architecture
– Languages are developed around the prevalent computer architecture,
known as the von Neumann architecture
Program Design Methodologies
– New software development methodologies led to new programming
paradigms and by extension, new programming languages

Computer Architecture Influence:

• Well-known computer architecture: Von Neumann


• Imperative languages, most dominant, because of von Neumann computer

– Data and programs stored in memory


– Memory is separate from CPU
– Instructions and data are piped from memory to CPU
– Basis for imperative languages:
• Variables model memory cells
• Assignment statements model piping
• Iteration is efficient
Fetch-execute-cycle (on a von Neumann architecture computer)
( 堰⨁㵨‫)׹‬
initialize the program counter “address of next instruction”
repeat forever
fetch the instruction pointed by the counter
increment the counter
decode the instruction
execute the instruction
end repeat

Von Neumann Bottleneck:

• Connection speed between a computer’s memory and its processor


determines the speed of a computer

• Program instructions often can be executed much faster than the speed
of the connection; the connection speed thus results in a bottleneck.

• Known as the von Neumann bottleneck; it is the primary limiting factor


in the speed of computers

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 “graphical user interface”
– 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, ML, F#,……..etc • 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 Server Pages Standard Tag Library”, HTML, xTML
Language Design Trade-Offs

• Reliability vs. cost of execution


– Example: Java demands all references to array elements be checked for
proper indexing, which leads to increased execution costs

• Readability vs. writability


-Example: APL provides many powerful operators (and a large number of new
symbols), allowing complex computations to be written in a compact program
but at the cost of poor readability

• Writability (flexibility) vs. reliability


– Example: C++ pointers are powerful and very flexible but are unreliable

Implementation Methods
• Compilation
– Programs are translated into machine language; can be executed directly
on the computer
– Use: Large commercial applications
• Pure Interpretation
– Programs are interpreted by another program known as an interpreter
– Use: Small programs or when efficiency is not an issue
• Hybrid Implementation Systems
– A compromise between compilers and pure interpreters
– Use: Small and medium systems when efficiency is not the first concern

Compilation process

• Translate high-level program (source language) into machine code


(machine language)

• Slow translation, fast execution

• Compilation process has several phases:


– lexical analysis
– syntax analysis
– Semantics analysis
– code generation
Pure Interpretation

• Programs are interpreted by another program called an interpreter, with


no translation
• Advantage: Easier implementation of programs
• Disadvantage: Slower execution decoding source code.
• Disadvantage: Often requires more space
• Examples of languages: (e.g., JavaScript, PHP)

Hybrid Implementation Systems

• A compromise between compilers and pure interpreters.


• 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; the intermediate form,
byte code, provides portability to any machine that has a byte code
interpreter and a run-time system (together, these are called Java
Virtual Machine
Ch2:
Zuse’s Plankalkül
• Never implemented
• Advanced data structures
– floating point, arrays, records

Minimal Hardware Programming: Pseudocodes


• There were no high-level programming languages so programming was done
in machine code

• What was wrong with using machine code?


– Poor readability (ADD in assembly language was specified by 14).
– Poor modifiability, and prone to error
– Machine deficiencies--no indexing for using in array or floating point

IBM 704 and Fortran;

– Designed for the new IBM 704, which had index registers and floating
point hardware

– Environment of development;
• Computers were small and unreliable
• Applications were scientific
• No programming methodology or tools
• Machine efficiency was the most important concern

Fortran I Overview
• First implemented version of Fortran
– Names could have up to six characters
– Post-test counting loop (DO)
– Formatted I/O
– User-defined subprograms
– Three-way selection statement (arithmetic IF)
– No data typing statements

Functional Programming: LISP


• LISt Processing language
• AI research needed a language to
– Process data in lists (rather than arrays)
– Symbolic computation (rather than numeric)
• Only two data types: atoms and lists
• Syntax is based on lambda calculus
LISP Evaluation
• Pioneered functional programming
– No need for variables or assignment
– Control via recursion and conditional expressions
• Still the dominant language for AI
• ML, Haskell, and F# are also functional programming languages, butuse
very different syntax

The First Step Toward Sophistication: ALGOL 60


• Environment of development
– FORTRAN had (barely) arrived for IBM 70x
– Many other languages were being developed, all for specific machines
– No portable language; all were machinedependent
– No universal language for communicating algorithms
• ALGOL 60 was the result of efforts to design a universal language
^^^^^^^^^^
Early Design Process
• Goals of the language
– Close to mathematical notation
– Good for describing algorithms
– Must be translatable to machine code

ALGOL 58
• Names could be any length
• Arrays could have any number of subscripts
• Compound statements (begin ... end)
• Semicolon as a statement separator
• Assignment operator was :=
• if had an else-if clause
• No I/O

ALGOL 60 Overview
• New features
– Block structure (local scope)
– Two parameter passing methods
– Subprogram recursion
– Stack-dynamic arrays
– Still no I/O and no string handling
ALGOL 60 Evaluation
• Successes
– It was the standard way to publish algorithms for over 20 years
– All subsequent imperative languages are based on it
– First machine-independent language
– First language whose syntax was formally defined (BNF)

ALGOL 60 Evaluation (continued)


• Failure
– Never widely used.
– Reasons :
• Lack of I/O and the character set made programs non-portable
• Too flexible--hard to implement

Pascal
• Designed for teaching structured programming
• Small, simple, nothing really new
• Largest impact was on teaching programming

C
• Designed for systems programming.
• Powerful set of operators, but poor type checking
• Initially spread through UNIX
• it Also has been used in many application areas

Programming Based on Logic: Prolog


• Based on formal logic
• Non-procedural
• Can be summarized as being an intelligent database system that uses an
inferencing process to infer the truth of given queries
• Comparatively inefficient
• Few application areas

Combining Imperative and ObjectOriented Programming: C++


• Evolved from C and SIMULA 67
• Facilities for object-oriented programming, taken partially from SIMULA
67
• A large and complex language, in part because it supports both procedural
and OO programming
• Rapidly grew in popularity, along with OOP
An Imperative-Based Object-Oriented Language: Java
• Based on C++
– Significantly simplified
– Supports only OOP
– Has references, but not pointers

Java Evaluation
• Eliminated many unsafe features of C++.
• Supports concurrency “is the ability to run several programs or several
parts of a program in parallel”
• Libraries for GUIs, database access
• Portable: Java Virtual Machine concept (jvm), JIT compilers
• Widely used for Web programming
• Use increased faster than any previous language

Scripting Languages for the Web


• JavaScript
– A client-side HTML-embedded scripting language, often used to create
dynamic HTML documents
– Purely interpreted
– Related to Java only through similar syntax
• PHP
– A server-side HTML-embedded scripting language, often used for form
processing and database access through the Web
– Purely interpreted
• Python
• Ruby

The Flagship .NET Language: C#


• Based on C++ , Java, and Delphi
• Includes pointers, delegates, properties, enumeration types, a limited
kind of dynamic typing, and anonymous types
• Is evolving rapidly

Ch3;
Syntax: the form or structure of the expressions, statements, and program
units
Semantics: the meaning of the expressions, statements, and program units
Syntax and semantics: provide a language’s definition
Users of a language definition
• Other language designers • Implementers • Programmers (the users of the
language)
• A sentence is a string of characters over some alphabet.
• A language is a set of sentences.
• A lexeme is the lowest level syntactic unit of a language
• A token is a category of lexemes (e.g., identifier)

Describing syntax
• The strings of a language are called sentences or statements.
• programs are strings of lexemes rather than of characters.
• Lexemes are variable names, class, operators, numeric, and symbolic data.
• Each lexeme is belong to specific token.
• Token of a language is a category of its lexemes

Formal Definition of Languages


• Recognizers (Compiler)
– A recognition device reads input strings over the alphabet of the
language and decides whether the input strings belong to the language
(compiler can check the syntax of whether a sentence is syntactically
correct or no).
• Generators
– A device that generates sentences of a language.
– One can determine if the syntax of a particular sentence is
syntactically correct by comparing it to the structure of the
generator.

Describing syntax methods


• Grammar is a language generation method to describe the syntax of the
language.
1- Backus-Naur Form (BNF) and Context-Free Grammars
2- Extended BNF

•Context-Free Grammars
– Developed by Noam Chomsky
– Language generators, meant to describe the while syntax of natural
languages.
– Define a class of languages called context-free languages
• Backus-Naur
– Invented by John Backus to describe the syntax of Algol 58
– BNF is equivalent to context-free grammars
BNF Fundamentals
• BNF is a grammar consists of a finite set of rules.
• A rule has left-hand side (LHS), and right-hand side (RHS).
• Left-hand side (LHS), consists of a nonterminal symbol.
• Right-hand side (RHS), consists a string of terminals and/or
nonterminals. (definition of nonterminal symbol).
• Nonterminal is description of syntactic structure. enclosed with angle
brackets <>
• Terminals are lexemes or tokens, here is =.

-A start symbol is a special element of the nonterminals of a grammar.


-nonterminal symbol can have more than one RHS

Sentences belong to Grammar 1 are: 1+2, 2+1,1-2,2-1,4*3 ……..


Etc but
1+2+3, 3 , 10-3, 4+5*5 ( not belong)

All generated sentences include only terminal symbols.

You might also like