Make a JShell kernel
- Dominant language
- Jupyter Notebook
- Stars
- 2.9k
- Forks
- 383
- PR merge metrics
- No merged PRs in 30d
Description
Java9 is about ready to release its RC1, with the final version due out in about a month (July 2017):
http://openjdk.java.net/projects/jdk9/
It would be fairly easy to make a beakerx JShell-based kernel:
```java
import jdk.jshell.*;
public class JShellKernel {
JShell js;
JShellKernel() {
js = JShell.create();
}
public void eval(String code) {
js.eval(code);
// etc.
}
}
```
There are differences between a JShellKernel and the current beakerx JavaKernel (this is to the best of my knowledge, not being an expert in JShell nor Beakerx JavaKernel):
1. JShell can evaluate snippets and expressions (eg, "1 + 1"). See http://download.java.net/java/jdk9/docs/api/jdk.jshell-summary.html. JavaKernel requires each cell to be a complete set of Java statement(s).
2. JShell has optional semicolons; JavaKernel does not.
3. JShell doesn't support return as a snippet; JavaKernel does support return.
4. JShell allows variables to persist between evals; JavaKernel variables live only for the life of the cell.
5. JShell allows "forward reference": code may reference items not defined yet. This allows writing code that has co-dependencies. I don't think this type of code development is possible in JavaKernel.
From a pedagogical standpoint, none of these differences may be desired, and the JavaKernel may be prefered in the classroom. For example, if students learn that they don't need semicolons, then there is some cognitive overhead when transitioning to full Java.
On a related note, parts of Java9 JShell might be usable in the JavaKernel, if you switch to java9. For example, JShell also has functionality for code-completion.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.