Notebooks are a community standard for communicating and performing interactive computing. They are a document that blends computations, outputs, explanatory text, mathematics, images, and rich media representations of objects.
It allows you to interleave blocks of text (in Markdown), editable and executable Java code blocks and output blocks.
> Hello world!
As you can see, when we run the code block above, the output is immediately updated. It is similar to JShell, but in the browser.
Notebooks are an ideal tool to teach programming languages and to display and explore libraries and frameworks. Notebooks also support the import of external libraries using Apache Maven. Here is an example using the
load command to import Apache Commons.
> !dlrow olleH
Data processing with jandas
It is also possible to directly import resources from internet and parse them to Java objects and records using frameworks like
jandas (loosely based on pandas).
Here is an interactive example:
> Lady Gaga currently has 6 top 1000 hits. > Ed Sheeran has 26513653 total streams. > Bohemian Rhapsody was released: Fri Oct 31 00:00:00 CET 1975
Hosting your own Notebooks
It is very easy to host your own notebooks. Users can run notebooks locally (using Docker) or use one of the following free cloud services to run your Java Notebook:
If you build or maintain a framework or library, or if you have a website explaining Java programming: Please add these interactive notebooks to your website. This makes it incredibly easy for new developers to get acquainted with your code.
Sadly (as you might have noticed) the examples above do not work. It was all just a dream. There is no such thing as a (widely used) Java Notebook.
The reason I wrote this post is the famous TIOBE Index of programming languages.
Today is the first day since 2001 that Java isn’t in the top 3.
That is why we, as the Java community, should look at our competition. What did Python do right? Why is it topping the chart?
A major reason, I think, is the feedback and steep learning curve of Java. If you want to parse some data, would you rather download a Java Runtime, install an IDE, install Maven etc? Or would you rather open the browser, have documentation and tutorials inlined with running examples? This is SO much easier.
My wish for 2023: Oracle, Microsoft, Google, Azul… PLEASE make this a reality.
They do exist…
Almost forgot: There are some online Java Notebooks that provide much of the functionality given above, here are some options you can consider:
- Apache Zeppelin (a Jupyter-like runtime that has Java bindings)
- IJava (a Jupyter kernel for executing Java code)
- And more, mostly single developer hacked/weekend projects
The main problem I have isn’t that these project don’t exist; we just don’t utilize them, at all. There is no widespread support for this. It would be such a powermove if Oracle launched a similar product and encouraged libraries to embed it (running on their cloud for example).
If you want to get into AI/deep learning for example, here are two examples, Java or Python, I know which I’d pick:
Java: Quickstart DeepLearning4J:
Twenty steps of installing Java, Maven, git, IntelliJ, check out a project…
Python: Tensorflow Quickstart for Beginners:
No setup at all; from the start you’re importing Tensorflow and running the examples.
It isn’t all bad, here is an example where it does work:
Easy to overlook, but press the top button “Run this notebook online”. Using IJava and Jupyter, yay!
Perfect for: https:://dev.java
I’d love for dev.java to become more engaging or interactive, something like a notebook. Have a place online where you can “Try now” without having to install everything.
Currently the Getting Started goes as follows:
- Open a plain text file, write your first class, without code formatting etc.
- Now you could compile it and run TADAA!
- But wait, you need to install a JDK first
- Download JDK
- Install JDK
- Learn to use the compiler
- Now run it.
Nobody got time for that anymore, sure, perhaps after you’ve decided to really go for it. But with notebooks you get instant results, you can tinker away, run stuff in the browser and see the results, perfect.
Anywaaaay, enough ranting for today ✌️