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

15

u/chipmandal Sep 02 '19

If you are not using Windows, C# development tools, libraries etc may be lacking.

I like the language, but haven’t gotten into it too much, since the community is focused on Windows.

-1

u/Lofter1 Sep 02 '19

Actually, that is only true for .Net framework (which will be dropped soon) and gui programming. .Net core isn‘t focused on anything

5

u/chipmandal Sep 02 '19

Well.. for example I tried to write a web server using .NET in Linux a couple of years ago ... I found few examples.. but didn’t get very far. I think I recently saw asp.net core examples. I’ll look at then again.

If you look at the Java (JVM) ecosystem, you’ll find a look out of popular frameworks which are well supported.

I am not saying Java is better, but then it’s not always a no-brainer to use C#, especially in the non-Microsoft world.

3

u/Lofter1 Sep 02 '19

Yeah, a few years ago, .net-core might not have been as big as it is now, or depending on when you tried, even non-existant, but nowadays it‘s huge and microsofts primary focus.

2

u/antonivs Sep 02 '19

Yeah, a few years ago, .net-core might not have been as big as it is now, or depending on when you tried, even non-existant,

You answered your own question here. It takes more than a few years to change industry perception and practices.

I worked on a C# project a few positions back, and we looked into building it for Linux. At the time it wasn't practical, and Microsoft's attitude to Linux then was that it was an evil that they had to tolerate because some customers liked it.

What you're essentially arguing in this thread is that the support for Linux has improved, and Microsoft's attitude to it has changed. That may be true, but it remains to be seen how exactly that will play out.

In the meantime, the Java ecosystem is huge. Companies like IBM and Amazon offer support for it, in addition to Oracle. From all sorts of business perspectives, Java has advantages over C#, largely due to the size of its community, the number and kind of companies heavily involved in its ecosystem, and the number of developers who are familiar with it.

As such, t's misleading to look at the core Java language and draw conclusions, because there's so much tooling built around it. Real world Java systems rely heavily on frameworks like Spring or Spring Boot. The language is also quite extensible in many ways. Don't like the boilerplate that Java tends to require? There are plenty of annotation libraries and other such tools to avoid that, and good IDEs have excellent support for addressing such issues.

The bottom line is that an experienced Java dev is not at a disadvantage compared to developers in other languages.

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...

¯_(ツ)_/¯

5

u/DiamondEevee Sep 02 '19

so what you're saying that an Oracle single-handedly destroyed a giant nuclear ball but it can't kill a simple morning beverage

4

u/myuusmeow Sep 02 '19

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

Probably COBOL in our interstellar banking and Fortran calculating our orbits too.

3

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

I'm having this overflow of data:

  • Is there any other way for banking? I, for one, have given up hope.

  • If code may be sacred then certainly COBOL is Kabbalah... just mainframe magic.

  • Did you know? "Cobola" is a tall, slow-growing evergreen tree. (read: there is more to come than we've seen yet!)

I think the signs are pretty clear. Mastery over money, magic, nature, in that order: COBOL is the language of the gods.

Joke aside the other day I was reading this article by a Red Hat engineer, it's about Golang but incidentally outlines how COBOL and FORTRAN basically opened the world of software back then, how they still run 90% of mainframes as we speak. I'm not at all sure this is about to change. Interesting outlook.

7

u/Ragingman2 Sep 02 '19

Personally I often turn to Java for personal projects because

  1. I'm already familiar with the syntax

  2. The documentation of the standard library is very good

  3. There are often libraries available that do some or most of what I want to do for me

1

u/srpsycho Sep 02 '19

I understand your frustration.

At the end of the day, it all goes back to maintaining existing code--in your case, it sounds like Java has been used in your company for years. Unless there are severe security issues with this existing code, and/or Java becomes unsupported one day, then it won't likely be changed.

You also argue that runtime in Java is slower (this is true because of the JVM), and I can see why you want more optimized code. If your company were to switch to C#, the tradeoff of time must be considered--is it worth rebuilding your whole architecture, when the time could be used to add more to the existing one? This can eat up a lot of costs too (i.e. hiring new devs, or a consultant that specializes in making that transition happen).

3

u/Lofter1 Sep 02 '19

This wasn‘t really about my company. We do use C#, and we see what it does for us every day.

2

u/srpsycho Sep 02 '19

That's good for you then, since you're not a big fan of Java lol

In the grand scheme of things and to answer your question, my response addresses why Java is a preferred language for some teams. In a perfect world, all dev teams would use something better like C#, but it's not always feasible. It always comes down to a business decision and opportunity cost, and sometimes you just gotta work with what you already have.

An example: SAS vs. R.

R is open-source, cleaner, and gives you the ability to do way more than SAS, but:

  • SAS has been around forever (still used heavily in finance and healthcare industries)

  • SAS is easier to learn/use

  • SAS has customer support (this justifies the cost alone)

As much as I dislike SAS, it's not going away primarily because of the 1st and 3rd reasons. This is because

  1. A lot of companies depend on legacy code and it would cost more (time or money) to recreate everything in R.

  2. Companies like to have that piece of mind and if something goes wrong, they have the option to cover themselves and sue. In the case of Java, Oracle has their own support system.

2

u/minimim Sep 02 '19 edited Sep 02 '19

Many organizations using Java also still have a huge investment in COBOL and keep it going.

Except for a few COBOL programmers that their minds warped by years of abuse, no one really likes COBOL. Yet universities around here offer it as a course you can take.

About people saying they prefer, it might be linked to the fact that Java has this capability of supporting very large scale projects that are still lacking in other languages. People that deal with those problems don't wanna have to deal with a legacy COBOL code base, a legacy Java code base and start developing in a third one.

Syntax and tools are good enough for them and they would have to develop the large scale support for any language they pick up, so they think it's still the better option.

1

u/Tkwk33 Sep 02 '19

Dud, don't be like that with poor COBOL :(

Been working with COBOL in Mainframe for about 6 years and I love it for work. Of course I need my little Java and Python personal projects to feel like I'm not a dude in my 60s lol

1

u/Ttaywsenrak Sep 02 '19

For me, I also prefer C#. But Java is what I learned on. The syntax is easy, and in my opinion static typing > dynamic. I also like brackets, and use them when I dont have to. It makes code more readable to me personally.

I guess for me its all about readability, and Java is very readable. Also, the fact that it runs anywhere is pretty cool. What I dont understand is actually the hatred so many people have for the language.

-2

u/Oxc0ffea Sep 02 '19

Java isn't so bad relative to C++. Show me some Java code and I'll tell you what is happening. No SO or googling required. Ditto for C#.

Can't say the same for C++.

All three will have "good enough" performance for most things. Java/C# have more modern/sane and bigger std libraries.

0

u/bimbar Sep 02 '19

- C# runs on Windows only.

- Java was designed as a C++ without all the dangerous features that don't really add anything but make C++ code hard to understand and to maintain. Then, it is my impression, that C# came along adding all that crap back in. I'm not a fan of that. For projects with many people that can be a problem.

- There is a huge java ecosystem that you may not be aware of. Java has a huge install base in enterprise grade web services, because Java servlets are a very robust and performant technology. C# can't compete because nobody in that environment runs Windows web servers, for good reason.

Now if you write programs on windows that have a GUI, you are better off with C#.

1

u/chalk_nz Sep 02 '19

C# compiles to many platforms (.Net Core)

0

u/bimbar Sep 02 '19

Sure. But nobody in a big corporation will use that, the risk is way too high.

1

u/chalk_nz Sep 02 '19

I also think this isn't true, not for a couple of years any way.

Source: worked for one, worked with people from another, seeing job listings about

1

u/bimbar Sep 02 '19

Probably depends on the environment, but enterprise tends to be quite conservative.

Understandably so, if you have to explain to your boss why you chose .net on linux and it develops problems.

Nobody ever got fired for buying IBM ;) .

1

u/chalk_nz Sep 02 '19

Maybe so. I worked in an enterprise, the others worked in a cool SaaS company.

In both cases, bosses didn't make language choices (the team decided and got architecture endorsement). One was a bank, so times are changing.

1

u/bimbar Sep 02 '19

Maybe the ISP environment I have experience in just is super conservative.

1

u/ImJustHereForMyCoat Jun 24 '22

All of these points are incorrect.

C# runs on Windows only

C#/.NET is cross-platform - you can build apps for Linux, Mac, and Windows

that C# came along adding all that crap back in

You have no idea what you're talking about. Garbage collection is far more efficient in C# than it is in Java. If you're referring to the fact that, in C#, you can make interop calls to C++ libraries using DLLImport then that is a major benefit.

C# can't compete because nobody in that environment runs Windows web servers

Like I said, the OS doesn't matter. Bimbar - I encourage you to try both languages before you chime in with your comparison opinions.

The language features of Java are nowhere even close to C# - safe navigation operator, null coalescing, auto-properties (haha @ Lombok...), not having to specify exceptions, EF Core (JPA is an abomination in comparison), etc.

Fact: C# is a more performant and less verbose language than Java.

This is coming from someone who has 10 years of experience building both ASP.NET applications and Java SpringBoot applications for enterprise clients.

0

u/[deleted] Sep 02 '19

I'd rather be pulling from maven central than npm, nuget or whatever people are using for C++ these days. I think that's a big part of it. The ecosystem is a gold standard even if the language itself isn't exactly bleeding edge.

-9

u/delventhalz Sep 01 '19

I think people who prefer Java are mostly just old school Java devs that never learned anything else. And of course there is plenty of legacy code to maintain.

Personally, if I were starting a JVM project, I would reach for something like Kotlin or Scala.

-2

u/MugiwarraD Sep 02 '19

some people are backward minded.

0

u/[deleted] Sep 01 '19

[deleted]

-9

u/Lofter1 Sep 01 '19

yeah, I understand that, if one language is already established in a company, changing it isn't really the thing to go for. But that isn't what I'm talking about.

Other languages have as many tools and resources as Java for stuff like web service development, sometimes even more, and might even be developed for just that purpose. Yet, there are still people out there who always go for java, no matter what.

And it goes even further, people don't only use java for stuff where you can see why they chose java, but for stuff where java is just a terrible choice because it is not designed for that use-case.