Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dgroomes/jshell-playground
📚 Learning and exploring JShell—the official Java shell and read-eval-print loop (REPL)
https://github.com/dgroomes/jshell-playground
java jshell jshell-repl learning-by-doing
Last synced: about 2 months ago
JSON representation
📚 Learning and exploring JShell—the official Java shell and read-eval-print loop (REPL)
- Host: GitHub
- URL: https://github.com/dgroomes/jshell-playground
- Owner: dgroomes
- Created: 2020-09-08T04:32:28.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-08-03T18:49:23.000Z (6 months ago)
- Last Synced: 2024-08-03T19:36:25.803Z (6 months ago)
- Topics: java, jshell, jshell-repl, learning-by-doing
- Language: Java
- Homepage:
- Size: 2.1 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# jshell-playground
📚 Learning and exploring JShell—the official Java shell and read-eval-print loop (REPL).
## Overview
Java is infamously awkward to get up and running with for beginner programmers. `public static void main(String[] args)`... really?
And the `main` method must be wrapped in a class. And the compile and run steps must be in separate commands (until [JEP-330](https://openjdk.java.net/jeps/330) anyway).
Overall, a prototypical "hello world" program is just too hard compared to other languages.
🚀 JShell to the rescue!JShell removes all of those requirements and enables a beginner programmer to start learning and exploring Java
without all the fuss! This project is my attempt to learn about JShell and share my findings.## Quick start
Start with the [basic/](basic/) subproject.
## Learn about JShell
The JDK Enhancement Proposal that introduced JShell is the best place to learn the "what" and "why" about it: .
To learn the "how", see the [*Introduction to JShell* article](https://docs.oracle.com/en/java/javase/14/jshell/introduction-jshell.html#GUID-630F27C8-1195-4989-9F6B-2C51D46F52C8).
Some highlights from the JEP page include:
> Provide an interactive tool to evaluate declarations, statements, and expressions of the Java programming language, together with an API so that other applications can leverage this functionality.
> Out of scope are graphical interfaces and debugger support. The JShell API is intended to allow JShell functionality in IDEs and other tools, but the jshell tool is not intended to be an IDE.
> Immediate feedback is important when learning a programming language and its APIs. The number one reason schools cite for moving away from Java as a teaching language is that other languages have a "REPL" and have far lower bars to an initial "Hello, world!" program.
> Exploration of coding options is also important for developers prototyping code or investigating a new API. Interactive evaluation is vastly more efficient in this regard than edit/compile/execute and System.out.println.
## Standalone subprojects
This repository illustrates different concepts, patterns and examples via standalone subprojects. Each subproject is
completely independent of the others and do not depend on the root project. This _standalone subproject constraint_
forces the subprojects to be complete and maximizes the reader's chances of successfully running, understanding, and
re-using the code.The subprojects include:
### `basic/`
Start a `jshell` (the JShell command-line tool) session that's loaded with your own application source code. It is beginner-friendly!
See the README in [basic/](basic/).
### `with-libraries/`
This subproject is similar to `basic/` buts adds a few external Java libraries (including [Jackson](https://github.com/FasterXML/jackson)).
See the README in [with-libraries/](with-libraries/).
### `with-gradle/`
This subproject showcases an idiomatic Gradle-based Java project that is extended with a custom Gradle plugin that helps
you run a `jshell` session with the project's source code and library dependencies.See the README in [with-gradle/](with-gradle/).
### `api/`
Explore the JShell API by implementing a custom event loop.
See the README in [api/](api/).
## WishList
General clean-ups, TODOs and things I wish to implement for this project:
* [x] DONE Implement `basic/`
* [ ] SKIPPED (no, not possible) Can we execute `jshell` without compiling the program source code? Similar to the single-file source code support?
* [x] DONE Implement `with-gradle/`. It should be taken directly from .
* [x] DONE Can the `basic` and `with-libraries` subprojects be define as Gradle "included builds"? To be clerr, they are not
Gradle projects but to get the convenience of "Clone a repo and open it in the IDE" I want to technically define them
as Gradle projects using the root `build.gradle.kts` (does not exist yet). I'm not sure how to re-defined the path to the
"source sets" (i.e `src/` instead of the traditional Maven/Gradle `src/main/java/`).
* [x] DONE (well, not perfectly) Use the name "JShell" where appropriate instead of `jshell`