programming languages xiaojuan cai xiaojuan/pl2015

19
Programming Languages Xiaojuan Cai http://basics.sjtu.edu.cn/~xiaojuan/p l2015/

Upload: reynard-knight

Post on 17-Dec-2015

223 views

Category:

Documents


1 download

TRANSCRIPT

Programming Languages

Xiaojuan Cai

http://basics.sjtu.edu.cn/~xiaojuan/pl2015/

Programming Languages Section 0 2

Do you know

• How many programming languages in the world?

http://en.wikipedia.org/wiki/List_of_programming_languages

• There are strange(weird) programming languages99 Bottles of Beer

Programming Languages Section 0 3

Roadmap

• Course overview

• Policy

Programming Languages Section 0 4

What is the best kind of car?

What is the best PL?

Programming Languages Section 0 5

Cars tell us• Cars are used for rather difference things.

• You can not be a great driver if you only ever drive one car.

• A good mechanic understands how “cars” work

• A good mechanical engineer knows how to design better ones

• To learn how car pieces interact, start with a classic design rather than the latest model.

Programming Languages Section 0 8

This course will show three languages with different

paradigms;

introduce a lot of fundamental concepts and key points;

make you a better programmer by learning to think about software in “PL” way;

give you the mental tools and experience you need for a lifetime of confidently picking up new languages and ideas.

Programming Languages Section 0 9

Five different things

1. Syntax2. Semantics3. Idioms4. Libraries5. Tools

These are 5 separate issues

• In practice, all are essential for good programmers

• Many people confuse them, but shouldn’t

Programming Languages Section 0 11

The languages together

ML: polymorphic types, pattern-matching, abstract types

Racket: dynamic typing, “good” macros, minimalist syntax

Ruby: classes but not types, very OOP, mixins

dynamically typed statically typed

functional Racket SML

object-oriented

Ruby Java/C#

Programming Languages Section 0 12

Functional Programming

• Mutation is discouraged

• Higher-order functions are very convenient

• One-of types via constructs like datatypes

1. These features are invaluable for correct, elegant,

efficient software

2. Functional languages have always been ahead of their

time

Programming Languages Section 0 13

Ahead of their timeAll these were dismissed as “beautiful, worthless, slow things

PL professors make you learn”

•Garbage collection (Java didn’t exist in 1995, PL courses

did)

•Generics (List<T> in Java, C#), much more like SML than

C++

•Higher-order functions (Ruby, Javascript, C#, …)

•Type inference (C#, Scala, …)

•…

Programming Languages Section 0 14

Is this real programming?

• The way we use ML/Racket/Ruby can make them

seem almost “silly”

• “Real” programming needs file I/O, string

operations, floating-point, graphics, project

managers, testing frameworks, threads, build

systems, …

• Many elegant languages have all that and more

• Including Racket and Ruby

Programming Languages Section 0 15

Course overview

Special thanks to Prof. Dan Grossman.

Programming languagesCourseraby Dan Grossman(about 65,000 people registered this course)

Dan GrossmanProfessor,University of Washington

Programming Languages Section 0 16

Course data(Coursera, Jan 2013 session, provided by Prof. Grossman

• “Registered”: 65,000 totally irrelevant• Clicked play in first 2 weeks: 27,000 • Watched an hour of video: 12,000 like coming to first day?• Turned in 1st homWework: 4,000• Turned in 5th homework: 2,100 attrition doesn’t stop• “Passed”: 1,716• Fan mail/posts: 300

• Consistent with “hard” course in Coursera!

Programming Languages Section 0 17

Roadmap

• Course overview

• Policy

Programming Languages Section 0 18

Instructor and TAs

•蔡小娟 (Instructor)Office: Software building 1210Email: [email protected]

•刘立 Office: Dianxin building 3-329Email: [email protected]

Programming Languages Section 0 19

Policy

• Final score = 40% homework + 60% final exam

• Exams cover topics harder to re-enforce with “just programming” because this is not just a programming course

Programming Languages Section 0 20

More on homework

• 7 assignments (for the first 16 lectures)

• Doing the homework involves:Understanding the concepts being addressedWriting code demonstrating understanding of the conceptsTesting your code to ensure you understand and have correct programs“Playing around” with variations, incorrect answers, etc.

Programming Languages Section 0 21

More on homework

• Every word you submit should be your own!

• Cheating: copy codes from other sources. You will directly get a fail score.

Programming Languages Section 0 22

“Sleep now, Dreams will come out;

Study now, Dreams will come true.”