Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dr. Muhammed Al-Mulhem 1ICS535-101 ICS 535 Design and Implementation of Programming Languages Part 1 Introduction (Chapter 1)

Similar presentations


Presentation on theme: "Dr. Muhammed Al-Mulhem 1ICS535-101 ICS 535 Design and Implementation of Programming Languages Part 1 Introduction (Chapter 1)"— Presentation transcript:

1 Dr. Muhammed Al-Mulhem 1ICS535-101 ICS 535 Design and Implementation of Programming Languages Part 1 Introduction (Chapter 1)

2 Dr. Muhammed Al-Mulhem 2ICS535-101 Programming Languages What is a programming language? What is a programming language? 1. A programming language is the medium of expression in the art of computer programming. [Mitchell] 2. Any notation for the description of algorithms and data structures may be termed as a programming language. [Pratt.]

3 Dr. Muhammed Al-Mulhem 3ICS535-101 Programming Languages (Cont.) What is a programming language? What is a programming language? No general consensus on the precise definition of programming language. Important aspects include function, target, constructs, and expressive power. Function: A programming language is a language used to write computer programs, which instruct a computer to perform some kind of computation and/or organize the flow of control between mechanical devices.computer programscomputation

4 Dr. Muhammed Al-Mulhem 4ICS535-101 Programming Languages (Cont.) Target: Programming languages differ from natural languages in that natural languages are only used for interaction between people, while programming languages also allow humans to communicate instructions to machines. natural languages

5 Dr. Muhammed Al-Mulhem 5ICS535-101 Programming Languages (Cont.) Constructs: Programming languages may contain constructs for defining and manipulating data structures or for controlling the flow of execution.data structuresflow of execution Expressive power: The theory of computation classifies languages by the computations they can express.theory of computation

6 Dr. Muhammed Al-Mulhem 6ICS535-101 Taxonomy of Programming Languages Hundreds of programming languages have been devloped. Hundreds of programming languages have been devloped. No single overall classification scheme for programming languages. No single overall classification scheme for programming languages. One classification is the domain of use. One classification is the domain of use. Another classification by purpose like general purpose, system programming, scripting, and concurrent. Another classification by purpose like general purpose, system programming, scripting, and concurrent. Some languages have multiple characteristics like Java: Object-oriented and concurrent. Some languages have multiple characteristics like Java: Object-oriented and concurrent.

7 Dr. Muhammed Al-Mulhem 7ICS535-101 Taxonomy of Programming Languages Commonly, PLs are divided into programming paradigms (procedural/imperative, object-oriented, functional, and logic). Commonly, PLs are divided into programming paradigms (procedural/imperative, object-oriented, functional, and logic).

8 Dr. Muhammed Al-Mulhem 8ICS535-101 Programming Languages Diversity One of the things that makes programming languages so fascinating is their diversity. One of the things that makes programming languages so fascinating is their diversity. Imperative Languages Imperative Languages int fact (int n) { int sofar = 1; while ( n > 0 ) sofar *= n--; return sofar; } Functional Languages Functional Languages (defun fact (x) (if ( <= x 0 ) 1 (* x (fact ( - x 1)))))

9 Dr. Muhammed Al-Mulhem 9ICS535-101 Programming Languages Diversity Logic Programming Languages Logic Programming Languages fact(1, 1). fact(N, M) :- X is N – 1, fact(X, Y), M is N * Y.

10 Dr. Muhammed Al-Mulhem 10ICS535-101 Programming Languages Diversity Object-Oriented Languages Object-Oriented Languages public class MyInt { private int value; public MyInt (int value) { this.value = value; this.value = value;} public int getValue() { return value; return value;} public MyInt getFact() { return new MyInt (fact(value)); return new MyInt (fact(value));} private int fact(int n) { int sofar = 1; int sofar = 1; while (n > 1) sofar *= n--; return sofar; }}

11 Dr. Muhammed Al-Mulhem 11ICS535-101 Criteria for a good programming language An ideal programming language will make it easy for programmers to write programs concisely and clearly. An ideal programming language will make it easy for programmers to write programs concisely and clearly. A good programming language will help others read programs and understand how they work. A good programming language will help others read programs and understand how they work. A good language for large-scale programming will help programmers manage the interaction among software components effectively. A good language for large-scale programming will help programmers manage the interaction among software components effectively.

12 Dr. Muhammed Al-Mulhem 12ICS535-101 Trade-offs in Programming Language Design Some language features make it easy for us to write programs quickly, but may make it harder for us to design testing tools or methods. Some language features make it easy for us to write programs quickly, but may make it harder for us to design testing tools or methods. Some language constructs make it easier for a compiler to optimize programs, but may make programming cumbersome. Some language constructs make it easier for a compiler to optimize programs, but may make programming cumbersome. Different computing environments and applications require different program characteristics, different programming language designers have chosen different trade-offs. Different computing environments and applications require different program characteristics, different programming language designers have chosen different trade-offs. One reason for discussing historical languages is that this gives us a realistic way to understand programming language design trade-offs. One reason for discussing historical languages is that this gives us a realistic way to understand programming language design trade-offs.

13 Dr. Muhammed Al-Mulhem 13ICS535-101 Trade-offs Example APL (named after the book A Programming Language)[5] is an interactive array-oriented language APL (named after the book A Programming Language)[5] is an interactive array-oriented language[5]interactivearray-oriented language[5]interactivearray-oriented language It is concise, using symbols rather than words and applying functions to entire arrays without using explicit loops. It is concise, using symbols rather than words and applying functions to entire arrays without using explicit loops.arrays An expression to find all prime numbers from 1 to R. An expression to find all prime numbers from 1 to R.prime numbersprime numbers (~R ∊ R ∘.×R)/R←1↓ ⍳ R

14 Dr. Muhammed Al-Mulhem 14ICS535-101 (~R ∊ R ∘.×R)/R←1↓ ⍳ R Executed from right to left, this means: Executed from right to left, this means: ιR creates a vector containing integers from 1 to R (if R = 6 at the beginning of the program, ιR is 1 2 3 4 5 6) ιR creates a vector containing integers from 1 to R (if R = 6 at the beginning of the program, ιR is 1 2 3 4 5 6)integers Drop first element of this vector (↓ function), i.e. 1. So 1↓ιR is 2 3 4 5 6 Drop first element of this vector (↓ function), i.e. 1. So 1↓ιR is 2 3 4 5 6 Set R to the new vector (←, assignment primitive), i.e. 2 3 4 5 6 Set R to the new vector (←, assignment primitive), i.e. 2 3 4 5 6 Generate outer product of R multiplied by R, i.e. a matrix which is the multiplication table of R by R (°.× function), i.e. Generate outer product of R multiplied by R, i.e. a matrix which is the multiplication table of R by R (°.× function), i.e.outer productmultiplication tableouter productmultiplication table46810126912151881216202410152025301218243036 Build a vector the same length as R with 1 in each place where the corresponding number in R is in the outer product matrix (ε, set inclusion function), i.e. 0 0 1 0 1 Build a vector the same length as R with 1 in each place where the corresponding number in R is in the outer product matrix (ε, set inclusion function), i.e. 0 0 1 0 1 Logically negate the values in the vector (~, negation function), i.e. 1 1 0 1 0 Logically negate the values in the vector (~, negation function), i.e. 1 1 0 1 0 Select the items in R for which the corresponding element is 1 (/ function), i.e. 2 3 5 Select the items in R for which the corresponding element is 1 (/ function), i.e. 2 3 5

15 Dr. Muhammed Al-Mulhem 15ICS535-101 1.3 PLs Histroy 1950s Algol, Cobol, Fortran, Lisp 1950s Algol, Cobol, Fortran, Lisp 1980sObject-orientation 1980sObject-orientation 1990sNetwork-centered computing 1990sNetwork-centered computing 2000sDiversity of computing devices, wireless and cellular computing. 2000sDiversity of computing devices, wireless and cellular computing.

16 Dr. Muhammed Al-Mulhem 16ICS535-101 A Summary of Concepts and Languages ThreadsObjectsExceptionsFunctionsExpressionsLanguage LISP C Pascal Smalltalk C++ ML Java

17 Dr. Muhammed Al-Mulhem 17ICS535-101 Programming Languages Development Two main aspects: Design and Implementation Two main aspects: Design and Implementation Design: Two specifications Design: Two specifications Syntax Syntax Semantics Semantics Implementation: Two approaches: Implementation: Two approaches: Interpretation Interpretation Compilation Compilation


Download ppt "Dr. Muhammed Al-Mulhem 1ICS535-101 ICS 535 Design and Implementation of Programming Languages Part 1 Introduction (Chapter 1)"

Similar presentations


Ads by Google