An open API service indexing awesome lists of open source software.

https://github.com/zipcodecore/codeinterpreters

simple java exercises using jshell
https://github.com/zipcodecore/codeinterpreters

Last synced: 4 months ago
JSON representation

simple java exercises using jshell

Awesome Lists containing this project

README

          

# Code Interpreters: Understanding How Programming Languages Run

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.

## What is Code Interpretation vs Compilation?

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:

### Compiled Languages (Traditional Java)
**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
```

### Interpreted Languages (Python)
**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)
```

## The Best of Both Worlds: JShell

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.

## Why This Matters for Beginners

### Learning with Interpreters (Python & JShell)
- **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

### Learning with Compilers (Traditional Java)
- **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

## What's in This Repository

This repository contains parallel tutorials for both languages:

### Java Directory (`/java/`)
- **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

### Python Directory (`/python/`)
- **README.md**: Getting started with Python interpreter
- **PythonSmall.md**: Interactive Python programming
- **VARS.md**: Understanding Python variables
- **ClassPerson.md**: Creating Python classes

## Learning Path

1. **Start with either language** - both directories teach the same concepts
2. **Use the interpreters** - jshell for Java, python3 for Python
3. **Type, don't copy-paste** - build muscle memory and understanding
4. **Experiment beyond the examples** - interpreters make this safe and fun

## Key Takeaways

- **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

## The Big Picture

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!