1 / 20

Lecture 0 CSIS10A Overview

Lecture 0 CSIS10A Overview. Welcome to CSIS10A (5 mins ) . Typical format for class meetings New material first (monitors off, notebooks out) Practice new material (like a lab) Syllabus Aim of this course (learning Java) Course assumes no prior knowledge of programming.

cadee
Télécharger la présentation

Lecture 0 CSIS10A Overview

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 0CSIS10A Overview

  2. Welcome to CSIS10A (5 mins) • Typical format for class meetings • New material first (monitors off, notebooks out) • Practice new material (like a lab) • Syllabus • Aim of this course (learning Java) • Course assumes no prior knowledge of programming. • What is a program? A set of step-by-step instructions that directs a computer to solve some problem. • Pretty much anything you can do with a computer, you can do by programming in Java

  3. Do introductions (15 mins) • class website: www.mpcfaculty.net/tom_rebold/CSIS10A.htm • Click on "Tell me about yourself" • Name • Major and what year • Why taking the course • Something unique about yourself • then we go around and tell each other

  4. Do administrative stuff (10 mins) • Few if any handouts will be printed. They will be posted on the web instead. • No late work (model solutions, quick turnaround) • For conflicts with class meetings: let me know now! • We will use the online textbook JavaNotes by Eck • Textbook does not always line up with class, but is a great reference – I will provide notes for each lab. • We will use online labs by Michael Kowalczk, used with permission. We will thank him at the end of class! • Academic dishonesty • Office hours, and by appointment • Computer science tutor will be available – Steve Bruemmer our instructional tech, 9-5 most days

  5. Do PB & J demonstration (20 mins) • Get into groups and write up instructions (10 mins) • Present the results and have me follow those directions (10 mins)

  6. PBJ Debrief • Talk about observations; similarities to programming • Explicitness • Sequence, selection, repetition • Dependencies - when does order matter? • Closing open files and stuff • What is a basic command? • Unexpected uses of software • Infinite loops

  7. Course will be challenging, fun, painful at times - much like making a sandwich • But, you will make yourself more marketable or may get sold on computer science!

  8. Basic computer anatomy

  9. What the parts do • CPU • ``The brain''; performs relatively basic operations • It only executes machine language • The machine language varies from CPU to CPU • Storage • Primary storage/random-access memory/RAM/``memory'' • Fast, but volatile and expensive • Secondary storage/hard drive/hard disk • Cheap and non-volatile, but slow • Input devices (the ``I'' in ``I/O'') • Mouse, keyboard • Output devices (the ``O'' in ``I/O'') • Monitor, speakers, printer

  10. How hardware relates to programming • Your .java program files are files, therefore found on the hard drive (typically) • Programs need to run fast, so the computer uses primary memory for programs that are currently running. • There are ways to communicate with I/O devices in Java.

  11. Communicating instructions to the computer • Problem: We want to give instructions to the CPU, but the CPU's language is hard for humans to read, write, and understand. How do we handle this? • One (painful) solution: Just program in machine code • Why is this so painful? Just note this C code:main() { printf("hello, world"); } • does the same thing as the machine code on the next slide. • Since machine code depends on the CPU, the program would only work on a limited number of machines anyway

  12. "Hello World" program in machine code • 127 69 76 70 1 1 1 0 0 0 0 0 0 0 0 0 2 0 3 0 1 0 0 0 224 130 4 8 52 0 0 0 88 7 0 0 0 0 0 0 52 0 32 0 7 0 40 0 28 0 25 0 6 0 0 0 52 0 0 0 52 128 4 8 52 128 4 8 224 0 0 0 224 0 0 0 5 0 0 0 4 0 0 0 3 0 0 0 20 1 0 0 20 129 4 8 20 129 4 8 19 0 0 0 19 0 0 0 4 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 128 4 8 0 128 4 8 188 4 0 0 188 4 0 0 5 0 0 0 0 16 0 0 1 0 0 0 188 4 0 0 188 148 4 8 188 148 4 8 8 1 0 0 12 1 0 0 6 0 0 0 0 16 0 0 2 0 0 0 208 4 0 0 208 148 4 8 208 148 4 8 208 0 0 0 208 0 0 0 6 0 0 0 4 0 0 0 4 0 0 0 40 1 0 0 40 129 4 8 40 129 4 8 32 0 0 0 32 0 0 0 4 0 0 0 4 0 0 0 81 229 116 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 4 0 0 0 47 108 105 98 47 108 100 45 108 105 110 117 120 46 115 111 46 50 0 0 4 0 0 0 16 0 0 0 1 0 0 0 71 78 85 0 0 0 0 0 2 0 0 0 2 0 0 0 5 0 0 0 3 0 0 0 6 0 0 0 5 0 0 0 1 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 68 0 0 0 0 0 0 0 221 0 0 0 18 0 0 0 46 0 0 0 0 0 0 0 54 0 0 0 18 0 0 0 53 0 0 0 164 132 4 8 4 0 0 0 17 0 14 0 1 0 0 0 0 0 0 0 0 0 0 0 32 0 0 0 21 0 0 0 0 0 0 0 0 0 0 0 32 0 0 0 0 95 74 118 95 82 101 103 105 115 116 101 114 67 108 97 115 115 101 115 0 95 95 103 109 111 110 95 115 116 97 114 116 95 95 0 108 105 98 99 46 115 111 46 54 0 112 114 105 110 116 102 0 95 73 79 95 115 116 100 105 110 95 117 115 101 100 0 95 95 108 105 98 99 95 115 116 97 114 116 95 109 97 105 110 0 47 115 47 103 99 99 45 51 46 52 46 52 47 105 51 56 54 95 99 101 110 116 52 48 47 108 105 98 0 71 76 73 66 67 95 50 46 48 0 0 0 0 2 0 2 0 1 0 0 0 0 0 0 0 1 0 1 0 36 0 0 0 16 0 0 0 0 0 0 0 16 105 105 13 0 0 2 0 115 0 0 0 0 0 0 0 160 149 4 8 6 5 0 0 176 149 4 8 7 1 0 0 180 149 4 8 7 2 0 0 85 137 229 131 236 8 232 97 0 0 0 232 184 0 0 0 232 179 1 0 0 201 195 0 255 53 168 149 4 8 255 37 172 149 4 8 0 0 0 0 255 37 176 149 4 8 104 0 0 0 0 233 224 255 255 255 255 37 180 149 4 8 104 8 0 0 0 233 208 255 255 255 49 237 94 137 225 131 228 240 80 84 82 104 20 132 4 8 104 192 131 4 8 81 86 104 148 131 4 8 232 191 255 255 255 244 144 144 85 137 229 83 232 0 0 0 0 91 129 195 151 18 0 0 82 139 131 252 255 255 255 133 192 116 2 255 208 88 91 201 195 144 144 144 144 144 144 144 144 144 144 144 85 137 229 131 236 8 128 61 196 149 4 8 0 116 12 235 28 131 192 4 163 192 149 4 8 255 210 161 192 149 4 8 139 16 133 210 117 235 198 5 196 149 4 8 1 201 195 144 85 137 229 131 236 8 161 204 148 4 8 133 192 116 33 184 0 0 0 0 133 192 116 24 199 4 36 204 148 4 8 232 124 124 251 247 141 182 0 0 0 0 141 191 0 0 0 0 201 195 144 144 85 137 229 131 236 8 131 228 240 184 0 0 0 0 131 192 15 131 192 15 193 232 4 193 224 4 41 196 199 4 36 168 132 4 8 232 20 255 255 255 201 195 144 144 85 137 229 87 86 83 131 236 12 232 0 0 0 0 91 129 195 214 17 0 0 232 190 254 255 255 141 131 24 255 255 255 141 147 24 255 255 255 137 69 240 41 208 49 246 193 248 2 57 198 115 22 137 215 137 246 255 20 178 139 77 240 41 249 70 193 249 2 57 206 137 250 114 238 131 196 12 91 94 95 201 195 137 246 85 137 229 87 86 83 232 0 0 0 0 91 129 195 133 17 0 0 141 131 24 255 255 255 141 187 24 255 255 255 41 248 193 248 2 131 236 12 141 112 255 235 5 144 255 20 183 78 131 254 255 117 247 232 54 0 0 0 131 196 12 91 94 95 201 195 144 144 144 144 144 144 144 144 144 144 85 137 229 83 131 236 4 187 188 148 4 8 161 188 148 4 8 235 7 131 235 4 255 208 139 3 131 248 255 117 244 88 91 93 195 144 85 137 229 83 232 0 0 0 0 91 129 195 23 17 0 0 80 232 150 254 255 255 89 91 201 195 0 0 3 0 0 0 1 0 2 0 104 101 108 108 111 44 32 119 111 114 108 100 0 0 0 0 0 0 0 0 255 255 255 255 0 0 0 0 255 255 255 255 0 0 0 0 0 0 0 0 1 0 0 0 36 0 0 0 15 0 0 0 86 0 0 0 12 0 0 0 152 130 4 8 13 0 0 0 132 132 4 8 4 0 0 0 72 129 4 8 5 0 0 0 212 129 4 8 6 0 0 0 116 129 4 8 10 0 0 0 125 0 0 0 11 0 0 0 16 0 0 0 21 0 0 0 0 0 0 0 3 0 0 0 164 149 4 8 2 0 0 0 16 0 0 0 20 0 0 0 17 0 0 0 23 0 0 0 136 130 4 8 17 0 0 0 128 130 4 8 18 0 0 0 8 0 0 0 19 0 0 0 8 0 0 0 254 255 255 111 96 130 4 8 255 255 255 111 1 0 0 0 240 255 255 111 82 130 4 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 208 148 4 8 0 0 0 0 0 0 0 0 198 130 4 8 214 130 4 8 0 0 0 0 0 0 0 0 200 148 4 8 0 71 67 67 58 32 40 71 78 85 41 32 51 46 52 46 54 32 50 48 48 54 48 52 48 52 32 40 82 101 100 32 72 97 116 32 51 46 52 46 54 45 56 41 0 0 71 67 67 58 32 40 71 78 85 41 32 51 46 52 46 54 32 50 48 48 54 48 52 48 52 32 40 82 101 100 32 72 97 116 32 51 46 52 46 54 45 56 41 0 0 71 67 67 58 32 40 71 78 85 41 32 51 46 52 46 52 0 0 71 67 67 58 32 40 71 78 85 41 32 51 46 52 46 52 0 0 71 67 67 58 32 40 71 78 85 41 32 51 46 52 46 52 0 0 71 67 67

  13. One (bad) solution: Try to make a system where we can just type in instructions with natural language, and have the computer translate that into machine code. • Extremely difficult • Very ambiguous; for example, in ``I called the guy with the cell phone'' - who is carrying the cell phone?

  14. One (better) solution: Use an intermediate language that is somewhat easy for humans to use (i.e. Pascal, C++, etc.), and have the computer translate that into machine code. This translator is called a compiler. • Compiled languages such as C work in this way.

  15. Running programs the Java way • In Java, the computer simulates an imaginary CPU with very particular specifications. • This imaginary CPU is called the Java virtual machine (or JVM). • Java simulates the JVM much like an emulator simulates a Super-Nintendo • Main advantage: The same code can be made to run on any machine without modification (see previous slide). • Example: Good for Java applets on the web • Another advantage: Much better security can be implemented when running code in a virtual machine. • Example: again, crucial for Java applets on the web • One disadvantage: Simulating the JVM makes the program run slower • One caveat: There can actually be variations in your program from machine to machine, for a number of reasons • Different I/O devices • Different library implementations (or bugs) • Bugs in a JVM implementation (yes, it happens)

  16. Source file compiler  bytecode • The JVM's language is bytecode, which is found inside .class files. • The compiler converts java files into class files • Class files are not human readable • See the bytecode for the HelloWorld.java program

  17. Java source file public class HelloWorld {    public static void main(String[] args) {        System.out.println("Hello, World!");    }}

  18. Java Bytecode for previous slide 202 254 186 190 0 0 0 49 0 34 1 0 10 72 101 108 108 111 87 111 114 108 100 7 0 1 1 0 16 106 97 118 97 47 108 97 110 103 47 79 98 106 101 99 116 7 0 3 1 0 6 60 105 110 105 116 62 1 0 3 40 41 86 1 0 4 67 111 100 101 12 0 5 0 6 10 0 4 0 8 1 0 15 76 105 110 101 78 117 109 98 101 114 84 97 98 108 101 1 0 18 76 111 99 97 108 86 97 114 105 97 98 108 101 84 97 98 108 101 1 0 4 116 104 105 115 1 0 12 76 72 101 108 108 111 87 111 114 108 100 59 1 0 4 109 97 105 110 1 0 22 40 91 76 106 97 118 97 47 108 97 110 103 47 83 116 114 105 110 103 59 41 86 1 0 16 106 97 118 97 47 108 97 110 103 47 83 121 115 116 101 109 7 0 16 1 0 3 111 117 116 1 0 21 76 106 97 118 97 47 105 111 47 80 114 105 110 116 83 116 114 101 97 109 59 12 0 18 0 19 9 0 17 0 20 1 0 13 72 101 108 108 111 44 32 87 111 114 108 100 33 8 0 22 1 0 19 106 97 118 97 47 105 111 47 80 114 105 110 116 83 116 114 101 97 109 7 0 24 1 0 7 112 114 105 110 116 108 110 1 0 21 40 76 106 97 118 97 47 108 97 110 103 47 83 116 114 105 110 103 59 41 86 12 0 26 0 27 10 0 25 0 28 1 0 4 97 114 103 115 1 0 19 91 76 106 97 118 97 47 108 97 110 103 47 83 116 114 105 110 103 59 1 0 10 83 111 117 114 99 101 70 105 108 101 1 0 15 72 101 108 108 111 87 111 114 108 100 46 106 97 118 97 0 33 0 2 0 4 0 0 0 0 0 2 0 1 0 5 0 6 0 1 0 7 0 0 0 47 0 1 0 1 0 0 0 5 42 183 0 9 177 0 0 0 2 0 10 0 0 0 6 0 1 0 0 0 14 0 11 0 0 0 12 0 1 0 0 0 5 0 12 0 13 0 0 0 9 0 14 0 15 0 1 0 7 0 0 0 55 0 2 0 1 0 0 0 9 178 0 21 18 23 182 0 29 177 0 0 0 2 0 10 0 0 0 10 0 2 0 0 0 16 0 8 0 17 0 11 0 0 0 12 0 1 0 0 0 9 0 30 0 31 0 0 0 1 0 32 0 0 0 2 0 33

  19. A source file contains source code and is really just a simple text file. It contains (among other things) instructions for the computer to execute. • A ``.java'' ending is used to distinguish it as a Java source file • Java files have special structure so that the computer can translate it into machine code. • Use a text editor or an IDE (in this class we use BlueJ but you can also use Eclipse) to create source and make changes to it. • We'll make a simple "Hello World" program now!

More Related