announcements & review

11
Lecture 3: Scaffolding and Output Announcements & Review Announcements Discussion Sections: PAI 5.70 until further notice Pair in same discussion Email: 305j in subject Last Time Acquiring & creating language Noam Chomsky Catherine Snow

Upload: osma

Post on 06-Jan-2016

25 views

Category:

Documents


0 download

DESCRIPTION

Announcements Discussion Sections: PAI 5.70 until further notice Pair in same discussion Email: 305j in subject. Last Time Acquiring & creating language Noam Chomsky Catherine Snow. Announcements & Review. Today. Compilation and Execution What’s “javac” do? - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Announcements & Review

Lecture 3: Scaffolding and Output

Announcements & Review

AnnouncementsDiscussion

Sections: PAI 5.70 until further notice

Pair in same discussion

Email: 305j in subject

Last Time• Acquiring &

creating language• Noam Chomsky• Catherine Snow

Page 2: Announcements & Review

Lecture 3: Scaffolding and Output

Today

Compilation and Execution– What’s “javac” do? – What happens next?

Basics– Scaffolding - what every program

needs– Making the computer talk to you!

Page 3: Announcements & Review

Lecture 3: Scaffolding and Output

Static Compilation & Execution

Easier case: The C programming language “static” ahead-of-time compilation model:

Tool: “cc” the C compilerYour file: Circle.c

“cc Circle.c” -> (Circle.a) -> a.outExecutable: a.out

“a.out”

Page 4: Announcements & Review

Lecture 3: Scaffolding and Output

Dynamic Compilation & Execution

Java “dynamic” compilation model:2 Tools

“javac” the Java bytecode compiler“java” the Java virtual machine

Your file: Circle.javaWhat do you do in Bluej?“javac Circle.java” -> Circle.class

Executing Bytecode: low-level virtual machine form machine independent, portableWhat do you do in Bluej?“java Circle.class”

Page 5: Announcements & Review

Lecture 3: Scaffolding and Output

Java Dynamic Compilation

Executing Bytecode: “java Circle.class” What happens?

Interpretation vs Dynamic Compilation

Page 6: Announcements & Review

Lecture 3: Scaffolding and Output

Dynamic Compilation & Execution

Java “dynamic” compilation model:Executing Bytecode:

“java Circle.class” - What happens?Interpreting 1. map each bytecode to a machine code

sequence,2. for each bytecode, execute the sequenceTranslation to machine code1. map all the bytecodes to machine code (or a

higher level intermediate representation),2. massage them (e.g., get rid of redundancies

between instructions), 3. execute the machine code

Page 7: Announcements & Review

Lecture 3: Scaffolding and Output

Dynamic Compilation & Execution

“Hotspot” compilation, a hybrid 1. Initially interpret2. Find the “hot” (frequently executed

code) methods, and translate only these hot methods to machine code

Page 8: Announcements & Review

Lecture 3: Scaffolding and Output

Basics

What you write– Scaffolding - what every program needs– Making the computer talk to you!

Comments - tell the compiler to ignore text// the compiler ignores this text on the same line

/* For multi-line comments, you can use * this form and it will ignore all this text

* too until it sees */

Page 9: Announcements & Review

Lecture 3: Scaffolding and Output

Scaffolding:Magic or Logical?

/* Kathryn S McKinley * January 10, 2005 * file: Song.java * My program does nothing right now! */public class Song{ // code can go here

public static void main (String [] args) { // code here too }}

Page 10: Announcements & Review

Lecture 3: Scaffolding and Output

Printing

System.out.print(“I love CS305j.”);

System.out.println(“I love CS305j.”);

[More examples in Bluej…]

Page 11: Announcements & Review

Lecture 3: Scaffolding and Output

Questions?