Welcome to your introduction to programming with Java and Python! This repository contains beginner-friendly tutorials for both languages, focusing on how code gets executed on your computer.
When you write code, your computer doesn't understand it directly. Programming languages need to be translated into machine language (1s and 0s) that your computer can execute. There are two main ways this happens:
Compilation is like translating an entire book before anyone can read it:
- You write your Java code in a
.java
file - A compiler (like
javac
) translates your entire program into bytecode - The Java Virtual Machine (JVM) then runs this compiled bytecode
- If there are errors anywhere in your code, the compiler catches them before anything runs
- You must fix all errors before your program can run
Example workflow:
Write code → Compile (javac) → Run (java) → See results
↓ ↓ ↓
hello.java → hello.class → Output
Interpretation is like having a live translator who translates as you speak:
- You write Python code and run it immediately
- The interpreter reads your code line by line and executes it instantly
- Errors are found and reported as the program runs, not before
- You can test small pieces of code quickly without compiling
Example workflow:
Write code → Run directly → See results immediately
↓ ↓
hello.py → Output (no compilation step)
Traditionally, Java required you to write a complete program, compile it, and then run it. This made experimenting with small code snippets difficult for beginners.
JShell (introduced in Java 9) changed this by adding an interpreter to Java:
- Type Java code and see results immediately
- Test methods, variables, and expressions interactively
- No need to write a complete class structure for simple experiments
- Perfect for learning and prototyping
Think of jshell as giving Java programmers the same "try it now" experience that Python programmers have always had.
- Immediate feedback: See results instantly
- Experiment freely: Try code snippets without writing full programs
- Learn incrementally: Build understanding one concept at a time
- Quick debugging: Test small pieces to understand what went wrong
- Catch errors early: The compiler finds many mistakes before running
- Understand program structure: Learn how complete programs are organized
- Build discipline: Write more complete, thoughtful code
- Performance benefits: Compiled code typically runs faster
This repository contains parallel tutorials for both languages:
- README.md: Getting started with Java and jshell
- JavaSmall.md: Interactive Java programming with jshell
- VARS.md: Understanding Java variables using jshell
- ClassPerson.md: Creating Java classes interactively
- README.md: Getting started with Python interpreter
- PythonSmall.md: Interactive Python programming
- VARS.md: Understanding Python variables
- ClassPerson.md: Creating Python classes
- Start with either language - both directories teach the same concepts
- Use the interpreters - jshell for Java, python3 for Python
- Type, don't copy-paste - build muscle memory and understanding
- Experiment beyond the examples - interpreters make this safe and fun
- Interpreters let you run code immediately, line by line
- Compilers translate entire programs before running
- JShell brings interpreter-style learning to Java
- Python has always been interpreted, making it beginner-friendly
- Both approaches have their place in programming
Understanding how your code runs helps you become a better programmer. Interpreters are great for learning and quick experiments. Compilers help you build robust, efficient programs. Modern development often uses both approaches - interpreters for testing ideas, compilers for building final applications.
Ready to start? Pick either /java/
or /python/
and begin your programming journey!