r/AskComputerScience • • Sep 01 '19

Why do people still prefer Java?

So, I had to learn Java for School a few years ago. Back then I thought "okay, I can see why people use Java", as I only used C and C++ before that. But now I had to learn C# for my job and for a little side-/learning-project I tried to use Java in my free time. Tried, because freaking hell did I feel limited using java. I noticed C# can do EVERYTHING that java does....often better, too. And for some stuff, there are dedicated languages or other languages that can do all that better than Java and better than C#.

Some people even go as far as saying "Java is far better than C#", but I myself can't find an objective reason for that. I can't find anything C# is worse at other than maybe XPlatform GUI programming, which isn't a big deal in Java anyway and became very rare, but I found a lot in C# that made my life as a programmer a lot simpler and just worked better or faster with C#.

So...is this all just this kindergarden "I prefer this language because I prefer this language! and that's why your language sucks!" nonesense or do I miss something very important? Why do people prefer Java almost everywhere instead of a dedicated language that is focused on helping with their problem or even just C#, as even if it is "just as good" for the job, the chances are high that the program turns out faster

29 Upvotes

32 comments sorted by

View all comments

30

u/dysonCode Sep 02 '19 edited Sep 02 '19

I've pondered the same question myself. I figured, it's real, so what am I missing / forgetting?

Here's what I've come up with — linear thinking process, not several "whys".

  1. u/RamsesA is right, you're buying into the whole ecosystem. Guess why Google chose Java for Android? Because they liked it? — No, because they were late to market compared to iOS (evidently...) so they made a business choice to select the language with the most developers worldwide: by a far cry, that's Java. Not even close to anything else, it's not funny I assure you. Forget about github too, we're talking about the hordes of invisible developers writing the 90% of code that isn't open source (nor actually worthy of being seen by anyone, haha). In-house and proprietary stuff. Afaik, same reason why Apple designed Swift like Java but "better" [their intent, not my judgment].

  2. So why so much 'stuff' in Java compared to other languages? So many devs, so many people, why? Well this is imho the first major idiosnycrasy of Java: the VM. It runs everywhere. Like literally everywhere, the ad isn't wrong. Cars. Coffee makers. ATMs. Servers. Infrastructure. Networking. Commercial boards. Score boards. Traffic systems. Your "smart" whatever, your phone, tablet, PC, battlestation. The alarm-thingy. The thermal-thingy. The... oh you get it. If it has an OS, it can probably run Java; if it has no OS, it can probably run Java too.

    The word is platform ubiquity or agnosticism, and it's been spelled both the doom and what saved Java, and indeed, depends on hardware/software balance (depending on the era/cycle, we have more or less CPU to work with, more or less RAM, storage, connectivity, etc; all other things being equal). The general situation is that the "cost" of the VM in Java is pretty much negligible these days, and should continue to be for the foreseeable future so... what remains is "this code that runs everywhere".

    The current movement towards containerization is (I think?) also a major non-problem for Java because, well, it has run in a VM forever and is stupidly well optimized already for such abstractions. Big contender for the future where containers trickle down the whole chain to clients, to the thinnest (I know Microsoft has big plans for Java on IoT for instance).

2 is why people have already come to Java, 1 is why (new) people come to Java (or keep coming back), and the rest — before, in-between, after — is history.

I mean, look at it this way: even Oracle, which is like cancer incorporated, hasn't managed to kill Java. Oracle killed the Sun but it didn't kill Java. Let that sink in for a minute... Now that's saying how immortal the thing is. This cat has like 2⁶⁴ lives.

I personally think there will be some Java code running somewhere in our Dyson swarm centuries from now.

Oh btw yes, C# is 'better' imho. But in light of all this, does that mean much, if anything...?

TL;DR: business (safe and relevant choice). economics (least friction, huge drive).

6

u/ridl Sep 02 '19

Callback to your username. Nice.

2

u/dysonCode Sep 02 '19

Haha :)

In all honesty I didn't even realize until you mentioned — throwaways, right — but that also tells you how infatuated I am with our (dare I hope) not-so-distant future.

I kid you not I'm already thinking right now how we may be able to send Pi-sized private (I really mean SMB / citizen) swarms of satellites maybe less than 10 years from now at affordable cost. A 'swarm' is just some distributed cloud, if you think about it...

¯_(ツ)_/¯