isn’t one language enough ? {week 01}

20
Isn’t one language enough? {week 01} The College of Saint Rose CIS 433 – Programming Languages David Goldschmidt, Ph.D. rom Concepts of Programming Languages, 9th edition by Robert W. Sebesta, Addison-Wesley, 2010, ISBN 0-13-607347-6

Upload: brinly

Post on 05-Jan-2016

29 views

Category:

Documents


0 download

DESCRIPTION

The College of Saint Rose CIS 433 – Programming Languages David Goldschmidt, Ph.D. Isn’t one language enough ? {week 01}. from Concepts of Programming Languages , 9th edition by Robert W. Sebesta, Addison-Wesley, 2010, ISBN 0-13-607347-6. Programming languages. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Isn’t one language enough ? {week 01}

Isn’t one language enough?{week 01}

The College of Saint RoseCIS 433 – Programming LanguagesDavid Goldschmidt, Ph.D.

from Concepts of Programming Languages, 9th edition by Robert W. Sebesta, Addison-Wesley, 2010, ISBN 0-13-607347-6

Page 2: Isn’t one language enough ? {week 01}

Programming languages

Why study programming languages? Required course... Diverse set of tools in your

programming toolbox Increased capacity to express ideas Increased ability to build efficient and

easy-to-maintain software systems

Why so many languages?

Page 3: Isn’t one language enough ? {week 01}

Programming domains (i) Languages are not entirely general-

purpose Business applications (typically distributed)

▪ Process data, output reports, control transactions▪ Increasingly distributed

Manufacturing and control systems▪ Reliability and non-stop operation

Entertainment and Web applications▪ Wide variety of online and device requirements▪ Portability

Page 4: Isn’t one language enough ? {week 01}

Programming domains (ii) Languages are not entirely general-

purpose Scientific applications

▪ Often computationally intensive Artificial intelligence and research applications

▪ Represent and manipulate symbols instead of numbers

▪ Also often computationally intensive Systems and network programming

▪ Operating system and support programs▪ Requires efficient non-stop operations

Page 5: Isn’t one language enough ? {week 01}

Language evaluation criteria How can we evaluate a programming

language? Goals of the language Readability Writability Portability Reliability (of the language—e.g. C++ vs. Java) Cost ($$$, training costs, compilation process) Ease of maintenance (of compilers and source

code)

Page 6: Isn’t one language enough ? {week 01}

Language design tradeoffs Readability vs. writability

Perl is flexible and expressive—very writable As a result, Perl is sometimes hard to read...

Writability vs. reliability C and C++ both provide flexible use of

pointers As a result, C and C++ can be unreliably used

▪ Thus producing core dumps, null pointer references

Page 7: Isn’t one language enough ? {week 01}

Von Neumann architecture

Imperative Languages Data and programs are both stored in

memory Variables mimic memory Assignment statements Arithmetic operations Iterative repetition Control structures etc.

Page 8: Isn’t one language enough ? {week 01}

A brief history of programming 1940s – von Neumann architecture 1950s – simple applications (hardware focus) 1960s/1970s – structured programming

Costs shifted from hardware to software Complexity and size of software grew dramatically

1970s/1980s – data-oriented program design 1980s – object-oriented program design

Data abstraction + Inheritance + Polymorphism 1990s/2000s – network/Web applications 2010s – mobile applications

Page 9: Isn’t one language enough ? {week 01}

Language categories (i)

Imperative languages: Evolved from the von Neumann

architecture Focus on variables, assignment and

arithmetic statements, control structures, and iterative constructs

e.g. C, C++, Pascal, C#, Java, Perl, JavaScript, etc.

Page 10: Isn’t one language enough ? {week 01}

Language categories (ii)

Functional languages: Apply (often recursive) functions to

parameters Usually an interpretive language e.g. LISP, Scheme

Logic languages: Rule-based approach to build a knowledge

base Perform queries against knowledge base e.g. Prolog (also the Semantic Web)

Page 11: Isn’t one language enough ? {week 01}

Language categories (iii)

Object-oriented languages: Evolved out of imperative languages Data abstraction, inheritance, polymorphism,

late binding e.g. C++, Java, C#, Smalltalk, Eiffel

Markup and Web languages: Web-based or application-specific markup

languages specify layout of Web pages, database schemas, etc.

e.g. XHTML, XML, XSLT, MathML, RDF, etc.

Page 12: Isn’t one language enough ? {week 01}

How low can you go?

Low-level languages

LDA #47STA $570DEXJSR $817CPX #0BNE #14

assembly code

100010100010010010101011010010111011110001010001

machine code(executable)

translation program

(assembler)

Page 13: Isn’t one language enough ? {week 01}

High-level languages (i)

#include <iostream>

int main(){ float x; cout << " ...

C++ source code

10001010001001001010101101001011

intermediate code(object code)

translation program

(compiler)

100010100010010010101011010010111011110001010001

machine code(executable)

linker program

10001010001001001010101101001011

intermediate code ofprecompiled libraries

(<iostream> object code)

Page 14: Isn’t one language enough ? {week 01}

High-level languages (ii)

public static void main( String[] args ){ float x;

System.out. println( "

...

Java source code

7A 56 789F FE F265 58 9976 6D 4E

intermediate code(byte code)

translation program

(compiler)

virtual machine

(JVM)

A6 65 5498 8F ABAE 33 388F DA 44

intermediate code ofprecompiled libraries

(java.util.Scanner byte code)

program execution

Page 15: Isn’t one language enough ? {week 01}

Layers

Page 16: Isn’t one language enough ? {week 01}

Compilation

lexical analysis groupscharacters into lexical units

syntax analysis transformslexical units into parse trees

a parse tree representsthe syntactic structure

of the program

analyzes parse trees toproduce intermediate code

transforms intermediatecode into executable

machine code

Page 17: Isn’t one language enough ? {week 01}

Interpreter

source code is bothinterpreted and executed

via an interpreterREM COMMENTLET X = 5LET Y = 8PRINT XPRINT YLET Z = XPRINT ZINPUT A$

BASIC source code

Page 18: Isn’t one language enough ? {week 01}

Hybrid

lexical analysis groupscharacters into lexical units

syntax analysis transformslexical units into parse trees

analyzes parse trees toproduce intermediate code

intermediate codeexecuted via

a virtual machine

Page 19: Isn’t one language enough ? {week 01}

Preprocessing

A preprocessor transforms source codeinto preprocessed source code

Sourceprogram

Preprocessor

Preprocessedsource program

#include <stdio.h>

#define PI 3.14159#define E 2.781828

#ifdef DEBUG_MODE

#endif

C source code

Page 20: Isn’t one language enough ? {week 01}

What next?

Read and study Chapters 1 and 2

Do Exercises at the end of Chapter 1

Categorize every programming language as compiled, interpreted, hybrid, etc.