Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.

Similar presentations

Presentation on theme: "Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages."— Presentation transcript:

1 Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages

2 Copyright © 2006 Addison-Wesley. All rights reserved.1-2 Module 1: Basics of Programming Languages Covering: –Chapter 1:Preliminaries –Chapter 2:Evolution of the Major Programming Languages –Chapter 3:Describing Syntax and Semantics

3 Copyright © 2006 Addison-Wesley. All rights reserved.1-3 What is a Programming Language? A language for expressing instructions to a computer. A series of instructions written by a programmer according to a given set of rules or conventions (“syntax”). A computer language that programmers utilize to create programs. C, Perl, Java, BASIC, and COBOL are examples of programming languages.

4 Copyright © 2006 Addison-Wesley. All rights reserved.1-4 Why Study Programming Languages? Increase ability to express ideas Improve background for choosing appropriate languages Ability to learn new languages Understand significance of implementation Ability to design new languages Overall advancement of computing

5 Copyright © 2006 Addison-Wesley. All rights reserved.1-5 Programming Domains Scientific applications –Large number of floating point computations –Fortran Business applications –Produce reports, use decimal numbers and characters –COBOL Artificial intelligence –Symbols rather than numbers manipulated –LISP Systems programming –Need efficiency –C Web Software –A number of languages: markup (e.g., XHTML), scripting (e.g., PHP), general-purpose (e.g., Java)

6 Copyright © 2006 Addison-Wesley. All rights reserved.1-6 Language Evaluation Criteria 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: conformance to specifications (i.e., performs to its specifications) Cost: the ultimate total cost

7 Copyright © 2006 Addison-Wesley. All rights reserved.1-7 Characteristics that contribute to the Readability Factors influencing Readability Overall simplicity –A manageable set constructs (languages with more constructs are more difficult to learn) –Few feature multiplicity--means of doing the same operation-- (increment an integer in Java can be done in four ways, C=C+1, C+=1, C++, ++C). –Minimal operator overloading (It is Ok to use “+” for integer and float addition, but not for array addition.) Orthogonality –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. –Every possible combination is legal and meaningful.

8 Copyright © 2006 Addison-Wesley. All rights reserved.1-8 Evaluation Criteria: Readability Control statements –The presence of well-known control structures (e.g., while statement) –Goto severely reduces the readability. while (incr = 20) goto out While (sum 100) goto next; Sum +=incr;sum += incr; }goto loop2 Incr++;next: incr++; }goto loop1; out: Data types and structures –The presence of adequate facilities for defining data structures improve readability. –Using record data types is more readable than using a number of arrays to define employee records. Syntax considerations –Identifier lengths. Fixed length makes it less readable—Fortaran. –Special words to form compound statements (while {…}.VS. while … end while).

9 Copyright © 2006 Addison-Wesley. All rights reserved.1-9 Evaluation Criteria: Writability Factors influencing Writability Simplicity and orthogonality –Few constructs, a small number of primitives, a small set of rules for combining them Support for abstraction –The ability to hide the details of implementation. Expressivity –A set of convenient ways of specifying operations –Example: count++ instead of count = count + 1 of in C.

10 Copyright © 2006 Addison-Wesley. All rights reserved.1-10 Evaluation Criteria: Reliability Factors influencing Reliability Type checking –Testing for type errors - good for reliability Exception handling –Intercept run-time errors and take corrective measures - good for reliability Aliasing –Presence of two or more distinct names for the same memory location - bad for reliability

11 Copyright © 2006 Addison-Wesley. All rights reserved.1-11 Evaluation Criteria: Cost Total cost consists of: Training programmers to use a language. Compiling programs Executing programs Language implementation system: availability of free compilers Reliability: poor reliability leads to high costs Maintaining programs

12 Copyright © 2006 Addison-Wesley. All rights reserved.1-12 Influences on Language Design The most important factors are: Computer Architecture Programming Methodologies

13 Copyright © 2006 Addison-Wesley. All rights reserved.1-13 Computer Architecture Influence Von Neumann architecture –Data and programs stored in memory –Memory is separate from CPU –Instructions and data are piped from memory to CPU Imperative languages, most dominant, because of von Neumann computers Basis for imperative languages Variables model memory cells Assignment statements model piping

14 Copyright © 2006 Addison-Wesley. All rights reserved.1-14 Programming Methodologies Influences 1950s and early 1960s: Simple applications; worry about machine efficiency Late 1960s: People efficiency became important; readability, better control structures –structured programming Late 1970s: Process-oriented to data-oriented –data abstraction Middle 1980s: Object-oriented programming –data abstraction + inheritance + polymorphism

15 Copyright © 2006 Addison-Wesley. All rights reserved.1-15 Language Categories Four categories of PLs Imperative –Central features are variables, and assignment statements. –Examples: C, Pascal Functional –Main means of making computations is by applying functions to given parameters –Examples: LISP, Scheme Logic –Rule-based (rules are specified in no particular order) –Example: Prolog Object-oriented –Data abstraction, inheritance, late binding –Examples: Java, C++

16 Copyright © 2006 Addison-Wesley. All rights reserved.1-16 Language Design Trade-Offs Reliability vs. cost of execution –Conflicting criteria –Example: Java demands all references to array elements be checked for proper indexing but that leads to increased execution costs Readability vs. writability –Another conflicting criteria –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 vs. reliability –Another conflicting criteria –Example: C++ pointers are powerful and very flexible but not reliably used

17 Copyright © 2006 Addison-Wesley. All rights reserved.1-17 Implementation Methods Compilation Pure Interpretation Hybrid Implementation Systems

18 Copyright © 2006 Addison-Wesley. All rights reserved.1-18 Compilation Translate a high-level program (source code) into machine code (machine code) Slow translation, fast execution Compilation process has several phases: –lexical analysis: converts characters in the source program into lexical units –syntax analysis: transforms lexical units into parse trees which represent the syntactic structure of the program –Semantics analysis: generate intermediate code –code generation: machine code is generated

19 Copyright © 2006 Addison-Wesley. All rights reserved.1-19 Pure Interpretation No translation Programs are interpreted by another program called an interpreter. The interpreter acts as a software simulation for the a machine that deals with high-level language program statements rather than machine instruction. Becoming rare on high-level languages

20 Copyright © 2006 Addison-Wesley. All rights reserved.1-20 Hybrid Implementation Systems A compromise between compilers and pure interpreters A high-level language program is translated to an intermediate code The intermediate code is then interpreted Examples –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) –There are now systems that translate Java byte code into machine code for faster execution.

21 Copyright © 2006 Addison-Wesley. All rights reserved.1-21 Assignment #1 Read a tutorial on C language given at the following link General/C_basics/ General/C_basics/ Prepare and submit a one page summary, in your own words. (Deadline Saturday, October 18 2008, in class)

Download ppt "Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages."

Similar presentations

Ads by Google