week 1 friday what did we talk about last time our first
play

Week 1 - Friday What did we talk about last time? Our first Java - PowerPoint PPT Presentation

Week 1 - Friday What did we talk about last time? Our first Java program Hardware Storage for all the data and instructions on your computer Modern computers store everything as binary digits (bits) which have a value of 0 or 1 .


  1. Week 1 - Friday

  2.  What did we talk about last time?  Our first Java program  Hardware

  3.  Storage for all the data and instructions on your computer  Modern computers store everything as binary digits (bits) which have a value of 0 or 1 . 1 byte = 8 bits = 2 10 bytes 1 kilobyte (kb) 1 megabyte (mb) = 2 20 bytes = 2 30 bytes 1 gigabyte (gb) = 2 40 bytes 1 terabyte (tb)

  4. Cache • Actually on the CPU • Fast and expensive RAM • Primary memory for a desktop computer • Pretty fast and relatively expensive Flash Drive • Faster than hard drives • Seen on USB drives but SSDs are becoming common too Hard Drive • Secondary memory for a desktop computer • Slow and cheap Optical Drive • Secondary memory that can usually only be written once • Very slow and very cheap

  5. Monitor • Common visual output device Speakers • Common audio output device Mouse • Common input device Keyboard • Common input device

  6.  Now that we've (sort of) defined computers, what is computer science?  The study of information, computation, and solving problems with programs  Subfields:  Theoretical computer science  Programming languages and compilers  Operating systems and networking  Graphics  Numerical computing  Information storage, retrieval, and security  Architecture and hardware  Artificial intelligence and machine learning

  7.  Computers are stupid, but fast  Programming is the process of giving them very detailed instructions about what to do  Usually, programming is done in a rigid, formalized language, like Java  English is insufficient:  E.g., "Computer! Solve my relationship problems!"  Writing a program to solve your relationship problems in Java would require you to be more detailed and explicit

  8.  Computer science is built out of layers (like a burrito)  No one can understand everything  People tend to focus on a particular level

  9. User We will Application program here Operating System Hardware

  10.  The process of giving computers very detailed instructions about what to do  How do we do that exactly?  First, we need a programming language like Java  How do we turn a set of instructions written so that a human can read them into a set of instructions that a computer can read?  Magic, of course!

  11.  There are many different programming languages:  Java  C/C++  ML  …thousands more  Each has different advantages in different situations

  12.  We can classify languages as high or low level  High level languages allow you to give more abstract commands that are more like human thought processes or mathematics  Low level languages are closer to the computer world and give explicit instructions for the hardware to follow Machine Assembly Low High C C++ Java Python Code Language

  13.  We use a program called a compiler to turn a high level language into a low level language  Usually, the low level language is machine code  With Java it's a little more complex

  14. Source Machine Code Code Hardware 010101010 Computer! Solve a 010100101 Execute problem; 001110010

  15.  Java is more complicated  Java runs on a virtual machine, called the JVM  Java is compiled to an intermediate stage called bytecode , which is platform independent  Then, the JVM runs a just-in-time compiler whenever you run a Java program, to turn the bytecode into platform dependent machine code

  16. Java Source Java Machine Hardware Code Code Bytecode class A { 101110101 010101010 Problem p; 101011010 010100101 JVM p.solve(); 110010011 001110010 }

  17. 1. Write a program in Java 2. Compile the program into bytecode 3. Run the bytecode using the JVM (which automatically compiles the bytecode to machine code)

  18. Often goes through phases similar to the following: 1. Understand the problem 2. Plan a solution to the problem 3. Implement the solution in a programming language 4. Test the solution 5. Maintain the solution and do bug fixes Factor of 10 rule!

  19.  You have heard people talking about all the 1 's and 0 's inside of a computer  What does that all really mean?  Using semiconductor physics, we can make a tiny little piece of a microchip be in one of two states, say, OFF and ON , like a switch  If we say that OFF is 0 and ON is 1 , then, by using a lot of these switches, we can represent a lot of 1 's and 0 's

  20.  What do we do with those 1 's and 0 's?  To begin with, we represent numbers  How many of you have heard of base 10?  How many of you have heard of base 2?  What's the definition of a number system with a given base?

  21.  Our normal number system is base 10  This means that our digits are: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9  Base 10 means that you need 2 digits to represent ten, namely 1 and 0  Each place in the number as you move left corresponds to an increase by a factor of 10

  22. Ten thousands Hundreds 3,482,931 Millions Ones Hundred Tens thousands Thousands

  23.  The binary number system is base 2  This means that its digits are: 0 and 1  Base 2 means that you need 2 digits to represent two, namely 1 and 0  Each place in the number as you move left corresponds to an increase by a factor of 2 instead of 10

  24. Sixty fours 256's Sixteens Fours 11111100100 1024's Ones 512's Twos 128's Eights Thirty twos

  25. 11111100100 = 1∙2 10 + 1∙2 9 + 1∙2 8 + 1∙2 7 + 1∙2 6 + + 1∙2 5 + 0∙2 4 + 0∙2 3 + 1∙2 2 + 0∙2 1 + 0∙2 0 = 1024 + 512 + 256 + 128 + 64 + 32 + 4 = 2020

  26.  You don't actually have to worry about doing binary conversions when you're coding Java  You should know this information because it explains how Java is different from math  In math, you can talk about an arbitrarily large number  In Java , each number is stored with a specific number of binary digits  There are limits on how big (or small) a given number can be

  27.  We'll talk more about data representation

  28.  Read Chapter 3

Recommend


More recommend