cs61b lecture 1 beginning day 1

Upload: xes

Post on 25-Feb-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    1/51

    A Note for those Stumbling on these Slides (Hi!)

    These lecture slides are not intended as written reference mate

    Just reading them probably wont be very educational.

    Best used in combination with webcasts and source code refere

    See (Video) and (Code) links under each lecture: http://cs6

    http://cs61b.ug/sp16
  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    2/51

    CS61B, Spring 2016

    Lecture 1:

    Introduction Course Logistics

    Hello World

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    3/51

    61B Overview

    What is 61B about?

    Efficiency

    Algorithms. Data Structures.

    Programming (efficiently)

    Designing, building, testing, and debugging large programs

    Use of programming tools. git, IntelliJ, JUnit, and various command line tools.

    Java (not the focus of the course!)

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    4/51

    Why study algorithms and data structures?

    Daily life is supported by them.

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    5/51

    Why study algorithms and data structures?

    Major driver of current progress of our civilization.

    http://www.youtube.com/watch?v=8XQlIvlWqpohttp://www.youtube.com/watch?v=8XQlIvlWqpohttp://www.youtube.com/watch?v=8XQlIvlWqpo
  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    6/51

    Why study algorithms and data structures?

    Major driver of current progress of our civilization.

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    7/51

    Why study algorithms and data structures?

    To become a better programmer.

    The difference between a bad programmer and a goodwhether [the programmer] considers code or data str

    more important. Bad programmers worry about the code

    programmers worry about data structures and

    relationships. - Linus Torvalds (Creator of Linux)

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    8/51

    Why study algorithms and data structures?

    For intellectual stimulation:

    Possible to draw without picking up pencilor going back over any lines.

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    9/51

    Why study algorithms and data structures?

    To understand the universe:

    http://www.youtube.com/watch?v=-ZcEDqyMbFwhttp://www.youtube.com/watch?v=-ZcEDqyMbFwhttp://www.youtube.com/watch?v=-ZcEDqyMbFw
  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    10/51

    Why study algorithms and data structures?

    To

    create

    beautifulthings.

    http://www.youtube.com/watch?v=BIjj3Qcmbf4http://www.youtube.com/watch?v=BIjj3Qcmbf4
  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    11/51

    Everyone else is doing it, so why shouldnt we?

    Why study algorithms and data structures?

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    12/51

    Who are you?

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    13/51

    Who are we?

    Instructor: Josh Hug (me) [email protected] 779 Soda

    GSIs:

    Leo Colobong Jimmy Lee Sarah Kim Kay Ou

    Akhil Batra Alan Yao Allen Guo Allen Z

    Alice Sheng Amit Vijay Akula Austin Le Anush

    Carlos Flores Chris Jeng Daniel Nguyen Daniel

    Dennis Zhao Gilbert Ghang Giulio Zhou Jim ReJimmy Lee Kay Ousterhout Leo Colobong Luise V

    Nick Rose Ross Teixeira Rudy Laprade Sarah

    Sean Zhu Sherdil Niyaz Ye Seon Lee

    http://cs61b.ug/sp16/staff.html

    mailto:[email protected]://cs61b.ug/sp16/staff.htmlmailto:[email protected]
  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    14/51

    But Thats Not All...

    Tutors:

    Colbert Guan Hayden Sheung Kuriakose "Sony" Th

    Tara Rezvani Jennifer Liang Raymond ZhaoBhuvana Bellala Megan Zhu Mitas Ray

    Jared Rulison Michael Aboody Laura Harker

    Maurice Lee Dasheng Chen Matthew Mussome

    Daniel Khasanov Khalid Shakur Raquel Layug

    Julian Early Yue Andy Zhang (And more coming

    http://cs61b.ug/sp16/staff.html

    http://cs61b.ug/sp16/staff.html
  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    15/51

    But Wait, Theres More...

    Lab Assistants:

    Vinay Koshy Kevin Lin Lance Xing Chen Gong Evan Sheng

    Mark Sun Brandon Huang Divyansh Agarwal Steven Chen Milan Saxena

    Hung Vu Vy Ly Rami Shahatit Robert Matych Thong Dinh

    Joyce Luong Nicolas Zoghb Seunghwna Choi Christine Munar Santos Tobar

    Ruihan Zhao Anusha Syed Abhinav K Adduri Andrew Linxie Lisa Jian

    Melis Kirikoglu Joe Kuang Allen Melody Huang Lily Lin

    Yuxi Chen Ricardo Herrera Yuki Mizuno Yao Ge Keeyune Cho

    David Zhang Parsa Khajeh Ahmad Attari Alice Tarng Antares Chen

    Michelle Ahn Kevin Kim Brian Lee Stella Tao Kevin Skorstad

    Patty Long Yanhe Chen Ryan Lee Andrew Dildy William Guss

    Mathew Joseph Samuel Choi Andrew Leong Levon Korganyan Sagang Wee

    Jonathan Ngan Kevin Li Scott Post Konrad Matthaei Aidan Clark

    Jung Yun Rhee Helen Che Caroline Kim Samuel Khano Alexander Hwa

    David Fang Kimberly Tze

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    16/51

    The Manner in Which Learning Occurs (TMW

    http://www.youtube.com/watch?v=OVtnnIifaU8http://www.youtube.com/watch?v=12lSScKSx20http://www.youtube.com/watch?v=12lSScKSx20http://www.youtube.com/watch?v=OVtnnIifaU8
  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    17/51

    TMWLO: A Small Minority

    Lectures

    Introduction to new material.

    Reading

    More thorough introduction.

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    18/51

    TMWLO: The Vast Majority

    Labs, Weekly(ish) Homework, and Your Own Experimentation

    Practice with tools, programming techniques, Java syntax, and a

    and data structures.

    Section

    Practice with concepts and Java syntax.

    Projects

    Similar to labs and HW, but larger and include a design compon

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    19/51

    Course Logistics

    This slide is green

    its easy to find wheyoure looking atwebcasts.

    l f i

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    20/51

    Places to Get Information

    Official Course Resources

    Course website: http://cs61b.ug/sp16

    Lectures (or webcasts). Piazza: http://piazza.com/class/61b

    Office hours (in 779 Soda this week, somewhere else next week

    Lab (ok to discuss anything, even not on lab).

    Discussion.

    Homework Parties.

    Guerrilla Sections.

    Group Tutoring Sections.

    Textbook: Head First Java (optional, silly, useful).

    Unofficial: Google, Stack Overflow, other programming courses on t

    various online documentation, etc.

    L i i l D il

    http://cs61b.ug/sp16http://piazza.com/class/61bhttp://cs61b.ug/sp16
  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    21/51

    Logistical Details

    For waitlisted folks: If you do project 0, I will get you in by week

    If possible, go to your assigned section and lab this week.

    If you dont have one yet, go to any section or lab.

    If room is too full, priority goes to those officially registered Please wait outside until 2 minutes before start (XX:08).

    Once attendance settles, doesnt matter which lab/section/lect

    registered for.

    Please post administrative issues to Piazza or send an email to

    eecs.berkeley.edu

    Please dont email me directly (sorry!).

    1200 students * 1 minute/student = 20 hours.

    61B 2 0 C St t

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    22/51

    61B 2.0 - Course Structure

    Phase 1: Programming Intensive Introduction to Java.

    Weeks 1-4

    One browser-based programming HW (this HW0 is optional). Three labs to introduce you to various tools (starting this week)

    Two projects (proj0 and proj1).

    Phase 2: Advanced Programming

    Weeks 5-7 One small HW.

    One large project, due 3/7.

    Labs to support large project.

    61B 2 0 C St t

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    23/51

    61B 2.0 - Course Structure

    Phase 3: Data Structures and Algorithms

    Weeks 8-14

    Labs: Implement a data structure or algorithm. Six HWs: Apply a data structure or algorithm.

    One medium sized data structure/algorithms project.

    See calendar at http://cs61b.ug/sp16for more.

    Lab Logistics

    http://cs61b.ug/sp16http://cs61b.ug/sp16
  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    24/51

    Lab Logistics

    OK to work on labs ahead of time.

    Lab always due by Friday at 10:00 PM.

    10% of lab grade is attendance.

    Dont like attending? Can instead submit early by 10:00 PM

    Full credit for reasonable effort.

    Some labs are freebies (automatic credit, even if you dont

    14 total labs, worth 2 points each. Lowest two are dropped. No exte

    grace hoursexcept emergencies.

    HWs

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    25/51

    HWs

    Homework breakdown:

    HW0: Optional browser based Java exercises.

    HW1: Practice with advanced Java features.

    HW2-7: Applications of various data structures and algorithms.

    Due dates vary. See calendar.

    7 total required homeworks, worth 10 points each. Lowest homewo

    dropped. No extensions or grace hoursexcept emergencies.

    Projects

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    26/51

    Projects

    Four projects

    One lightweight project, two medium projects, one large projec

    Project 0 (team): 10 points

    Project 1 (team): 25 points

    Project 2 (solo): 40 points

    Project 3 (solo): 25 points

    Project 2 will be the Hilfinger style systems project (very time in

    All code on solo projects must be your own work.

    Ok to discuss with others and help debug.

    May have opportunities for extra credit on some projects. More late

    Exams

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    27/51

    Exams

    Exams will be hard

    Median scores will be lower than you might be used to (ideally

    Two midterms in evenings, one final exam.

    One sheet of paper (front and back) per exam.

    If your midterm grades are statistically much worse than your fi

    replace your midterm grade. See course info (tomorrow) for the

    Exam dates (midterms tentative until room deadlines confirmed): Midterm 1: February 12th, 7:00 - 9:00 PM (drop deadline is Feb

    Midterm 2: March 31st, 6:00 - 8:00 PM

    May 11th(final exam) at 7 PM.

    Some alternate exam times will be available.

    Course Grade

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    28/51

    Course Grade

    Breakdown: 384 points total.

    Midterms: 100 points total.

    Final: 100 points.

    Projects: 100 regular points.

    HW: 60 points (10 points each)

    Lab: 24 points (2 points each)

    Grades are not curved, i.e. they are not based on your relative perfoSp2015, I did not change the bins at all. Tentativebins:

    >323: A-

    >265: B-

    >207: C-

    See course handout (online) for full details.

    Plus occasiona

    for extra credit fcourse feedbac

    Course Pacing

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    29/51

    Course Pacing

    We will start off very fast.

    Optional HW0 is out.

    Intro to Java syntax.

    Will take 1-4 hours.

    Work with friends!

    Recommended that you complete before your lab.

    Strongly recommended that you complete by lecture Friday

    Lab 1 and Lab 1B are both available.

    Lab1: How to use various tools. Lab1b: How to set up your home computer (maybe do befo

    Project 0 released Friday. Due next Friday Jan 29th (10 days from

    semester).

    Exercises all the basic Java features.

    Allowed to work in pairs (more next time).

    One Last Warning From an Internet Comments Section

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    30/51

    One Last Warning From an Internet Comments Section..

    From the comments of 15 Programming Languages You Need to Know in 2015

    http://mashable.com/2015/01/18/programming-languages-2015/?utm_cid=mash-com-fb-tech-linkhttp://mashable.com/2015/01/18/programming-languages-2015/?utm_cid=mash-com-fb-tech-linkhttp://mashable.com/2015/01/18/programming-languages-2015/?utm_cid=mash-com-fb-tech-link
  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    31/51

    Hello World

    (See Course Website for In-Class Coding Code

    (Might be a little boring if you know Java alrea

    Java Observations

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    32/51

    Java Observations

    All Java programs are object oriented.

    Every Java file must define a class, and that c

    must have the same name.

    To run a Java program, you must create a public

    void main(String[] args).

    More Java Observations

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    33/51

    More Java Observations

    Java isstatically typed.

    Every variable, parameter, and function must have a defined ty

    choice is permanent.

    These types are checked for consistency before program can ru

    Good:

    It is more efficient. Code runs faster because interpreter doesn

    types. Catch some errors before the user ever runs your mobile game

    trying to take their money.

    Code is easier to reason about.

    Bad:

    Code is less general, and more verbose.

    Citations

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    34/51

    Citations

    Real-time MRI by the New Scientist: https://www.youtube.com/watch?v=8XQlIvlWqpo

    Self-driving car image by The Guardian:

    http://www.theguardian.com/technology/2014/may/28/google-self-driving-car-how-does-it-work

    Dance Dance Revolution videos from:

    https://www.youtube.com/watch?v=OVtnnIifaU8

    https://www.youtube.com/watch?v=12lSScKSx20

    https://www.youtube.com/watch?v=12lSScKSx20https://www.youtube.com/watch?v=OVtnnIifaU8http://www.theguardian.com/technology/2014/may/28/google-self-driving-car-how-does-it-workhttps://www.youtube.com/watch?v=8XQlIvlWqpo
  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    35/51

    Slides That Follow This Are Obsolete

    Java Observations

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    36/51

    All Java programs are object oriented.

    All code must live in a class!

    If we define a class named Potato, this definition must go in Pot

    If we want something to happen when we run the program, we

    create a public static void main(String[] args)

    Functions are called methods in Java.

    More Java Observations

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    37/51

    Java is statically typed.

    Before we can use a variable, we permanently set its type.

    Functions and their parameters must have declared types.

    Before a program can even run, it is type checked.

    The good:

    You can catch some errors before the user tries running your pr

    Makes code more readable. Programmer knows EXACTLY what getting.

    Code runs faster.

    The bad:

    Code is more verbose.

    Java Observations

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    38/51

    All Java program are object oriented.

    All code must live inside a class.

    A class Uh.java must define a class Uh.

    If we want to run a Java program, we must create a public st

    void main(String[] args)

    More Java Observations

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    39/51

    Java is statically typed.

    Before we can use a variable, we make a permanent decision ab

    type.

    All functions have a declared return type.

    Before a program even runs, it is complete type checked.

    The good:

    Code will execute more efficiently (less space, less time). Easier to reason about what a program does.

    Prevents runtime errors. Errors are caught before user gets the

    The bad:

    Code is more verbose. Well have to generics.

    Whats Next

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    40/51

    This week:

    HW0: Out now. Will give you a chance to explore Java basics on

    Lab 1: How to compile and run code on the lab machines. How

    homework starter files and submit them. If possible, do HW0 b

    Lab 1B (optional): How to compile and run code on your own m

    Friday lecture: What all that public static blah blah stuff actually

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    41/51

    Solutions to slides developed in class

    Java Observations

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    42/51

    All Java program are object oriented.

    More Java Observations

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    43/51

    Java is statically typed.

    Java Observations

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    44/51

    All Java program are object oriented.

    More Java Observations

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    45/51

    Java is statically typed.

    Every variable and function must have a declared type.

    Decision is permanent.

    Before a Java program runs, it is type checked. If type checkingprogram doesnt even start.

    Good:

    Easier to reason about code (you know what all your variables a Catch errors more easily (and before they reach users).

    Code will run more efficiently (in memory usage and in time).

    Bad:

    More verbose (often much more verbose)

    Java Observations

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    46/51

    Java is object oriented.

    Every piece of code must be associated with a class.

    Every .java file must define a class:

    A Java file Potato.java must define a class called Potato. To run a Java class, you must define a method called main that

    signature public static void main(String args[])

    When Potato is run, its main method is called.

    More Java Observations

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    47/51

    Java is statically typed.

    Every variable and method (a.k.a. function) must have a defined

    This type can never change.

    Before code runs, it must pass a type check: Example of a failed type check: int x = monkeys;

    Good things:

    Catches some bugs before they reach the person running y

    Easier to reason about code since variables have known typ

    Code can run more efficiently (less space and time).

    Bad things

    Code is more verbose and redundant (sometimes extremel

    Java

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    48/51

    Java is object oriented:

    All code must be part of a class. Define classes with public clas

    A class Potato.java must define a class called Potato.

    To run a class, we must define a function called main. Functionsare called methods in Java.

    Will discuss reasons over the next several weeks.

    Java

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    49/51

    Java is statically typed, and types are checked BEFORE program runs

    All variables must be declared with a specific type before use.

    All methods return a specific type.

    The Good: Easier to catch programming errors.

    Typing provides implicit documentation.

    More efficient execution (no run-time type checking).

    The Bad:

    Java code is more verbose, e.g. need a separate larger metdoubles, etc.

    Java Observations

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    50/51

    Java is object oriented.

    Every piece of code needs to be associated with a class.

    To execute a class, define a method called main, it will run whe

    executed. public static void main(String[] args)

    The top-level class of a .java file must have the same name as th

    itself.

    More Java Observations

  • 7/25/2019 Cs61b Lecture 1 Beginning Day 1

    51/51

    Java is statically typed.

    Before we can use a variable, it must have a specified type.

    This type can never change.

    Any expressions involving a variable (or other entity) of a speciffollow the rules.

    Example of not following the rules:

    int x = potatobrains;

    Type checking is performed BEFORE THE CODE EVER RUNS!

    Prevents errors from reaching people using your code. Easier to find errors.

    Static types:

    Allow for more efficient code execution.

    Also provided a limited amount of documentation.