Skip to main content

CS 3100: Program Design Paradigms

Lecture 1: Course Overview & Introduction to Java

©2025 Jonathan Bell, CC-BY-SA

Introduction

  • Jon, Prof Bell, Prof Jon, Dr Bell, Dr Jon, etc…
  • Research: Software Engineering, Program Analysis
  • Open source contributor & project founder

Meet the TAs

[TA introductions]

Learning Objectives

  1. Understand the structure of this course and what will be expected of you
  2. Review the Systematic Program Design and Implementation Process
  3. Describe the context of Java in the historical development of OO languages and JIT runtimes
  4. Compare the Java runtime environment to Python
  5. Recognize Java syntax
  6. Understand the difference between core datatypes in Java: primitives, objects and arrays

Let's Start with a Story...

The 1950s

Computers exist, but programming them is... tedious.

Glen Beck and Betty Snyder programming the ENIAC

Glen Beck and Betty Snyder program the ENIAC (Public Domain)

1952: "Automatic Programming"

Grace Hopper

Grace Hopper develops the first compiler (A-0)

Her radical idea: let the machine translate human-readable code into machine code

The skeptics: "Machines can't write programs."

Photo: Lynn Gilbert, CC BY-SA 4.0

Sound Familiar?

"AI can't really write code..."

Every generation redefines what "automatic programming" means

Assembly → COBOL → C → Python → ???

1960s: Margaret Hamilton

Led Apollo flight control software — popularly attributed with origin of the term "software engineering"

"I fought to bring the software legitimacy so that it—and those building it—would be given its due respect."

Her "radical" approach: rigorous testing, error handling, treating software like hardware

Margaret Hamilton with Apollo guidance software

Margaret Hamilton with Apollo guidance software printouts (Public Domain)

The Software Crisis (late 1960s)

Despite innovations in programming:

  • Software was very inefficient
  • Software was of low quality
  • Software often did not meet requirements
  • Projects were unmanageable
  • Software was, sometimes, never delivered

Something had to change

1968: NATO Software Engineering Conference

Garmisch, Germany — 50 experts from 11 countries

The term "software engineering" was deliberately provocative:

Software should be built with the same rigor as bridges and buildings

A formal call to action: we must study how to build software

The Key Outcome

There could be systematic techniques for writing software

Just as civil engineering has methods for building bridges...

...software engineering could have methods for building programs.

The rest is history: new processes, tools, languages, and paradigms emerged over the following decades — and continue to emerge today.

Did the software crisis end?

Edsger Dijkstra

"The major cause of the software crisis is that the machines have become several orders of magnitude more powerful! To put it quite bluntly: as long as there were no machines, programming was no problem at all; when we had a few weak computers, programming became a mild problem, and now we have gigantic computers, programming has become an equally gigantic problem."

Photo: Hamilton Richards, CC BY-SA 3.0 · Quote: Dijkstra's 1972 Turing Award lecture

Moore's Law: 1972 → Today

Gordon Moore (1965): Transistor count doubles every ~2 years

From 1972 to 2025 = 53 years ≈ 26 doublings

2262^{26}67,000,000× more powerful

Dijkstra's "gigantic" is now incomprehensibly gigantic

This Course.

50+ years of research, practice, and hard-won lessons

How do we design, build, and maintain software that is sustainable at scale? (considering: technical, economic, environmental, social factors)

Using Java to explore ideas that transcend any single language

The Systematic Program Design Process

The goal: help you better understand how to design and implement programs

Inspired by classical software engineering processes

The Process

Software Design Process

Requirements → Design → Implementation → Validation → Operations

Principles-Based, Not Syntax-Based

  • We focus on the big picture and why things are the way they are
  • Not just the syntax of the language
  • Flashcards + resources provided for syntax—use them!
  • We move quickly past syntax in lecture

What About AI?

The hardest parts of building software have never been typing code.

It's: understanding what to build, making tradeoffs, reviewing code, coordinating with humans

Early: AI restricted — you can't review code you couldn't write yourself

Mid-course: AI introduced with structured workflows for human-AI collaboration

We're all still learning what it means to program effectively with AI — let's figure it out together

Course Logistics

Deliverables: Assignments → final project • Quizzes • Exams • Labs • Participation

Participation (required for an A):

  1. Attendance + in-class polls
  2. Pre-lecture activities (flashcards)

Expectations: Do readings before lecture • Bi-weekly assignments ~20 hours

Do not wait until the last minute!

The 1990s: New Pain Points

  • Platform fragmentation (Windows, Mac, Unix)
  • The Internet
  • 32,000× increase in complexity

C/C++ dominated, but:

  • Manual memory management → crashes
  • Platform-specific code everywhere
  • "It works on my machine" 🤷

Java & Python responded with:

  • Garbage collection
  • Platform abstraction
  • Large standard libraries
  • Object-oriented design

Java vs Python: Same Problems, Different Philosophies

Java (1995)Python (1991)
OriginSun Microsystems (corporate)CWI research (community)
TypesStatic — errors at compile timeDynamic — errors at runtime
SpeedFast (JIT compilation)Slower (interpreted)
StyleVerbose, explicitConcise, "readability counts"

Discussion: If Java is faster, why use Python?

Where Are They Now?

Java
  • Android
  • Enterprise
  • Big Data
Python
  • ML/AI
  • Data Science
  • Scripting

Plot twist: Industry trending toward static typing

  • PHP → Hack
  • JavaScript → TypeScript
  • Python → mypy

How Does Java Deliver on Its Promise?

"Write Once, Run Anywhere"

...with performance

The Challenge

  • CPUs have different instruction sets
  • OS's have different APIs
  • How do you run a program on any machine?

The Bytecode Solution

Both Python and Java compile to bytecode

(an intermediate representation executed by an interpreter)

Sidebar: Is it really that easy? Ever compiled native Python extensions?

Interpreted vs Compiled

InterpretedNative Compiled
Reads & executes line by lineAlready in machine code
100s of instructions per statementDirect CPU execution
SlowerFaster

Compiler Optimizations

A compiler can:

  • Identify branches never taken → remove them
  • Inline small functions
  • Optimize memory access patterns

An interpreter executes every line, every time

Java's Innovation: JIT Compilation

Just-In-Time (JIT) compilation

Dynamically compiles bytecode as it executes

The program that runs Java code: JVM (Java Virtual Machine)

Why Not JIT for Python?

PyPy and others have tried...

Fundamental language design differences
make it hard to match Java's performance

(Dynamic typing makes optimization very hard)

Tool Mapping: Python → Java

PythonJava
pipgradle
pytestjunit
VSCodeIntelliJ IDEA | VSCode

Key Difference: Compilation

Python

Source → Interpreter

Java

Source → Bytecode → JVM

Java requires an explicit compile step

Discussion

Did anyone have Python experience before CS 2100?

(without mypy)

How did you find errors in your code?

Java Syntax: A Brief Tour

We won't teach syntax explicitly in lectures

But for this first lecture...a quick introduction

Hello, World!

package io.github.neu_pdi.cs3100.lecture2;

import io.github.neu_pdi.cs3100.utils.OtherClass;

/**
* This is a simple program that prints "Hello, World" 10 times.
*/
public class HelloWorld {
  public static void main(String[] args) {
      OtherClass other = new OtherClass(10);
      for (int i = 0; i < 10; i++) {
          // Print a message to the console
          System.out.println("Hello, World #" + i);
      }
      other.doSomething();
  }
}

Package Declaration

package io.github.neu_pdi.cs3100.lecture2;
  • Similar to Python modules
  • Convention: reverse domain name
  • Example: GitHub user octocatio.github.octocat

Import Declaration

import io.github.neu_pdi.cs3100.utils.OtherClass;
  • Imports classes from other packages
  • java.lang.* imported by default
  • → No need to import String, System, etc.

Comments

// Single line comment

/* Multi-line
 comment */

/**
* Documentation comment (Javadoc)
* Used to generate documentation
*/

Class Declaration

public class HelloWorld {
  // contents here
}
  • All code must be in a class
  • public → usable by other classes
  • { } delimit scope (not indentation!)

Method Declaration

public static void main(String[] args) {
  // method body
}
public→ accessible by other classes
static→ class method (no instance needed)
void→ returns nothing
main→ JVM entry point

Dissecting a Statement

System.out.println("Hello, World #" + i);
  • System → class in java.lang
  • out → static field of type PrintStream
  • println → method that prints + newline
  • + → string concatenation
  • ;required! (not Python)

A Supporting Class

public class OtherClass {
  private int x;
  
  public OtherClass(int x) {
      this.x = x;
  }
  
  public void doSomething() {
      System.out.println("Doing something with x = " + x);
  }
  
  public int getX() {
      return x;
  }
}

Key Syntax Points

  • private int x → field only accessible within class
  • Constructor has same name as class
  • this.x → refers to the field (not parameter)
  • Can have multiple constructors (unlike Python)
  • getX() → getter method (encapsulation)

Java Data Types

Two categories:

  1. Primitive types (values)
  2. Reference types (pointers to objects)

Primitive Types

TypeSizeValues
byte1 byte-128 to 127
short2 bytes±32,767
char2 bytesUnicode character
int4 bytes±2 billion
long8 bytes±9 quintillion
float4 bytes~7 decimal digits
double8 bytes~15 decimal digits
boolean1 bytetrue / false

⚠️ Big Change from Python

Integers have fixed sizes!

Python integers can be arbitrarily large

Java integers overflow at their limits

Quick Math: Memory Sizes

1 byte = 8 bits → 282^8 = 256 values

4 bytes = 32 bits → 2322^{32}10910^9 (billions)

8 bytes = 64 bits → 2642^{64}101810^{18} (quintillions)

Trick: 2102^{10}10310^3 (1,024 ≈ 1,000)

Why Does Size Matter?

Storing age (in years) for 8 billion people:

  • byte (1 byte) → 8 GB
  • long (8 bytes) → 64 GB

Memory was expensive in the 1990s!
Today: matters for big data (numpy, pandas are C extensions)

Reference Types

  • Objects (anything extending Object)
  • Arrays (e.g., int[], String[])
  • Can be null (no object)

Variables store a pointer to memory

Reference Equality Warning

String a = new String("hello");
String b = new String("hello");
System.out.println(a == b);  // false!

== compares references (memory addresses)

Not values like in Python

Use .equals() for value comparison

Arrays vs Python Lists

Java ArrayPython List
Fixed sizeDynamic size
Single typeMixed types
Contiguous memoryPointers to objects

Summary

  • Course: principles-based, large-scale design
  • Java: "write once, run anywhere" with JIT performance
  • Static typing is winning the industry debate
  • Primitives vs references: understand the difference!

Next Steps

Questions?