This is a comparison between Java, Go, and Rust. Not in the sense of a benchmark, but more of a comparison between the output executable file size, memory usage, CPU usage, run-time requirements, and of course a small benchmark to get some requests per second figures, and to try to make some sense of the numbers.
In an effort to try to compare apples to apples (maybe?), I have written a web service in each of the languages in this comparison. The web service is very simple, it serves three REST endpoints.
The repository for the three web services is hosted on github.
Artifact Size
Some information about how the binaries were built. In the case of Java, I have built everything into one big fat jar using the maven-shade-plugin and used the mvn package
target. In the case of Go, I used go build
. And finally, for Rust I used cargo build --release
.
The artifact compiled size also depends on the chosen libraries/dependencies, so if they are bloated your compiled program will end up the same. In my specific case, for the libraries I have chosen, the above is the programs compiled size.
In a separate section, I will build and package all the three programs as docker images and will list their sizes as well to show the runtime overhead needed for each of these languages. More details below.
Memory Usage
Idle, doing nothing
What? Where are the bars for Go and Rust versions that show the memory footprint while running idle? Well, they are there, only that Java consumes an upward of 160 MB when the JVM starts the program and sitting idle, doing nothing. In the case of Go, the program uses 0.86 MB, and 0.36 MB in the case of Rust. This is a…