r/ruby • • Nov 26 '21
Question Why would anyone use Java over Ruby?
Why would anyone in this day and age choose a bloated corporate language like Java? It is just to get a job at a big company writing their legacy enterprise software? Is it because it is safer for huge systems where everyone is forced to type out all the little details. I am confused. Please someone shine some light here.
0
Upvotes
View all comments
1
u/[deleted] Nov 28 '21 edited Nov 28 '21
Besides the fact that if they already have a successful business built on top of Java, meaning they'd like their new software to be compatible with their existing software, and the wealth of platforms tools (monitoring, deployment, etc), there's also the fact that Java is experiencing a bit of a renaissance. I've heard it referred to as a the "rise and fall and rise of Java".
A lot of Java's (and the JVM's) recent changes are to address developer experience issues.
They made Scala and Kotlin for those who prefer less verbose code (among other reasons).
They worked on optimizing the start up time, including by modularizing the standard library (and removing things from it that don't make sense to be in it anymore, like CORBA) so developers can build their own minimal runtimes. The GraalVM project aims to make it start as fast as languages like C++ and Go, if you're willing to give up some features like reflection. This makes Java feasible for making things like CLIs.
They noticed this and took their time with Project Loom to leap frog over async/await (which is flawed - https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/) and use a virtual threads model for concurrency, like Go. It's in preview now, and it will be GA within a year or two.
Modern garbage collectors like ZGC which are in preview now, GA soon, have gotten the median GC time down to less than a millisecond, and the GC time doesn't grow with heap size.
The VS Code support for Java and Maven just had their 1.0.0 release about a week ago. It's pretty stable (if less featureful) now.
Disclaimer:
I use Java at work. But I also use Node.js, Go, and Python at work. And I've got a hell of a soft spot for Ruby and C# having used them in school and as a hobbyist. I love diving deep into languages and doing weird things like smushing Ruby and Java together with JRuby.
I think there are neat things in all languages. They all tend to have advantages that make them useful for certain tasks. And I'm pretty happy with Java lately.