Programming Languages Chapter OneModern Programming Languages, 2nd ed.1.

Slides:



Advertisements
Similar presentations
1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
Advertisements

Programming Languages and Paradigms
Adapted from Scott, Chapter 6:: Control Flow Programming Language Pragmatics Michael L. Scott.
CSCI 330: Programming Language Concepts Instructor: Pranava K. Jha Control Flow-II: Execution Order.
Introduction to Programming Languages Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
ISBN Chapter 3 Describing Syntax and Semantics.
Gary MarsdenSlide 1University of Cape Town Statements & Expressions Gary Marsden Semester 2 – 2000.
MATHEMATICAL FOUNDATIONS SUPPLEMENTAL MATERIAL – NOT ON EXAM.
ISBN Chapter 10 Implementing Subprograms.
High-Level Programming Languages
CS 101 Course Summary December 5, Big Ideas Abstraction Problem solving Fundamentals of programming.
The Evolution of Programming Languages
Programming in Scala Chapter 1. Scala: both object-oriented and functional Scala blends –object-oriented and –functional programming in a –statically.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Introduction to Functional Programming Notes for CSCE 190 Based on Sebesta,
Comp 205: Comparative Programming Languages Imperative Programming Languages Functional Programming Languages Semantics Other Paradigms Lecture notes,
Summer 02-03Programming Language Concepts1 Programming Language Concepts (CS 360) Lecture 1: Overview, Grammars, and Little Languages Jeremy R. Johnson.
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Introduction (Chapter 1)
CS 415: Programming Languages Chapter 1 Aaron Bloomfield Fall 2005.
Computer Science 101 Introduction to Programming.
CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be.
Chapter TwelveModern Programming Languages1 Memory Locations For Variables.
Chapter 8 High-Level Programming Languages (modified by Erin Chambers)
Imperative Programming
High-Level Programming Languages: C++
G Programming Languages T he main themes of programming language design and use: –Model of computation –Expressiveness types and their operations.
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
Functional Programing Referencing material from Programming Language Pragmatics – Third Edition – by Michael L. Scott Andy Balaam (Youtube.com/user/ajbalaam)
The Evolution of the Object Model OOAD. The Evolution of the Object Model software engineering trends observed The shift in focus from programming-in-the-small.
COMPUTER PROGRAMS AND LANGUAGES Chapter 4. Developing a computer program Programs are a set (series) of instructions Programmers determine The instructions.
CSC3315 (Spring 2009)1 CSC 3315 Programming Languages Hamid Harroud School of Science and Engineering, Akhawayn University
Programming Languages –14 David Watt (Glasgow) Steven Wong (Singapore) Moodle : Computing Science → Level 3 → Programming Languages 3 © 2012 David.
Chapter 1 - Introduction
By Neng-Fa Zhou1 Evolution of programming languages –Machine language –Assembly language –Sub-routines and loop (Fortran) –Procedures and recursion (Algol,
Programming Languages The Beginning. In the beginning... Computers were very expensive; programmers were cheap Programming was by plugboards or binary.
1 Concepts of Programming Languages TK 327, Fall 2015 MW 2:00 PM – 3:15 PM STV 104 Instructor:Dr. Chung-Chih Li Home page of the Class.
1 Type Checking Type checking ensures that the operands and the operator are of compatible types Generalized to include subprograms and assignments Compatible.
Chapter 6 Programming Languages (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
1 Programming Languages Fundamentals Cao Hoaøng Truï Khoa Coâng Ngheä Thoâng Tin Ñaïi Hoïc Baùch Khoa TP. HCM.
Chapter OneProgramming Languages1. Chapter OneProgramming Languages2 Recommended Course Textbooks A. B. Webber (2002) Modern Programming Languages: A.
Programming Language 1. Programming language A programming language is a machine-readable artificial language designed to express computations that can.
The Evolution of Programming Languages Day 2 Lecturer: Xiao Jia The Evolution of PLs1.
Statement Level Flow of Control Iteration Structures Copyright © by Curt Hill.
Chapter 8 High-Level Programming Languages. 2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
ISBN Structure of Programming Languages Prof. Dr. Mostafa Abdel Aziem Mostafa Senior Lecturer
1 The Evolution of Major Programming Languages Different Languages Characteristics.
CMSC 330: Organization of Programming Languages Operational Semantics a.k.a. “WTF is Project 4, Part 3?”
Programming Languages
(1) ICS 313: Programming Language Theory Chapter 11: Abstract Data Types (Data Abstraction)
1-1 1 Introduction  Programming linguistics: concepts and paradigms syntax, semantics, and pragmatics language processors.  Historical development of.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 190 Programming Language Paradigms Fall 2014
CMSC 330: Organization of Programming Languages Operational Semantics.
a medium allowing humans and computers to communicate an abstraction of the real world a notation for expressing algorithms the set of all syntactically.
History. Development Driven by Function Functions of a Programming Language –To describe computation for use by computers –To describe computation and.
Language Paradigms CS655.
Programming Languages Chapter OneModern Programming Languages 1.
Programming Language History and Evolution
Zuse’s Plankalkül – 1945 Never implemented Problems Zuse Solved
PROGRAMMING LANGUAGES
Programming Languages
Algol 60 John Cowan N Languages in N Months Meetup June 7, 2016
Comp 205: Comparative Programming Languages
Programming Language History and Evolution
Evolution of programming languages
Chap. 6 :: Control Flow Michael L. Scott.
Chap. 6 :: Control Flow Michael L. Scott.
High Level Programming Languages
Presentation transcript:

Programming Languages Chapter OneModern Programming Languages, 2nd ed.1

Outline n What makes programming languages an interesting subject? – The amazing variety – The odd controversies – The intriguing evolution – The connection to programming practice – The many other connections Chapter OneModern Programming Languages, 2nd ed.2

The Amazing Variety n There are very many, very different languages (A list that used to be posted occasionally on comp.lang.misc had over 2300 published languages in 1995) n Often grouped into four families: – Imperative – Functional – Logic – Object-oriented Chapter OneModern Programming Languages, 2nd ed.3

Imperative Languages n Example: a factorial function in C n Hallmarks of imperative languages: – Assignment – Iteration – Order of execution is critical Chapter OneModern Programming Languages, 2nd ed.4 int fact(int n) { int sofar = 1; while (n>0) sofar *= n--; return sofar; }

Functional Languages n Example: a factorial function in ML n Hallmarks of functional languages: – Single-valued variables – Heavy use of recursion Chapter OneModern Programming Languages, 2nd ed.5 fun fact x = if x <= 0 then 1 else x * fact(x-1);

Another Functional Language n Example: a factorial function in Lisp n Looks very different from ML n But ML and Lisp are closely related – Single-valued variables: no assignment – Heavy use of recursion: no iteration Chapter OneModern Programming Languages, 2nd ed.6 (defun fact (x) (if (<= x 0) 1 (* x (fact (- x 1)))))

Logic Languages n Example: a factorial function in Prolog n Hallmark of logic languages – Program expressed as rules in formal logic Chapter OneModern Programming Languages, 2nd ed.7 fact(X,1) :- X =:= 1. fact(X,Fact) :- X > 1, NewX is X - 1, fact(NewX,NF), Fact is X * NF.

Object-Oriented Languages n Example: a Java definition for a kind of object that can store an integer and compute its factorial Chapter OneModern Programming Languages, 2nd ed.8

Chapter OneModern Programming Languages, 2nd ed.9 public class MyInt { private int value; public MyInt(int value) { this.value = value; } public int getValue() { return value; } public MyInt getFact() { return new MyInt(fact(value)); } private int fact(int n) { int sofar = 1; while (n > 1) sofar *= n--; return sofar; } }

Object-Oriented Languages n Hallmarks of object-oriented languages: – Usually imperative, plus… – Constructs to help programmers use “objects”—little bundles of data that know how to do things to themselves Chapter OneModern Programming Languages, 2nd ed.10

Strengths and Weaknesses n The different language groups show to advantage on different kinds of problems n Decide for yourself at the end of the semester, after experimenting with them n For now, one comment: don’t jump to conclusions based on factorial! – Functional languages do well on such functions – Imperative languages, a bit less well – Logic languages, considerably less well – Object-oriented languages need larger examples Chapter OneModern Programming Languages, 2nd ed.11

About Those Families n There are many other language family terms (not exhaustive and sometimes overlapping) – Applicative, concurrent, constraint, declarative, definitional, procedural, scripting, single- assignment, … n Some multi-paradigm languages straddle families: JavaScript, OCaml, Python, Ruby n Others are so unique that assigning them to a family is pointless Chapter OneModern Programming Languages, 2nd ed.12

Example: Forth Factorial n A stack-oriented language n Postscript is similar n Could be called imperative, but has little in common with most imperative languages Chapter OneModern Programming Languages, 2nd ed.13 : FACTORIAL 1 SWAP BEGIN ?DUP WHILE TUCK * SWAP 1- REPEAT ;

Example: APL Factorial n An APL expression that computes X’s factorial n Expands X it into a vector of the integers 1..X, then multiplies them all together n (You would not really do it that way in APL, since there is a predefined factorial operator: !X) n Could be called functional, but has little in common with most functional languages Chapter OneModern Programming Languages, 2nd ed.14    X   X

Outline n What makes programming languages an interesting subject? – The amazing variety – The odd controversies – The intriguing evolution – The connection to programming practice – The many other connections Chapter OneModern Programming Languages, 2nd ed.15

The Odd Controversies n Programming languages are the subject of many heated debates: – Partisan arguments – Language standards – Fundamental definitions Chapter OneModern Programming Languages, 2nd ed.16

Language Partisans n There is a lot of argument about the relative merits of different languages n Every language has partisans, who praise it in extreme terms and defend it against all detractors Chapter OneModern Programming Languages, 2nd ed.17

Language Standards n The documents that define language standards are often drafted by international committees n Can be a slow, complicated and rancorous process n Fortran 82 8X standard released in 1991 Chapter OneModern Programming Languages, 2nd ed.18

Basic Definitions n Some terms refer to fuzzy concepts: all those language family names, for example n No problem; just remember they are fuzzy – Bad: Is X really an object-oriented language? – Good: What aspects of X support an object-oriented style of programming? n Some crisp concepts have conflicting terminology: one person’s argument is another person’s actual parameter Chapter OneModern Programming Languages, 2nd ed.19

Outline n What makes programming languages an interesting subject? – The amazing variety – The odd controversies – The intriguing evolution – The connection to programming practice – The many other connections Chapter OneModern Programming Languages, 2nd ed.20

The Intriguing Evolution n Programming languages are evolving rapidly – New languages are being invented – Old ones are developing new dialects Chapter OneModern Programming Languages, 2nd ed.21

New Languages n A clean slate: no need to maintain compatibility with an existing body of code n But never entirely new any more: always using ideas from earlier designs n Some become widely used, others do not n Whether widely used or not, they can serve as a source of ideas for the next generation Chapter OneModern Programming Languages, 2nd ed.22

Widely Used: Java n Quick rise to popularity since 1995 release n Java uses many ideas from C++, plus some from Mesa, Modula, and other languages n C++ uses most of C and extends it with ideas from Simula 67, Ada, Clu, ML and Algol 68 n C was derived from B, which was derived from BCPL, which was derived from CPL, which was derived from Algol 60 Chapter OneModern Programming Languages, 2nd ed.23

Not Widely Used: Algol n One of the earliest languages: Algol 58, Algol 60, Algol 68 n Never widely used n Introduced many ideas that were used in later languages, including – Block structure and scope – Recursive functions – Parameter passing by value Chapter OneModern Programming Languages, 2nd ed.24

Dialects n Experience with languages reveals their design weaknesses and leads to new dialects n New ideas pass into new dialects of old languages Chapter OneModern Programming Languages, 2nd ed.25

Some Dialects Of Fortran n Original Fortran, IBM n Major standards: – Fortran II – Fortran III – Fortran IV – Fortran 66 – Fortran 77 – Fortran 90 – Fortran 95 – Fortran 2003 – Fortran 2008? Chapter OneModern Programming Languages, 2nd ed.26 n Deviations in each implementation n Parallel processing – HPF – Fortran M – Vienna Fortran n And many more…

Outline n What makes programming languages an interesting subject? – The amazing variety – The odd controversies – The intriguing evolution – The connection to programming practice – The many other connections Chapter OneModern Programming Languages, 2nd ed.27

The Connection To Programming Practice n Languages influence programming practice – A language favors a particular programming style—a particular approach to algorithmic problem-solving n Programming experience influences language design Chapter OneModern Programming Languages, 2nd ed.28

Language Influences Programming Practice n Languages often strongly favor a particular style of programming – Object-oriented languages: a style making heavy use of objects – Functional languages: a style using many small side-effect-free functions – Logic languages: a style using searches in a logically-defined problem space Chapter OneModern Programming Languages, 2nd ed.29

Fighting the Language n Languages favor a particular style, but do not force the programmer to follow it n It is always possible to write in a style not favored by the language n It is not usually a good idea… Chapter OneModern Programming Languages, 2nd ed.30

Imperative ML Chapter OneModern Programming Languages, 2nd ed.31 fun fact n = let val i = ref 1; val xn = ref n in while !xn>1 do ( i := !i * !xn; xn := !xn - 1 ); !i end; ML makes it hard to use assignment and side-effects. But it is still possible:

Non-object-oriented Java Chapter OneModern Programming Languages, 2nd ed.32 Java, more than C++, tries to encourage you to adopt an object-oriented mode. But you can still put your whole program into static methods of a single class: class Fubar { public static void main (String[] args) { // whole program here! }

Functional Pascal Chapter OneModern Programming Languages, 2nd ed.33 function ForLoop(Low, High: Integer): Boolean; begin if Low <= High then begin {for-loop body here} ForLoop := ForLoop(Low+1, High) end else ForLoop := True end; Any imperative language that supports recursion can be used as a functional language:

Programming Experience Influences Language Design n Corrections to design problems make future dialects, as already noted n Programming styles can emerge before there is a language that supports them – Programming with objects predates object- oriented languages – Automated theorem proving predates logic languages Chapter OneModern Programming Languages, 2nd ed.34

Outline n What makes programming languages an interesting subject? – The amazing variety – The odd controversies – The intriguing evolution – The connection to programming practice – The many other connections Chapter OneModern Programming Languages, 2nd ed.35

Other Connections: Computer Architecture n Language evolution drives and is driven by hardware evolution: – Call-stack support – languages with recursion – Parallel architectures – parallel languages – Internet – Java Chapter OneModern Programming Languages, 2nd ed.36

Other Connections: Theory of Formal Languages n Theory of formal languages is a core mathematical area of computer science – Regular grammars, finite-state automata – lexical structure of programming languages, scanner in a compiler – Context-free grammars, pushdown automata – phrase- level structure of programming languages, parser in a compiler – Turing machines – Turing-equivalence of programming languages Chapter OneModern Programming Languages, 2nd ed.37

Turing Equivalence n Languages have different strengths, but fundamentally they all have the same power – {problems solvable in Java} = {problems solvable in Fortran} = … n And all have the same power as various mathematical models of computation – = {problems solvable by Turing machine} = {problems solvable by lambda calculus} = … n Church-Turing thesis: this is what “computability” means Chapter OneModern Programming Languages, 2nd ed.38

Conclusion n Why programming languages are worth studying (and this course worth taking): – The amazing variety – The odd controversies – The intriguing evolution – The connection to programming practice – The many other connections n Plus…there is the fun of learning three new languages! Chapter OneModern Programming Languages, 2nd ed.39