I’ve once made a simple helper class for a set of bytes stored as an integer bitfield. So the idea is that each of the 32bits is used to represent if the ordinal number is in the set or not. This only works for the bytes 0 to 31. Now this is an “inline class” – something we will get with Project Valhalla. Here’s the branch of my project: https://github.com/claudemartin/smallset/tree/valhalla
Just download that JDK, clone my branch, build using Ant, and see what you can do with it. It’s actually a good example of an inline class, because it is just an integer (primitive) value but has methods (like a referenced type would). It doesn’t need object identity, but should still behave like an object. For example the sets are comparable. The type actually implements the Comparable interface.
Note that this might not work with newer JDKs. I used JDK 14 + valhalla from java.net and the feature might look quite different in newer releases of Java.
I just saw that I never posted this here on my blog. JDBC is still a good way to just connect to some SQL database where JPA would be overkill. So I wrote a library that allows you to use the Java Stream API to process that data.
What is this supposed to mean? Evaluation from right to left would mean that when you have a line like the following you get the rightmost expression evaluated first:
int x = 42;
x += getNumber();
// The above would be equivalent to:
x = getNumber() + x;
But that’s not how Java actually evaluates this expression. And the JLS 12 (2019-02-08) clearly states in 15.26.2 that “the value of the left-hand operand is saved and then the right-hand operand is evaluated.”
With Windows Subsystem for Linux (WSL) we can now use Linux tools, such as grep, rsync, ssh, and network commands, such as dig and netstat, on Windows directly. No need for cygwin or other 3rd party software.
Here’s an example on how uname is unknown to Windows, but WSL (Ubuntu in my case) knows it:
Java isn’t easy. It’s often more complex than needed. But being easy for beginners shouldn’t be a design goal with high priority.
Should a programming language be easy?
I don’t know why so many educational establishments use Java to teach programming. They often start with Java in the first semester. Even the Oracle tutorials expect the reader to already know some basics. Java was designed for programmers who already know C/C++ as seen in this example.
Was 1900 a leap year and does every minute have 60 seconds?
In Java we have a new API for Date and Time since Java SE 8. Before that, there was already an API with mutable dates and fore some reason there was a date just for SQL. Since many were not happy with it there was Joda-Time, which later became the basis for JSR-310 and is now found in the package “java.time”.