Skip to content

Week 1 - Introduction to Programming

Introduction to Java

What is Programming

  • Set of instructions organized into an steps to solve a problem (Algorithm)
    • Computation, text manipulation, searching, graphics
  • Every language
    • Input, output, math, decisions (conditional), repetition (while, for, do…while loops)

What is Computer Science

  • Study of and discovery of algorithms (or creating the steps to solve a problem)
    • Reduce computational expense
    • Novel ways to solve a problem
  • Program (Algorithm) errors are called Bugs

Programming Languages

  • Low Level Language: machine code like the RISC vs CISC assembly language battle
    • RISC = 1 instruction / cycle VERSUS CISC = Many Instructions / several cycles
    • Complex Instruction Set Computer
      • CISC 80x86 is what Intel uses
    • Reduced Instruction Set Computer
      • RISC is what many ARM processors use
  • High Level Languages
    • Easier to understand, formatting human readable
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      ; ----------------------------------------------------------------------------------------
      ; Writes "Hello, World" to the console using only system calls. Runs on 64-bit Linux only.
      ; To assemble and run:
      ;
      ;     nasm -felf64 hello.asm && ld hello.o && ./a.out
      ; ----------------------------------------------------------------------------------------
      
                global    _start
      
                section   .text
      _start:   mov       rax, 1                  ; system call for write
                mov       rdi, 1                  ; file handle 1 is stdout
                mov       rsi, message            ; address of string to output
                mov       rdx, 13                 ; number of bytes
                syscall                           ; invoke operating system to do the write
                mov       rax, 60                 ; system call for exit
                xor       rdi, rdi                ; exit code 0
                syscall                           ; invoke operating system to exit
      
                section   .data
      message:  db        "Hello, World", 10      ; note the newline at the end
      
      VERSUS
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      /**
      Writes "Hello, World" to the console.
      
      javac HelloWorld.java  # compiled to byte-code.
      java HelloWorld        # Looks for and executes main.
      */
      
      class HelloWorld {
          public static void main(String[] args) {
              System.out.println("Hello, World!"); 
          }
      }
      
    • Less cumbersome to debug
    • Portable
  • Types of High Level Languages
  • Note on Compiling - In layman’s speak, a program that converts a program in one programming language into another program in another programming language.
  • Compiled to machine code AOT (Ahead of Time): C, C++
    • Must be compiled to the target architecture (80x86, ARMv8, etc.)
  • Compile to byte-code, then Interpreted JIT (Just in Time): Java
    • Portable to any system with bytcode interpreter (JVM)
  • Interpreted: Scripting Languages
    • Extremely Portable
    • Slower due to fewer runtime optimizations and fully just in time compiling

Description of HelloWorld

  • class: template used to create objects
    • Defines object data types.
    • Contains methods to get/set/modify the object.
  • class == category
  • object == item in that category
  • static: A static method belongs to the class rather than instances. This also goes for static variables.
  • void: It Returns NOTHING - We believe in nothing, Lebowski. Nothing. == VOID
  • public: Modifier that makes the method (variable, etc.) accessible OUTSIDE the class

A Bit About Git

Git Flow * Will demo full git turn in process at the end of class.

Learning!

  • Learn by doing - code, code, code, all day long
  • Learn tools that are relevant - IntelliJ, Git
  • Learn Languages where the jobs are - Python, Java, Web-Technologies (React, Next.js, Vue.js, GraphQL)
  • Ask for help! Be agile, Pair Program, run a personal (OR TEAM) scrum.
    • Questions to ask in Team/Personal scrum every day:
      • What did you do yesterday?
      • What will you do today?
      • What’s getting in your way?
      • Something fun I learned!