Comp 333: Concepts of Programming Languages Fall 2016

Similar documents
Introduction. A. Bellaachia Page: 1

Lecture 2. A Historical View

Language Translation, History. CS152. Chris Pollett. Sep. 3, 2008.

8/27/17. CS-3304 Introduction. What will you learn? Semester Outline. Websites INTRODUCTION TO PROGRAMMING LANGUAGES

Continuations provide a novel way to suspend and reexecute

Chapter 2. 5 * B => A V 6 7 (subscripts) S 1.n 1.n (data types)

Programming Languages, Summary CSC419; Odelia Schwartz

2. Evolution of the Major Programming languages

Chapter 2. Pseudocodes: Speedcoding. 2.2 Minimal Hardware Programming: Pseudocodes. Evolution of the Major Programming Languages

LECTURE 1. Overview and History

8/23/18. Programming Language Genealogy The Evolution of Programming Languages. Zuse s Plankalkül. Plankalkül Syntax. Machine Code

CSCI 3136 Principles of Programming Languages

Programming Languages 2nd edition Tucker and Noonan"

Lecture 09. Ada to Software Engineering. Mr. Mubashir Ali Lecturer (Dept. of Computer Science)

General Concepts. Abstraction Computational Paradigms Implementation Application Domains Influence on Success Influences on Design

CS558 Programming Languages

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

1/14/2014. Introduction to CSE 1325 Object Oriented Programming (Using Java) Introduction (Cont.) Introduction

Chapter 2. Evolution of the Major Programming Languages

G Programming Languages - Fall 2012

Concepts of Programming Languages

CS 314 Principles of Programming Languages

Outline. Programming Languages 1/16/18 PROGRAMMING LANGUAGE FOUNDATIONS AND HISTORY. Current

Chapter 1. Preliminaries

Principles of Programming Languages. Lecture Outline

Programmiersprachen (Programming Languages)

Chapter 2. Chapter 2

CS101 Introduction to Programming Languages and Compilers

Lecture 15: Iteration and Recursion

Introduction to Programming

Evolution of the Major Programming Languages

CS558 Programming Languages

CS 415 Midterm Exam Spring 2002

Topic IV. Parameters. Chapter 5 of Programming languages: Concepts & constructs by R. Sethi (2ND EDITION). Addison-Wesley, 1996.

Chapter 2. Evolution of the Major Programming Languages

St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

INSTITUTE OF AERONAUTICAL ENGINEERING

Evolution of PL s. EECS 476, Prog. Lang. Design/ page 1

Chapter 5. Names, Bindings, and Scopes

Topic IV. Block-structured procedural languages Algol and Pascal. References:

G Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University

CSCI.4430/6969 Programming Languages Lecture Notes

Lecture 1: Course Introduction

Com S 541. Programming Languages I

CS 314 Principles of Programming Languages

CS 330 Lecture 18. Symbol table. C scope rules. Declarations. Chapter 5 Louden Outline

Chapter 2 Preview. Preview. History of Programming Languages. History of Programming Languages. History of Programming Languages

Organization of Programming Languages (CSE452) Why are there so many programming languages? What makes a language successful?

Chapter 2. Evolution of the Major Programming Languages ISBN

Introduction to Scientific Computing Languages

CSC231 C Tutorial Fall 2018 Introduction to C

6. Names, Scopes, and Bindings

Introduction to Scientific Computing Languages

Lecture 1: Course Introduction

Chapter 1. Preliminaries

NOTE: Answer ANY FOUR of the following 6 sections:

Chapter 1 Preliminaries

The results for a few specific cases below are indicated. allequal ([1,1,1,1]) should return true allequal ([1,1,2,1]) should return false

G Programming Languages - Fall 2012

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

Appendix to Topic IV

Chapter 2. Evolution of the Major Programming Languages ISBN

Imperative Programming Languages (IPL)

Functional Programming. Big Picture. Design of Programming Languages

CSCI-GA Scripting Languages

Imperative Programming

Evolution of Fortran. Presented by: Tauqeer Ahmad. Seminar on Languages for Scientific Computing

Design Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8

CSC 533: Organization of Programming Languages. Spring 2005

MIDTERM EXAMINATION - CS130 - Spring 2005

Chapter 7. - FORTRAN I control statements were based directly on IBM 704 hardware

PROGRAMMAZIONE I A.A. 2017/2018

Informatica 3 Syntax and Semantics

Chapter 2 Evolution of the Major Programming Languages Chapter 2 Topics

22c:111 Programming Language Concepts. Fall Types I

Lecture Overview. [Scott, chapter 7] [Sebesta, chapter 6]

Compiling and Interpreting Programming. Overview of Compilers and Interpreters

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming

CS383 PROGRAMMING LANGUAGES. Kenny Q. Zhu Dept. of Computer Science Shanghai Jiao Tong University

Programs are: CMPSCI 105/119/120: Programming, Flowchar<ng, and Running Program Flowcharts

SOFTWARE ARCHITECTURE 6. LISP

Logic Programming II & Revision

R13 SET Discuss how producer-consumer problem and Dining philosopher s problem are solved using concurrency in ADA.

Seminar in Programming Languages

Test 1 Summer 2014 Multiple Choice. Write your answer to the LEFT of each problem. 5 points each 1. Preprocessor macros are associated with: A. C B.

CS A331 Programming Language Concepts

Lecture 4 Memory Management

MIDTERM EXAM (Solutions)

Is it ever useful to be confident that a problem is hard?

Implementing Subprograms

HANDLING NONLOCAL REFERENCES

CSc 372. Comparative Programming Languages. 2 : Functional Programming. Department of Computer Science University of Arizona

CPS 506 Comparative Programming Languages. Programming Language Paradigm

CS 242. Fundamentals. Reading: See last slide

CS 3360 Design and Implementation of Programming Languages. Exam 1

Chapter 8 Statement-Level Control Structures

15. Functional Programming

Final-Term Papers Solved MCQS with Reference

System Software Assignment 1 Runtime Support for Procedures

G Programming Languages - Fall 2012

Transcription:

Comp 333: Concepts of Programming Languages Fall 2016 Instructor: Professor Schwartz History Syntax and Semantics Compilers Language Constructs Names, Binding, Scoping, Data Types Expressions, Control Structures, Subprograms Programming Language Types Imperative Functional Logic Concurrent Object Oriented Scripting Languages Chapter 1 FALL 2016 2 1

Imperative Languages C, C++, Fortran, Java, Pascal Functional Languages Lisp, Scheme, ML, Haskell Logic Programming Languages Prolog Object-Oriented Languages Java, C++, Smalltalk, OCAML Scripting Languages Javascript, Perl, Python Tiobe Programming Community Index http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html Chapter 1 FALL 2016 3 Aug 2016 Aug 2015 Change Program ming Language Ratings Change 1 1 Java 19.010% -0.26% 2 2 C 11.303% -3.43% 3 3 C++ 5.800% -1.94% 4 4 C# 4.907% +0.07% 5 5 Python 4.404% +0.34% Exercise: Check out the Tiobe Community Index. Where do the ratings come from? Chapter 1 FALL 2016 4 2

Chapter 1 FALL 2016 5 TIOBE Programming Community Index Definition Basically the calculation comes down to counting hits for the search query <language> programming on various search engines. See www.tiobe.com for further details of choice of search engines and formula for calculation the ratings. Chapter 1 FALL 2016 6 3

Different program domains Scientific applications Business applications Artificial Intelligence Systems programming Web programming Embedded Systems DOD Education Chapter 1 FALL 2016 7 New languages usually evolve from older languages Features are added or modified to make new languages easier to read and write compile and run faster better able to solve a class of problems more modular ( and hence more reusable) more reliable and more maintainable Chapter 1 FALL 2016 8 4

Handout: Genealogy of Selected Programming Languages Scott Text Appendix A (page 860) Chapter 1 FALL 2016 9 Chapter 1 FALL 2016 10 5

Variables: x,y,z Arithmetic Expressions: z = x + 4 * y Data types: int, double, string Control structures: loops, conditionals Block structure: local scope rules Functions and procedures Data structures: arrays, records, pointers Recursion Support for concurrency: threads Object -Oriented Language Features classes, objects, inheritance, polymorphism Chapter 1 SP16 11 Symbolic locations and opcodes Computation of N = I + J ( Pentium 4) FORMULA: MOV EAX,I ADD EAX, J MOV N, EAX I DD 3 ;reserve 4 bytes J DD 4 ;reserve 4 bytes N DD 0 ;reserve 4 bytes Chapter 1 FALL 2016 12 6

Fortran Mid 1950s Developed by John Backus and his group at IBM Used to perform math computations ( formulas) One of the first high level languages Continued development Fortran IV, Fortran77,.. Features Variables, expressions, statements Arrays Iteration and conditional branching Subroutines ( independently compiled) FORMAT for input and output Chapter 1 FALL 2016 13 Fortran IV Example DIMENSION X(10) C C Skipping code that inputs numbers into array X READ(5,*) N is the FORTRAN READ statement R= 0; DO 60 J = 1,10 IF( X(J).LT. 0) GOTO 200 R = R + ( X(J) * X(J) / J ) 60 CONTINUE WRITE(5, 80) R 80 FORMAT( 1X, R =, F20.10) STOP Exercise: Translate this FORTRAN program to a complete Java program 200 WRITE(5, 210) 210 FORMAT(1X, NEGATIVE NUMBER DETECTED ) Chapter 1 FALL 2016 14 7

Class Exercise Translate the following pseudocode into FORTRAN code using the example FORTRAN program. You may also use the goto without an if. sum = 0.0 while ( sum < 10) { write Enter a number read X sum = sum + x } write sum is sum Chapter 1 FALL 2016 15 C ( 1972) Designed by Dennis Ritchie at Bell Labs Ancestor of Java, C++ Features Language for systems programming C compiler was part of the UNIX operating system Used in many application areas Official (ANSI) description of C ( 1989) Chapter 1 FALL 2016 16 8

#include <stdio.h> //Needed for C IO void copystring ( char s[], char t[]) { int k = 0; while( ( s[k] = t[k])!= '\0') { k++; } } int main() { char a[] = banana"; char b[] = orange"; copystring ( b,a); } printf("%s\n", a); printf("%s\n",b); Very insecure code. What happens if b[] is set to kiwi? May depend on compiler. Chapter 1 FALL 2016 17 Lisp ( 1959-1960) Developed by John McCarthy at IBM Ancestor of Scheme and Haskell Features Symbolic processing language ( e.g. list processing) Built on lists, atoms, selectors and constructors Dynamically allocated lists Garbage Collection Recursion Functions are first class objects Chapter 1 FALL 2016 18 9

(define factorial ( lambda (n) (if (= n 0) 1 ( * n (factorial ( - n 1))) ) ) ) This function is written in Scheme Chapter 1 FALL 2016 19 Compare Java with Scheme programs Java: int factorial ( int n) { if ( n == 0) return 1; else return n * f( n-1); } Scheme: (define factorial ( lambda (n) (if (= n 0) 1 ( * n (factorial ( - n 1))) ) ) ) Differences? Similarities? Chapter 1 FALL 2016 20 10

Logic programming language Makes explicit use of logic Very useful for problems that require searching for solutions to logic problems Used for automatic theorem proving Early Prolog interpreter and compiler developed in 1977 in Edinburgh Chapter 1 FALL 2016 21 Jerry is a mouse Mickey is a mouse Tom is a cat Garfield is a cat All mice eat cheese Deduce: Jerry eats cheese Prolog World Chapter 1 FALL 2016 22 11

mouse(jerry). facts mouse(mickey). cat(tom). cat(garfield). eatcheese(x) :- mouse(x). rule?- eatcheese(jerry). query true.?- eatcheese(tom). false. Chapter 1 FALL 2016 23 Designed by Niklaus Wirth in 1960s. Simplified version of Algol 68 Widely used as a teaching language in the 1970s and 1980s. Chapter 1 FALL 2016 24 12

program pascalex( input,output) ; type intlisttype = array [ 1..99] of integer; var intlist: intlisttype; listlen, k, sum, average, result : integer; begin result := 0; sum := 0; readln( listlen); if ( listlen > 0) and ( listlen < 100) then begin for k:= 1 to listlen do begin readln( intlist[k]); sum := sum + intlist[k] end; Class Exercise end. end else average := sum /listlen; for k := 1 to listlen do if ( intlist[k] > average) then result := result + 1; {Print result} writeln( The number of values > average is, result) writeln( Error input list length is not legal ) How does this Pascal program differ from a similar Java program? Chapter 1 FALL 2016 25 13