CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

26
CSE-321 Programming Languages Overview POSTECH March 2, 2010 박박박

Transcript of CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

Page 1: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

CSE-321 Programming Languages

Overview

POSTECH

March 2, 2010

박성우

Page 2: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

2

Language = Frame of Thought• The language defines the frame of thought.

– what you can communicate to others– what concepts you are able to think over– how you think

• Big question:"Does the programming language define the frame

of thought in the course of programming?"

Page 3: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

3

C Exercise: Integration• Specification

– input: function f from int to int range a and b

– output: f(a) + f(a + 1) + ... + f(b)

• Solution?int integral(int (*f)(int), int a, int b) {

int i, sum = 0;for (i = a; i <= b; i++)

sum += f(i);return sum;

}

• Question: what if there were no function pointer?

Page 4: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

4

C Exercise: Derivative• Specification

– input: function f from float to float– output: derivative f' of f such that

f'(x) = (f(x + ) - f(x)) /

• Solution?

Page 5: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

5

Question for You• What is your favorite language?

– Assembly, Basic, Pascal, C, C++, C#, Java, Perl, Python, Ruby, Prolog, Lisp, SML, Haskell, Scheme, ...

• What is its strength?• What is its weakness?• What is its limitation?

• Do you think your language defines the frame of thought?

Page 6: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

Never (mistakenly) think that your favorite language is all you will

need ever.

Cf. 'Beating the Averages' by Paul Graham

Page 7: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

Evolution of programming languages

Page 8: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

8

Structured Programming• Features

– split programs into sub-sections (e.g., functional units) and reuse the sub-sections

• procedural programming– limited number of control structures

• for, while, do/while, repeat/until• goto is discouraged.

• Pascal, Ada, C, ...• Enabled the development of large-scale software in 1970s

– Unix operating system written in C– 1st revolution in programming language history

Page 9: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

9

Object-oriented Programming• Features

– focus on objects, rather than operations– hide the internal representation of an object– code reuse by inheritance or subclassing

• Smalltalk, C++, Java, C#, ...• Enabled the cooperative development of large-

scale software in 1980s– 2nd revolution in programming language history

Page 10: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

10

Dominance of OO• TIOBE programming community index, Feb 2010

Page 11: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

11

Limitation of OO Programming• No code reuse for different datatypes

– templates in C++– generics in Java

• No "first-class" functions– closures in Java

• No inherent support for modular programming– Classes are okay for modular programming of

moderate scale.– OO does not scale afterwards. Why?

Page 12: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

12

Functional Programming• Standard ML, Haskell, Objective CAML, F#, ...• Savior for OO programming

– templates in C++, generics in Java) primitive forms of polymorphism in type theory

– closures in Java) functions in functional programming

– modular programming) structures and functors in functional programming

• F# in Microsoft Visual Studio 2010

Page 13: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

What is the (ongoing) 3rd revolution in programming

language history?

Page 14: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

14

CPU Frequency

http://www.tomshardware.com/reviews/mother-cpu-charts-2005,1175.html

Page 15: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

15

Multicore Revolution

• Intel reaches thermal wall, 2004 ) no more free lunch!

• Intel, 80-cores, 2011

source: Herb Sutter – "Software and the concurrency revolution"

Page 16: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

16

Intel Roadmap

Page 17: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

17

Tim Sweeney's POPL '06 Invited Talk- Last Slide

Page 18: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

Parallel Programming:3rd Programming Revolution

) It's no longer optional.

Page 19: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

What is the hottest issue in programming language research?

) Verification(verifying that your software is okay)

Page 20: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

20

Technologies for Verification• Testing

– white box testing, black box testing– limited assurance

• Model checking– verifying both software and hardware systems

• Static analysis– many success stories

• Astree, 100,000 lines of Airbus A380 control software– many industrialized tools (e.g., Sparrow of SNU)

• Deductive verification (theorem prover, proof assistant)– next-generation technology in verification

Page 21: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

21

Can you trust your compiler?• Critical software requires the correctness of

compilers.– Compilers are far from perfect, producing

unintended, erroneous code.– Unfortunately the verification of compiler is not

trivial at all.

• Formal verification of CompCert (Xavier Leroy, 2006)

– Clight to PowerPC assembly code– Verification in Coq (proof assistant)

Page 22: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

Course Overview

Page 23: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

23

Topics to Be Covered• Basic programming language theory

– inductive reasoning– -Calculus– basic type theory– modular programming (assignment)– object-orientation (lecture, assignment)– parallelism/concurrency (tentative)

Page 24: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

24

Grading• 50% assignments (heart of this course)

– 8 programming assignments, all in Standard ML• 10% quizzes

– 4 quizzes (substitute for written assignments)• 20% midterm• 20% final

• Absolute grading system

Page 25: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

25

No Cheating• Read the document on the disciplinary policy.

• 2006– 7 students cheated (out of 46 students)– 2 suspicious cases

• We will check your programs at the end of the semester.– all your programs + those submitted in the previous years

• Cheating will not be tolerated.– Cheating will expel you from class and get you an F.

Page 26: CSE-321 Programming Languages Overview POSTECH March 2, 2010 박성우.

26

Homework by Thursday• Visit the course webpage.

– http://www.postech.ac.kr/~gla/cs321/• Visit the discussion board.

– telnet pl.postech.ac.kr, board 321• Install

– Standard ML 110.58.– AFS client software.

• Read articles for fun.– A Critical Look at Programming Languages– The Free Lunch is Over: A Fundamental Turn Toward Concurrency

in Software– Software and the Concurrency Revolution– Beating the Average