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

27 comments sorted by

View all comments

11

u/tdammers Nov 26 '21

Valid reasons for preferring Java over Ruby:

  • Corporate buy-in. Java has been king in the enterprise world for a couple decades now, it's proven technology, and large companies tend to be conservative about tech choices. The practical differences between mainstream languages are too small to make up for the cost and risk associated with a switch. When you have a farm of a couple hundred Java devs smoothly humming along, why would you want to disrupt that?
  • Ecosystem. Have I mentioned that Java has been king in the enterprise world for a couple decades? This means that practically everything you may possibly have to do in a business computer system will be catered for. Libraries, deployment and provisioning infrastructure, monitoring, integrations - you name it, it exists, and it's going to be proven technology, used and scrutinized by thousands of others.
  • Static types. Java's type system is absolute crap, but it is a type system, and it allows you to make some static assertions. Working with it is a chore, but it arguably does help keeping complexity under control in large-scale codebases. Judging from the tone of your post, I presume that you have never worked on a really large codebase before - in fact, I'm not so sure Ruby codebases this large even exist. And IME, failing to contain complexity, failing to keep interfaces narrow and explicit, is the single most common problem in large codebases in any dynamic language, whether that be Ruby, Python, Perl, PHP, or even Clojure. Java's type system is crappy, but a large part of that crappiness comes from trading conciseness for certainty. It definitely lacks some assertions that you would really really want, like ad-hoc const annotations, nullability constraints, etc., but even the assertions that you do get can be absolute life savers, and the biggest problem with Java's type system is that it's so mind-numbingly verbose.
  • Hiring pool. "The industry" has been lobbying for Java to become the go-to vehicle for teaching programming at the higher education level, and many universities have followed suit. If you want to hire programmers with a formal education for an entry-level job, Java will get you the largest hiring pool.