Programming Languages Chapter OneModern Programming Languages 1.

Slides:



Advertisements
Similar presentations
Programming Languages and Paradigms
Advertisements

Adapted from Scott, Chapter 6:: Control Flow Programming Language Pragmatics Michael L. Scott.
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.
Principles of programming languages 4: Parameter passing, Scope rules Department of Information Science and Engineering Isao Sasano.
Scope Chapter Ten Modern Programming Languages.
Copyright © by Curt Hill Expressions and Assignment Statements Part 2.
Gary MarsdenSlide 1University of Cape Town Statements & Expressions Gary Marsden Semester 2 – 2000.
High-Level Programming Languages
The Evolution of Programming Languages
CSE S. Tanimoto Syntax and Types 1 Representation, Syntax, Paradigms, Types Representation Formal Syntax Paradigms Data Types Type Inference.
Comp 205: Comparative Programming Languages Imperative Programming Languages Functional Programming Languages Semantics Other Paradigms Lecture notes,
Presented by Neng-Fa Zhou1 Evolution of programming languages –Machine language –Assembly language –Sub-routines and loop (Fortran) –Procedures and recursion.
Summer 02-03Programming Language Concepts1 Programming Language Concepts (CS 360) Lecture 1: Overview, Grammars, and Little Languages Jeremy R. Johnson.
Programming Languages Chapter OneModern Programming Languages, 2nd ed.1.
Programming Language Concepts
CSE 341, S. Tanimoto Concepts 1- 1 Programming Language Concepts Formal Syntax Paradigms Data Types Polymorphism.
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++
(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)
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 and Design Lecture 7 Subroutines and Control Abstraction Instructor: Li Ma Department of Computer Science Texas Southern University,
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 Programming Languages and Paradigms Functional Programming.
10/16/2015IT 3271 All about binding n Variables are bound (dynamically) to values n values must be stored somewhere in the memory. Memory Locations for.
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.
Programming Languages and Paradigms Imperative Programming.
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,
1-1 An Introduction to Functional Programming Sept
Subprograms - implementation
ISBN Structure of Programming Languages Prof. Dr. Mostafa Abdel Aziem Mostafa Senior Lecturer
1 The Evolution of Major Programming Languages Different Languages Characteristics.
Allyson M. Hoss, January 14, 2008 CSC 7101 Programming Language Structures Spring 2008 Louisiana State University.
int k = Integer.MAX_VALUE; k++; int k = Integer.MAX_VALUE; k++; What happens when the following code executes? byte b = someFile.readByte(); b = (byte)(b.
Programming Language Principles Lecture 32 Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Course Summary.
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
1 Introduction to Functional Programming in Racket CS 270 Math Foundations of CS Jeremy Johnson.
History. Development Driven by Function Functions of a Programming Language –To describe computation for use by computers –To describe computation and.
Language Paradigms CS655.
Functional Programming
Programming Language History and Evolution
CSCE 190 Programming Language Paradigms
The language focusses on ease of use
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
Representation, Syntax, Paradigms, Types
Comp 205: Comparative Programming Languages
Application Development Theory
Programming Language History and Evolution
User-Defined Functions
Evolution of programming languages
Chap. 6 :: Control Flow Michael L. Scott.
Representation, Syntax, Paradigms, Types
Chap. 6 :: Control Flow Michael L. Scott.
Representation, Syntax, Paradigms, Types
Introduction to Functional Programming in Racket
Representation, Syntax, Paradigms, Types
Presentation transcript:

Programming Languages Chapter OneModern Programming Languages 1

Outline What makes programming languages an interesting subject? ◦ The amazing variety ◦ The odd controversies ◦ The intriguing evolution ◦ The connection to programming practice Chapter OneModern Programming Languages 2

HOW MANY PROGRAMMING LANGUAGES ARE THERE? Chapter OneModern Programming Languages 3

The Amazing Variety There are very many, very different languages ◦ Thousands! ◦ See ming_languages Chapter OneModern Programming Languages 4

Programming Paradigms Often grouped into four major families: ◦ Imperative ◦ Functional ◦ Logic ◦ [Object-oriented (evolved from Imperative)] Chapter OneModern Programming Languages 5

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

Functional Languages Example: a factorial function in ML Hallmarks of functional languages: ◦ Single-valued variables (immutable) ◦ Heavy use of recursion (vs. iteration) Chapter OneModern Programming Languages 7 fun fact x = if x <= 0 then 1 else x * fact(x-1);

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

Object-Oriented Languages Hallmarks of object-oriented languages: ◦ Usually imperative, plus… ◦ Constructs to help programmers use “objects”—little bundles of data that know how to do things Chapter OneModern Programming Languages 9

Strengths and Weaknesses The different language groups show their “Stuff” on different kinds of problems 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 10

About Those Families There are many other language family terms (not exhaustive and sometimes overlapping) ◦ Applicative, concurrent, constraint, declarative, definitional, procedural, scripting, Some languages straddle families Others are so unique that assigning them to a family is pointless ◦ FORTH, APL Chapter OneModern Programming Languages 11

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

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

The Odd Controversies Programming languages are the subject of many heated debates: ◦ Partisan arguments ◦ Language standards ◦ Fundamental definitions Chapter OneModern Programming Languages 14

Language Partisans There is a lot of argument about the relative merits of different languages Every language has partisans, who praise it in extreme terms and defend it against all detractors To experience some of this, explore newsgroups: comp.lang.* (Plenty of rational discussion there too!) Chapter OneModern Programming Languages 15

Language Standards The documents that define language standards are often drafted by international committees Can be a slow, complicated and rancorous process Fortran 82 8X standard released in 1991 C++: 1998 / 2003 / 2011 ECMAScript, CLI Chapter OneModern Programming Languages 16

Basic Definitions Some terms refer to fuzzy concepts: all those language family names, for example 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? Some crisp concepts have conflicting terminology: one person’s argument is another person’s actual parameter Chapter OneModern Programming Languages 17

The Intriguing Evolution Programming languages are evolving rapidly ◦ New languages are being invented ◦ Old ones are developing new dialects Chapter OneModern Programming Languages 18

Widely Used: Java Quick rise to popularity since 1995 release Java uses many ideas from C++, plus some from Mesa, Modula, and other languages C++ uses most of C and extends it with ideas from Simula 67, Ada, Clu, ML and Algol 68 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 19

Not Widely Used: Algol One of the earliest languages: Algol 58, Algol 60, Algol 68 Never widely used ◦ but very influential! Introduced many ideas that were used in later languages, including: ◦ Block structure and scope ◦ Recursive functions ◦ Parameter passing by value Chapter OneModern Programming Languages 20

Chapter Twenty-FourModern Programming Languages 21

tiobe.com Programming popularity index ◦ Updated monthly Chapter OneModern Programming Languages 22

Language Influences Programming Practice Languages often strongly favor a particular style of programming ◦ Object-oriented languages: a style making heavy use of dynamic 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 23

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

Imperative ML Chapter OneModern Programming Languages 25 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 26 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! }

Other Connections: Computer Architecture Language evolution drives and is driven by hardware evolution: ◦ Call-stack support – languages with recursion ◦ Parallel architectures – parallel languages ◦ Internet – Java, PHP Chapter OneModern Programming Languages 27

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