Unformatted text preview:

Abdelghani Bellaachia, Advanced Software Paradigms Page: 1 Programming Paradigms  Programming languages  A Programming language is a notational system for describing tasks/computations in a machine and human readable form.  Most computer languages are designed to facilitate certain operations and not others: numerical computation, or text manipulation, or I/O.  More broadly, a computer language typically embodies a particular programming paradigm.  Characteristics of a programming language: Every language has syntax and semantics: - Syntax: The syntax of a program is the form of its declarations, expressions, statements and program units. - Semantic: The semantic of a program is concerned with the meaning of its program.  Which programming language?  Since a task can be solved in different ways (paradigms), the language used to describe the solution differs in abstractions, structures due to the way in which the problem is solved.Abdelghani Bellaachia, Advanced Software Paradigms Page: 2  There is no theory that dictates the best paradigm to solve a particular problem.  Efforts by Sebesta in his Concepts of Programming Languages book: o He based his evaluation criteria on three factors and 9 characteristics. o The three criteria (R,W,R) are:  Readability  Writability  Reliability o The nine characteristics are:  Simpilicity/orthogonality(R,W,R): - “Orthogonality in a programming language means that a relatively 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” [Sebesta] - Relatively small set of primitive constructions combined in a number (of logically consistent) ways to provide the required control and data structures. - The concepts of a programming language do not interfere with each other: different methods of passing parameters. - Non-orthogonality: means exceptions to the general language rules, which make it harder to learn. It means that you cannot combine language features in all possible ways. - Examples of non-orthogonal languages:  Arrays in Perl4 can't contain other arrays.  In C, parameters can be passed by value, unless they are arrays, in which case they are passed by reference.Abdelghani Bellaachia, Advanced Software Paradigms Page: 3  In C++, we start a Switch statement by using the Switch keyword, followed by the expression that we would like to evaluate. This expression is just a single variable or a complex expression that must evaluatge to an integral type (that is, char, short, int, long, or enum). Floating point variables and other non-integral types may not be used here. o Good Orthogonality:  Functional languages (Lisp, ML,etc.): everything is a function. o Given a programming language:  m options on x axis  n options on y axis  Total number of possible interactions: - mn interactions  Total number of basic facts to learn: - m+n facts  Total number of exceptions: - e exceptions  Basic elements of the language: - m+n+e facts and exceptions to be learned  Total number of features: - mn-e  Objective: - m+n+e << mn-e  Control structures (R,W,R)  Data types and structures (R,W,R): o Adequate data types help increase the readability of a programming language. o Example:  Boolean data type:Abdelghani Bellaachia, Advanced Software Paradigms Page: 4 - How do you interpret the followingstatement: visited = 1; o Is this an assignment or a conditional statement?  Syntax design (R,W,R): o Special words which is easier to read:  braces or “if…end if” provided by Ada?  Braces or “Begin..end” provided in Pascal.  Support for abstraction (,W,R): o Ability to hide detail o Abstraction is an important factor in the writability of a language. o Two types of abstraction: process and data  Process: subprograms and modules  Data: structures, records, objects  Expressivity (,W,R): o Programming languages with poor support for abstraction and weak primitives will have poor writability. o Short circuit evaluation for Boolean expressions:  Ada uses “and then” and “or else”  Java uses: - “&&” and “||” (regular operator for “and” and “or” operators - “&” and “|” for short circuit evaluation  Type checking (,,R)  Exception handling (,,R)  Restricted aliasing (,,R): o example: (C)Abdelghani Bellaachia, Advanced Software Paradigms Page: 5 int salary, *p_salary; salary = 98000; p_salary = &salary; salary and *p_salary are aliases. - Maintainability o Factoring: The ability to group related features into a single unit. Use subroutines to group related computations units so they can be re-used in different parts of the application. o Locality: The ability to implement information hiding so that changes to a grouping (either control or data) are transparent. - Cost o Programmer training o Software creation o Compilation o Execution o Compiler cost o Poor reliability o Maintenance - Others: portability and generalityAbdelghani Bellaachia, Advanced Software Paradigms Page: 6  Programming paradigms - The paradigms are not exclusive, but reflect the different emphasis of language designers. Most practical languages embody features of more than one paradigm. - Classification: Imperative/ Algorithmic Declarative Object-Oriented Functional Programming Logic Programming Algol Cobol PL/1 Ada C Modula-3 Lisp Haskell ML Miranda APL Prolog Smalltalk Simula C++ Java  Imperative paradigms - It is based on commands that update variables in storage. The Latin word imperare means “to command”. - The language provides statements, such as assignment statements, which explicitly change the state of the memory of the computer. - This model closely matches the actual executions of computer and usually has high execution efficiency. - Many people also find the imperative paradigm to be a more natural way of expressing themselves.Abdelghani Bellaachia, Advanced Software Paradigms Page: 7  Functional programming paradigms - In this paradigm we express computations as the evaluation of mathematical functions. - Functional programming paradigms treat values as single entities. Unlike variables, values are never modified. Instead, values are transformed into new values. - Computations of functional languages are performed


View Full Document

GWU CSCI 210 - Programming Paradigms

Download Programming Paradigms
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Programming Paradigms and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Programming Paradigms 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?