Isn’t one language enough ? {week 01}

Post on 05-Jan-2016

29 views 0 download

Tags:

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

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

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?

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

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

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)

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

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.

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

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.

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)

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.

How low can you go?

Low-level languages

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

assembly code

100010100010010010101011010010111011110001010001

machine code(executable)

translation program

(assembler)

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)

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

Layers

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

Interpreter

source code is bothinterpreted and executed

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

BASIC source code

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

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

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.