Programming Languages Nate Nystrom University of Lugano Amanj - - PowerPoint PPT Presentation

programming languages
SMART_READER_LITE
LIVE PREVIEW

Programming Languages Nate Nystrom University of Lugano Amanj - - PowerPoint PPT Presentation

Programming Languages Nate Nystrom University of Lugano Amanj Sherwany usi-pl-staff@googlegroups.com Ilya Yanok http://inf.usi.ch/nystrom/teaching/pl/sp13 Who are we? Nate Nystrom Amanj Sherwany Ilya Yanok 2 19911995 Purdue: BS


slide-1
SLIDE 1

Programming Languages

Nate Nystrom University of Lugano Amanj Sherwany Ilya Yanok usi-pl-staff@googlegroups.com http://inf.usi.ch/nystrom/teaching/pl/sp13

slide-2
SLIDE 2

Who are we?

2

Amanj Sherwany Ilya Yanok Nate Nystrom

slide-3
SLIDE 3

About me

1991–1995 Purdue: BS Computer Science, Mathematics 1996–1998 Purdue: MS Computer Science 1998–1999 Hewlett-Packard: compiler engineer 1999–2006 Cornell: PhD Computer Science 2006–2009 IBM Research PL/SE group 2009–2010 Arlington, Texas: Assistant Professor 2011–present University of Lugano: Assistant Professor

3

slide-4
SLIDE 4

My research

Using programming languages to solve systems problems: Extensibility

  • Polyglot, an extensible compiler framework
  • http://www.cs.cornell.edu/Projects/polyglot
  • A framework for Scala compiler plugins

Concurrency and distribution and fault tolerance

  • X10, a concurrent OO language for HPC
  • http://www.x10-lang.org
  • Firepile, a Scala library for GPU programming
  • Languages for reasoning about relaxed consistency

4

slide-5
SLIDE 5

Book / scribing

Types and Programming Languages By Benjamin C. Pierce I will not follow the book very closely Most lectures will not use slides Each lecture, one of you will be a scribe and take notes for the class. (This does not mean you shouldn’t take your own notes.) We will post the scribe notes on the web page. You should edit your notes for clarity and accuracy. Send the staff your notes within a week

  • f the lecture so we can post them.

5

slide-6
SLIDE 6

Grading

Assignments 40% Midterm exam 25% Final exam 25% Scribing and participation 10%

6

slide-7
SLIDE 7

Assignments

Some writing. Some math. Some programming, but not too much About one homework every 7-10 days Plus occasionally some small exercises due before the next lecture, usually one or two short questions

7

slide-8
SLIDE 8

Website

http://inf.usi.ch/faculty/nystrom/teaching/pl/sp13/ Everything will be posted there

8

slide-9
SLIDE 9

Moodle

Exists.

9

slide-10
SLIDE 10

How would you like us to communicate with you?

slide-11
SLIDE 11

Community

Moodle forums are an abomination unto Nuggan. Join the G+ community for this course.

  • Discuss assignments, ask questions there.
  • Announcements will go there and to the web page.

Questions for the staff: usi-pl-staff@googlegroups.com

11

slide-12
SLIDE 12

What do you want to get out of this course?

slide-13
SLIDE 13

What do I want you to get out of this course?

slide-14
SLIDE 14

What do I want you to get out of this course?

  • Become familiar with different programming paradigms
  • Understand principles behind programming languages
  • Apply these principles to solve “real” problems

14

slide-15
SLIDE 15

What do I want you to get out of this course?

  • Become familiar with different programming paradigms
  • Understand principles behind programming languages
  • Apply these principles to solve “real” problems

15

slide-16
SLIDE 16

Language features

We’ll look at features common across multiple languages Variables Functions Eager and lazy evaluation Mutable state (assignment) Exotic control-flow constructs: exceptions, continuations Typing, subtyping, polymorphism Objects

16

slide-17
SLIDE 17

Different paradigms

We’ll look at several different programming languages and try to distill them to their essential features We’ll also look at how those features interact

  • e.g., parametric polymorphism + subtyping = WTF!?

But, we’ll program primarily in Haskell

17

slide-18
SLIDE 18

Why Haskell?

slide-19
SLIDE 19

Get out of your comfort zone

19

slide-20
SLIDE 20

Learning zone

20

slide-21
SLIDE 21

Panic zone

21

slide-22
SLIDE 22

Why Haskell?

Haskell is a pure functional language

  • No assignment, no loops
  • You have to think differently about programs

Haskell is lazy

  • Think about computation as function composition, not

as a sequence of instructions

22

slide-23
SLIDE 23

Haskell crash course

This Thursday Bring your computers

23

slide-24
SLIDE 24

What do I want you to get out of this course?

  • Become familiar with different programming paradigms
  • Understand principles behind programming languages
  • Apply these principles to solve “real” problems

24

slide-25
SLIDE 25

PL principles

Focus is on semantics (what do programs mean?) (Mostly) ignore syntax (what do programs look like?)

25

slide-26
SLIDE 26

Dynamic semantics

How does a program behave? How is a program evaluated? We’ll experiment with different semantics by implementing interpreters We’ll define behavior formally with operational semantics Formal semantics lets you state precisely and prove properties of programs

26

slide-27
SLIDE 27

What does this expression do?

‘1’ + ‘2’

27

slide-28
SLIDE 28

Static semantics

Restrictions on programs to provide (some) correctness guarantees

  • e.g., if this program type checks, it won’t core dump

Focus on type systems Some other formal methods (e.g., program verification) are covered in other classes

28

slide-29
SLIDE 29

What do I want you to get out of this course?

  • Become familiar with different programming paradigms
  • Understand principles behind programming languages
  • Apply these principles to solve “real” problems

29

slide-30
SLIDE 30

Languages are models of dynamic systems

A programming language provides abstractions and ways to compose these abstractions The languages you are familiar with are models of computer systems They provide abstractions for data and computation

30

slide-31
SLIDE 31

31

abstractions compositions Assembly languages addresses, registers, instructions, labels sequences of instructions Procedural languages booleans, arithmetic, loops, arrays, procedures sequences of statements, procedure calls OO languages

  • bjects, methods, fields,

classes method invocation, inheritance Functional languages first-class functions, algebraic data types function application, type constructors

slide-32
SLIDE 32

32

Languages are models of dynamic systems

But languages can model not just computer systems, but any dynamic system General-purpose languages provide abstractions for modeling computation Domain-specific languages provide abstractions for

  • ther domains
slide-33
SLIDE 33

Domain-specific languages

33

abstractions compositions SQL relations, tuples, queries joins, selection, projection make files, build rules dependencies lex characters, strings sequences, alternation (|), repetition (*) yacc tokens, nonterminal symbols grammar rules OpenFlow packets, network flows, channels matching, actions (drop, forward, etc) OpenSCAD shapes union, intersection, linear transformations

slide-34
SLIDE 34

Domain-specific languages

34

When designing a system, can be useful to think of the system as a language Implement the system as an interpreter for a domain-specific language A DSL can either:

  • be a language in its own right or
  • e.g., yacc
  • be embedded in a general-purpose language as a library
  • e.g., parser combinators

Same issues that arise with general-purpose languages arise with domain-specific languages

  • name binding, control-flow, mutation, evaluation order, ...
  • similar problems => similar solutions
slide-35
SLIDE 35

Homework for Thursday

Do Assignment 0. It’s easy.

  • https://docs.google.com/forms/d/1Mers7bsiRrG6_VF9YcYkIEM-AIiIjAtoz90cWHWSt40/viewform

Install ghc (the Glasgow Haskell Compiler)

  • 7.4 or later
  • http://haskell.org
  • Mac users:
  • brew install ghc haskell-platform
  • port install ghc

35