I love the idea, but why in the name of the Flying Spaghetti Monster, would you use Java on an RPi? There are at least half a dozen python libs for the PMS7003.
Many people don't realize but for a garbage collected language it can be quite efficient in terms of memory used. I have a long running web server that's forced to not exceed 50 MB of heap, having an up time of one year, which means no leaks.
And the great part of Java processes is that they can be fat and handle multiple things at the same time, so you only need one Java process for anything you'd like to do.
It's actually hard to achieve such stats with other garbage collected languages, including Python which in my experience is a memory hog and does reference counting AFAIK, along with relying on shitty C libraries, Python processes being leaky.
The other advantage that Java has, over compiled languages like Rust or Haskell is that you can compile your JAR on your workstation and then distribute just that.
This is less of a concern with interpreters like Python, however anybody that tried compiling stuff with something like Haskell for RPi knows how challenging that can be. And even for Python you often end up depending on native libraries that need to be compiled from source.
I mean, every Python beginner hates PostgreSQL just because of how hard it can be to install psycopg2 via pip/easy_install.
In my experience Java's ease of deployment is better than anything else. You just copy a JAR and that's it.
Python is great for prototyping, but my grand plan with this project is to add more sensors, integrate with some "smart home" devices and create a web UI - and I'm more comfortable coding all that in Java.
> My Android device that runs slower after each "update"?
This is not only an Android problem, Apple is equally guilty of this. Arguably, more so.
Nor is it a Java problem. Some extremely speed-sensitive high perfomance code used by high speed trading algorithms use Java. This is in an environment where micro-seconds count.
When microseconds/frame rates/audio buffers count, you're only one garbage collection away from a complete thread lockup. Those gigabytes of heap aren't going to clean up themselves!
there’s no reason not to use java. the pi is powerful and runs a full linux os. generally in device programming the language breakdown is C or Everything Else
I can just confirm what others are saying here - Java is great for the development of robust and reliable software. If you need even lower memory usage, you can compile the Java app with a GraalVM to a native image.
Currently running 4 JVM based solutions on 2 RPi's in our home. One is a fairly heavy one (OpenHAB 2), consuming 700 MB of memory. The others are simple importers (written in Scala), using around 50 MB each. It runs fast, is extremely stable (> 200 days uptime), very fast response times (< 100 ms), has a built-in dependency manager and is type-safe.
With this setup, I have aggregated more than 4 years of in-home data, ranging from radio-thermostats, 15 thermometers, continuous electricity usage, around 10 z-wave devices, 15 zigbee sensors, Philips Hue Lighting (8 bulbs, 8 switches), local weather updates, InfluxDB storage and a fairly complicated setup for climate control (including presence detection using OwnTracks / WiFi and operation of roller-shutters and sunscreens).
How is it bizarre? Java and Python are both pretty standard for devices like this since they don't require recompilation for ARM. And Java is more performant than Python in general.
Many people don't realize but for a garbage collected language it can be quite efficient in terms of memory used. I have a long running web server that's forced to not exceed 50 MB of heap, having an up time of one year, which means no leaks.
And the great part of Java processes is that they can be fat and handle multiple things at the same time, so you only need one Java process for anything you'd like to do.
It's actually hard to achieve such stats with other garbage collected languages, including Python which in my experience is a memory hog and does reference counting AFAIK, along with relying on shitty C libraries, Python processes being leaky.
The other advantage that Java has, over compiled languages like Rust or Haskell is that you can compile your JAR on your workstation and then distribute just that.
This is less of a concern with interpreters like Python, however anybody that tried compiling stuff with something like Haskell for RPi knows how challenging that can be. And even for Python you often end up depending on native libraries that need to be compiled from source.
I mean, every Python beginner hates PostgreSQL just because of how hard it can be to install psycopg2 via pip/easy_install.
In my experience Java's ease of deployment is better than anything else. You just copy a JAR and that's it.