How do you use a program? How do you run a program?bec/courses/csci3155-s14/...Programming in Scala,...
Transcript of How do you use a program? How do you run a program?bec/courses/csci3155-s14/...Programming in Scala,...
1
A puzzle …
Suppose you want to run lots of JavaScript programs--all the cool kids are doing it, but unfortunately you have a computer that can only execute x86 assembly. So you decide to write a compiler from JavaScript to x86 assembly.
Furthermore, suppose that you think Scala is the best language for writing a compiler; you find the language has particularly effective constructs for implementing compilers. Unfortunately, your computer only has a C to x86 compiler. You know that you can write an awesome compiler in Scala that produces efficient x86 code, but you're not so sure you can write an efficient compiler in C. What do you do?
1
Back up. What is a program?
2
How do you use a program?
3
How do you run a program?
4
What is compilation?
5
What is an interpreter?
6
2
Uh oh …
7
Some terminology
• A programming language is
• A program is
8
An analogy: A cooking recipe
9
Syntax and semantics: An analogy
10
Meta Language and Object Language
11
Interpreter
12
3
Compiler
13
Back to the puzzle …
• What do we have?
14
Step 0
15
Step 1
16
Step 2
17
Step 3
18
4
Step 4
19
Step 5
20
Principles of Programming Languages
Prof. Evan Chang
Meeting 1: Welcome, CSCI 3155, Spring 2014
Getting to Know You: “I, …, wonder …”
22
Distraction-Free Classroom
• Let’s turn off our cell phones and wi-fi
23 … just imagine that we have class at 30,000 feet
Distraction-Free Classroom
• Laptop users, please sit in the back rows, on the sides
24
5
Introductions
• Introduce yourself to someone you haven’t met before. [credit Boulder New Tech Meetup]
• Two minutes!
25
Introductions: Your guide this semester
• Office hours: T 10:45am-11:45am, R 2pm-3pm, or drop by ECOT 621
26
Introductions: Other guides
27
David Johnson Alok Joshi
Instruction Philosophy
• Do you drive?
28
Who is the better instructor?
Instructor Pass Rate on Driver’s Test
#1 98% #2 88%
29
Who is the better instructor?
Instructor Pass Rate on Driver’s Test
Accident Rate in Next Year
#1 98% 20% #2 88% 0.1%
30
Instructor #1 focuses on the exam, while instructor #2 focuses on the ideas and skills the student needs for the future.
6
Focusing on guiding towards understanding … • Project-based course: Build a JavaScript
interpreter – Incrementally in 6 two-week projects – Two weeks of discussion towards completing
the lab, driven by you (in class + on Piazza)! – Fridays are lab sessions—bring a laptop – Labs due Friday Saturday – No late labs but generous “redo” policy and
drop lowest
31
subset of Discussion, discussion, discussion
• Discussion, not lecture – Only meeting I will use slides
• Please interrupt at any time! • It’s completely ok to say:
– I don’t understand. Please say it another way. – Slow down!
• Course is project-based – Lab assignments prompt the discussion – Expectation on you to be active
32
Oath
33
Introductions: About you?
• What do you want to get out of this class?
34
What do you want to get out of this class?
35
Getting Your Money’s Worth
Why Study PL?
7
“Isn’t PL ancient history?”
• PL is an old field within Computer Science
• 1920’s: “computer” = “person” • 1936: Church’s Lambda Calculus (= PL!) • 1937: Shannon’s digital circuit design • 1940’s: first digital computers • 1950’s: FORTRAN (= PL!) • 1958: LISP (= PL!) • 1960’s: Unix • 1972: C Programming Language • 1981: TCP/IP • 1985: Microsoft Windows
37
Don’t we have enough prog. languages?
38
A Dismal View of PL
39
Java
Ruby
Not a history course
Not quite a trip to the zoo …
40
More like a study of anatomy …
41
So Why Study PL?
8
“I like Ruby. Isn’t that enough?”
43
What PLs do you know?
44
What PLs do you know?
45
TIOBE Language Popularity Index
46 http://www.tiobe.com/tiobe_index/
TIOBE Language Popularity Index
47
Jobs!
48 http://blog.timbunce.org/ 2008/02/12/ comparative-language-job-trend-graphs/
9
Increase ability to learn new languages
• You will need to learn many languages during your careers.
• You will learn concepts that make it easier for you to learn new languages in this class.
49
Have you ever had to pick a language?
50
Have you ever had to pick a language?
51
Improve background for choosing an appropriate language
52
Have you heard of MapReduce?
53
Have you heard of MapReduce?
54
… inspired by ideas from PL theory
10
Get new ways of viewing computation and approaching algorithmic problems
55
Get new ways of viewing programs
• What is a program? How it executes, right?
56
Better understanding of the significance of implementation
57
Other Reasons?
58
Other Reasons?
59
How?
11
Build interpreters for JavaScript in
• Never heard of it?
61
A convenient language for language tools (compilers, interpreters, etc.) Requirements
63
Prerequisites
• CSCI 2270 (CS2: Data Structures) • CSCI 2824 (Discrete Structures) • [CSCI 2400 (Computer Systems)]
• Proficiency in programming and ready to pick up new languages quickly. – trees, recursion, induction, stack+heap
• If you have not satisfied the prerequisites or have any concerns, please see me.
Assignments
• Labs (30%) • Quizzes (20%), Midterm (20%), Final (25%) • Participation (5%) and Reading
64
Reading, Participation, Extra Credit
• Reading to spark class discussion, post/bring questions
• Textbook: – Friedman, Wand. Essentials of Programming Languages, 3rd
edition – Odersky, Spoon, Venners. Programming in Scala, 2nd edition – Course notes
• Participate actively in-class and online • Extra Credit really extra
65
Online Discussion: Piazza
• “Begin Active” – Post ¸1 substantive comment, question, or
answer each week
• Take a moment to reflect upon the day’s reading or class discussion
• Replaces E-Mail – Course announcements – Questions for course staff
66
12
Labs, Quizzes, and Exams
• Labs – Are two weeks, due Saturday 6:00pm – In pairs for learning and interviews but everyone submits and
individually responsible for the material – Collaboration are encouraged (but you must acknowledge!) – Autograde part and interview part
• Quizzes (Tue after each lab) • Midterm Exam: Feb 27 • Final Exam: According to University
– Mark your calendars. No make-ups (except special circumstances)
67
Course Administration
Policies
• Read the course syllabus http://www.cs.colorado.edu/~bec/courses/csci3155-s14/
• Coming next time means you have read and agreed to them.
69
Highlights
• Lab assignment late and “redo” policy • No make-up exams (unless emergency or
special accommodation) • Special accommodation requests (disability,
religious observances) within first four weeks • Regrades requests within one week
70
Most Important Goal
Have Lots of Fun!
71
For Next Time
• Read the course syllabus http://www.cs.colorado.edu/~bec/courses/csci3155-s14/
• Join the course moodle, Piazza, upload a profile picture, and introduce yourself
• Set up a Scala development environment – Scala IDE screencasts
72
13
Controversial Editorial …
• Linked on the schedule • Optional, but entertaining
• “Take this course to get a first-rate CS education”
73