CSCI 161 - Lecture 1

Instructor's Class Notes

  1. Class Essentials
  2. "What is Programming?"
    1. To understand what a program is you must first understand hardware and software.
    2. Hardware is what the software runs on. Your iPhone is hardware. Hardware in this context is simply a computer.
    3. A computer is a machine that manipulates data and executes list of instructions known as a program.
    4. For a machine to be a computer it must be "Turing Complete". Turing completeness is the ability for a system of instructions to simulate a Turing machine. A programming language that is Turing complete is theoretically capable of expressing all tasks accomplishable by computers; nearly all programming languages are Turing complete if the limitations of finite memory are ignored.
    5. Software is programming running on a computer - the programs; a program - list of instructions to be carried out by a computer.
    6. Programs are written in languages, called "Programming Languages."
    7. The first program written by Ada Lovelace in 1842. Was written on punch cards used to control a yet-to-be-built "Difference Engine" (a mechanical computer) by Charles Babbage who is coined "The Father of Computers."
    8. This course introduces you to programming and does so using one language: Java.
  3. "Why is Programming Important?"
    1. Computer Science is a vast discipline with many different areas of study. One can be a computer scientist without ever having to program.
    2. Yet all colleges and universities that offer Computer Science degrees require their students to take various courses in programming and programming languages. Why?
      Answer: Because the discipline of programming requires "algorithmic thinking." We study programming not because it is the most important aspect of Computer Science, but because it is the best way to explain the approach that computer scientists take to solving problems.
    3. Algorithm - A step-by-step instruction of how to accomplish a task.
    4. Do Androids Dream of Electric Sheep? - Do computers dream? They certainly speak and can be spoken to and their native language is binary.
    5. We humans think of numbers in terms of the decimal system. Computers think in terms of the binary system and binary is the root of all that is logical in computers.
    6. Computer programs can be written in many languages, some higher level than others. The lowest level language is the "machine language" (often referred to as machine code), it is binary, and it is tied to the physical computer on which it runs.
    7. Code is the fragment of a program.
    8. A program must be written, it must follow the syntax (rules) of the language it is written in and in order to run it must be compiled (put into a form to be executed).
  4. Introduction to Java
    1. Java is a little different than many languages. It doesn't compile into machine language, it compiles into machine-independent bytecodes.
    2. Java requires a Java Virtual Machine (JVM) in order to run a compiled Java program.
    3. To run the bytecodes of a Java program you need a Java Runtime
    4. Java: A simple, object-oriented, network-savvy, interpreted, robust, secure, architect neutral, portable, high-performance, multithreaded, dynamic language.
    5. Java Class Libraries: The collection of preexisting Java code that provides solutions to common programming problems (lang, io, math, ...)
    6. Programming in Java:
      1. Type in a program as a Java class.
      2. Compile the program.
      3. Run the compiled version of the program.
    7. Hello World:
                          
                  public class HelloWorld {
      
                      public static void main(String[] args) {
      
                          System.out.println("Hello world!");
      
                      }
      
                  }
                          
                      
    8. Edit, Compile, Run:
    9. Classes, Methods, Statements:
    10. So, to review, every Java program:
  5. Programming in the Lab and on your own Computer