24
PROGRAMMING LANGUAGES Dr. Shahriar Bijani Sep. 2014

P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

Embed Size (px)

Citation preview

Page 1: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

PROGRAMMING LANGUAGESDr. Shahriar Bijani

Sep. 2014

Page 2: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

2

TEXT BOOK

Kenneth C. Louden & Kenneth A. Lambert, Programming Languages: Principles and Practice, 3rd Edition, 2012.

Page 3: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

3

CODE OF CONDUCT

• Plagiarism is not acceptable!

• All assignments are strictly individual Unless explicitly stated otherwise

Page 4: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

4

MAIN SLIDE REFERENCES

CS 152: Programming Language Paradigms, Dept. of Computer Science, San Jose State University, Spring 2014.

COMP313A: Programming Languages, Dept. of Computer Science, The University of Waikato, 2014.

Page 5: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

GOALS OF THE COURSE

Program in languages from different “cultures”. Learn new ideas and concepts. Apply the new concepts to your “native”

language. C++, C#, Java, etc.

Become a better programmer!

Different programming cultures (paradigms). Object-oriented

C++, C#, Objective C, Java, etc. Functional

Lisp, Scheme, ML, Haskell, F# Logic

Prolog

Page 6: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

GOALS OF THE COURSE

How are programming languages designed? Can we design a language? What are the design criteria? How can we specify the language’s syntax and

semantics? What about data types and control structures?

How are programming languages implemented? Interpreters Compilers

Page 7: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

WHY THIS COURSE?

Increased capacity to express ideas. The depth at which we can think is influenced

by the expressive power of the language

Improved background for choosing appropriate languages. Make better informed choices if you are familiar

with other available languages, especially the particular features of those languages.

Page 8: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

WHY THIS COURSE? Increased capacity to learn new languages.

Understanding of the fundamental concepts of languages and learning a new language give you better understanding of your first language.

Better understanding language implementation. Understand implementation issues

Understand why languages are designed the way they are Ability to use a language more intelligently.

Increased ability to design new languages. Advance the state of the art. Better languages can crowd out poor languages.

Page 9: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

A HISTORIC TIMELINE

Programming Languages: Principles and Practice, 3rd ed.Kenneth Louden & Kenneth Lambert(c) 2012 Course Technology. All rights reserved. 978-1-111-52941-3

Page 10: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

ORIGINS OF PROGRAMMING LANGUAGES

A programming language is often defined as “a notation for communicating to a computer

what we want it to do”.

Before the mid 1940s, computer operators set switches to adjust the internal wiring of a computer to perform the requested tasks.

Programming languages allowed computer users to solve problems without having to reconfigure hardware.

Page 11: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

PLUGBOARD CONTROL PANEL

IBM 407 Accounting Machine (1949)

Page 12: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

PROGRAMMING A PLUGBOARD

“Hmm, should I pass this parameter by value or by reference?”

“Programming” was hand-wiring plugboards.

Page 13: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

PROGRAMMING A PLUGBOARD

Plugboard wiring diagram

It doesn’t look too complicated, does it?

Page 14: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

MACHINE LANGUAGE

John von Neumann proposed that computers should be permanently hardwired with a small set of general-purpose operations.

An operator could input a series of binary codes to organize the basic hardware operations to solve more specific problems.

Operators could flip switches to enter these codes, called machine language, into memory.

Page 15: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

MACHINE LANGUAGE

Machine language programming was boring and error prone.

Page 16: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

ASSEMBLY LANGUAGE

Assembly language: a set of mnemonic symbols for instruction codes and memory locations. Example: LD R1,R2

Assembler: a program that translates the symbolic assembly language code to binary machine code.

Loader: a program that loads the machine code into computer memory for execution.

Input devices: Keypunch machine Punched card reader

Page 17: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

17SJSU Dept. of Computer

ScienceSpring 2014: January 27

CS 152: Programming Language Paradigms© R. Mak

IBM 1401 AUTOCODER PROGRAMMING

80/80 List Read and print a deck of cards.

JOB 80/80 CARD LISTER * ORG 333 LOCATE AFTER THE PRINT AREA START CS 332 CLEAR STORAGE 332 - 300 CS CLEAR STORAGE 299 - 200 SW 1,201 SET WORD MARKS AT 1 AND 201 * READ R READ A CARD INTO READ AREA MCW 80,280 MOVE TO PRINT AREA W PRINT IT BLC DONE GO TO DONE IF LAST CARD READ B READ ELSE GO READ ANOTHER CARD * DONE H DONE ALL DONE END START

MCW Move characters to word mark

Main loop

Page 18: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

18

ASSEMBLY LANGUAGE

Mnemonic symbols were an improvement over binary machine codes but still had shortcomings.

Lacks abstraction of conventional mathematical notation.

Each type of computer hardware architecture has its own machine language instruction set and requires its own dialect of assembly language.

Assembly languages first appeared in the 1950s and are still used today for low-level system tools

or for hand-optimization.

Page 19: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

PUNCHED CARDS Data was stored in

punched cards called “IBM cards” or “Hollerith cards” Named after

Herman Hollerith.

80 columns per card, one character per column.

Up to 12 punched holes per column.

Alphanumeric data, often grouped into fields._

Page 20: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

A DATA PROCESSING JOB A typical “job”.

Tanenbaum & Woodhull Operating Systems: Design and Implementation (c) 2006 Prentice-Hall, Inc. All rights reserved. 0-13-142938-8

Page 21: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

PUNCHED CARDS Data processing

was all about punched cards.

A compiler project! 3½ boxes of punched cards Each box = 2000 cards, 10

lbs.

Page 22: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

FORTRAN FORTRAN: FORmula TRANslation language

Developed by John Backus in the early 1950s. Reflected the architecture of a particular type of

machine. Lacked the structured control statements and data

structures of later high-level languages.

Popular with scientists and engineers for its support for algebraic notation and floating-point numbers.

The language has evolved and is still used today. FORTRAN IV FORTRAN 77 FORTRAN 90 FORTRAN 95 FORTRAN 2015 ...

Page 23: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

ALGOL Algol: Algorithmic Language released in 1960

Provided a standard notation for computer scientists to publish algorithms in journals.

John Backus was a major contributor.

Structured control statements Sequencing (begin-end blocks) Loops (for loop) Selection (if and if-else statements)

Different numeric types Introduced the array structure

Supported procedures Including recursive procedures

Page 24: P ROGRAMMING L ANGUAGES Dr. Shahriar Bijani Sep. 2014

THE ALGOL FAMILY

A large number of high-level languages descended from Algol, including: Pascal: language for teaching programming in the 1980s Ada: for embedded applications of U.S. Dept. of Defense

(DoD)

Algol control structures are present in today’s languages, including Java, C, C++, etc.