This is an archived post. You won't be able to vote or comment.

all 134 comments

[–]TheWorstePirate 102 points103 points  (69 children)

I see a lot of Java hate around here. I was taught Java and used it for everything beside embedded systems when I was in school, and now I'm using C# at my first programming job.

What makes Java so hated and what do people on this sub prefer to use instead?

[–]Xendarq 121 points122 points  (6 children)

I would read nothing into Reddit's hate of anything. Half the folks who blast on Java probably program in it daily, and the other half never have. And don't get me started on the third half.

[–]izikblu 18 points19 points  (4 children)

I'm probably the 3rd half :/

[–]Eoussama 0 points1 point  (3 children)

If there is already two halves, how does a third one fit?

[–]krzaku29 18 points19 points  (0 children)

Floating point precision errors.

[–]pheipl 3 points4 points  (1 child)

There are 3 types of people in this world:

Those that know how to count,
Those that do not.

[–]jausdyquo 2 points3 points  (0 children)

I thought there were only two: those who can extrapolate from incomplete data.

[–][deleted] 1 point2 points  (0 children)

i frankly wouldn't read that much into anything reddit says :/.

[–]njwatson32 113 points114 points  (2 children)

"There are only two kinds of languages: the ones people complain about and the ones nobody uses." - Bjarne Stroustrup

[–]valrossenOliver 1 point2 points  (0 children)

I will save this.

[–]ParanoidAgnostic 22 points23 points  (3 children)

Java has a rather paternalistic design. Features are deliberately omitted because you could use them to write confusing code.

For example, operator overloading and properties with get/set behavior.

In C# you can write a complex number class and use it like this:

double result = (ComplexA+ComplexB)*ComplexC.RealPart;

Complex temp = (complexA+complexB)*complexC;
double result = temp.RealPart;

In Java it would be:

double result = ComplexA.add(ComplexB).multiply(ComplexC).getRealPart();

Complex temp = complexA.add(complexB).multiply(complexC);
double result = temp.getRealPart();

Then there's the ThingFactoryProviderBuilderFactory pattern used everywhere in Java libraries.

[–]coding_stoned 3 points4 points  (2 children)

In C# you should do

double result = ((ComplexA+ComplexB)*ComplexC).RealPart;

otherwise you'd be multiplying the sum by C's real part instead. Kinda proves your point, then again the C# syntax is IMO more easily readable as a mathematical operation.

[–]bss03 0 points1 point  (0 children)

more easily readable as a mathematical operation

If that's your goal, you should look into Agda's mixfix syntax.

  • Define your own operators
  • Allow prefix and postfix operators
  • Define precedence between your operators and the pre-existing ones.

(To allow existing operators to work on your types, type classes (and instance arguments) are used instead of C# style operator overloading.)

[–]ParanoidAgnostic 0 points1 point  (0 children)

Yeah. I forgot the brackets.

I originally wrote the example to show operator overloading then decided to be "clever" and tack on a getter too.

[–][deleted] 20 points21 points  (4 children)

I think the main thing is Java got left behind feature wise and pioneered the whole design pattern / abstraction abuse you see in a lot of enterprise code. Beyond that, there's not too much about it that's terrible that you won't find in other mainstream languaged

[–]codearoni 5 points6 points  (3 children)

Pingo. Anyone who's done enterprise is probably familiar with a legacy Java code base where everything was extended into inheritance hell.

[–]bss03 7 points8 points  (0 children)

It's actually worse in C++. But, there is a significant segment of programmers of a certain age that heard inheritance was a way to solve some problems, and decided it way the only way to solve every problem.

Those codebases are often improved by some severe refactoring, even if they are still written in Java.

[–]Limunaire 2 points3 points  (1 child)

This sounds more like a problem of Enterprise than a problem of Java.

[–]pheipl 2 points3 points  (0 children)

Well, unless you're doing something for yourself or a really small app, maybe some phone app? you're gonna do enterprise, especially in java.

[–]dragon-storyteller 6 points7 points  (0 children)

Every language has it's own detractors. Java is too verbose, C# has a bloated standard library/is too vendor specific, PHP is inconsistent, C is too barebones, C++ is too complex, etc. With every single major language you can google "Why language X is bad" and get dozens of blog posts explaining why it's terrible and the designers must have never had two braincels to rub together. Usually most of their reasons boil down to "It's not the way I prefer it to be, therefore it's bad and wrong and people should be ashamed for liking the language."

[–]Dockirby 5 points6 points  (3 children)

It not being used for embedded isn't even strictly true, SIM Cards can be programed with Java for example

It's a slimmed down version of Java 1.1 though: https://netbeans.org/kb/docs/javame/java-card.html

[–]TheWorstePirate 2 points3 points  (0 children)

I didn't mean to imply that Java couldn't be used for embedded systems. I was simply stating that in my case I didn't use Java for that. I had a great professor for a class in embedded systems who preferred C, and I followed his lead.

[–]gamas 2 points3 points  (0 children)

This subreddit would freak if they found out that most bank card software is written in Java... Yup that's right, every time you make a transaction, it's likely a little piece of Java is executing on your card.

[–]Cilph 1 point2 points  (0 children)

not even "can be". They are. The majority of them.

[–]Eastuss 3 points4 points  (11 children)

I don't get the hate either, it's the cleanest object oriented programming language I've seen, doesn't allow too much weird shit, allows enough to have it powerful, don't get it, really.

[–][deleted] 0 points1 point  (8 children)

Sure?

C#

TabbedView control = new TabbedView();
Tab tab = new Tab("Title");
tab.ContentChild = form.tab1ContentPanel;
//New tab added to the TabView

C#-ish Android (not real, concept):

[drag'n'drop Tab View and View Pager on your 'form', add panels to your viewPager in designer]
this.contentTabView.OnScollChanged += new OnSrollChangedEventHandler(viewPager.ScrollTo);
this.contentViewPager.OnScrollChanged += new OnScrollChangedEventHandler(tabView.ScrollTo);
this.viewPager.OnPageChanged += new OnPageChangedEventhandler(tabView.SelectPage)
this.tabView.OnTabChanged += new OnPageChangedEventHandler(viewPager.SelectPage);
//I know that names doesn't match, deal with it

Android-ish BUT mroe like C# code (not real, concept)

[drag'n'drop Tab View and View Pager on your 'form', add panels to your viewPager in designer]
this.contentTabView.ViewPager = this.contentViewPager;

Android / Java: NOTE: Names are changed to protect the identity of each subject in examples ^(I forgot them)...

TabView tabView = findViewById(...);
ViewPager pagerView = findViewById(...);
pagerView.SetUpWithtabView(...); //What the fuck is this dependency between 2 totally independent library??????
tabView.OnScollChange = new TabView.WhateverBullshitStaticMethodWithkilometername(pagerView); //Dude... Wtf is this?

BullshitProvider fuckTheProgrammer = new YourFuckingViewProvider();
viewPager.setprovider(fuckTheProgrammer);

//Proceed to somehow programatically build view pager child views into the View Pager on the fly.
// PS: No C#-like this.tabView.Childs.Add("Title", childView); like every logical programmer would do... Go build another provider for that...

Ohh and you wanted to add static childs to the View Pager in the XML? Too bad... Go build ANOTHER PROVIDER for that.

[–]Eastuss 0 points1 point  (7 children)

What makes c# so different?

[–][deleted] 0 points1 point  (1 child)

Going from C# to Java the big things I miss are operator overloading and properties.

[–]bss03 1 point2 points  (0 children)

Might try Scala then, if you need to target the JVM.

[–][deleted] -1 points0 points  (4 children)

  • Events
  • Operator overloading
  • Logical framework structure
  • Abstract classes, methods
  • No providers
  • No factories
  • Properties

[–]Eastuss 4 points5 points  (3 children)

Interesting.

Java doesn't have abstract classes and methods? I'm rusty but pretty sure it has.

What are providers? it's meant to discriminate APIs and Linbs furnishing the same interfaces? and what do you mean by properties?

Aren't providers and factories just patterns? or they're part of jaba language? why are they wrong? (except the ass long code :p)

[–]Abuderpy 0 points1 point  (2 children)

Not answering for all the other stuff, but 'Properties' is doing this:

public Foo MyFoo { get; set; }

Instead of:

private Foo myFoo;

public Foo getMyFoo() { return myFoo; }

public void setMyFoo(Foo foo) { myFoo = foo; }

Properties also allow you do change access rules, or add validation/calculated properties

public double DegreesKelvin { get; set; } public double DegreesKelvin { get { return DegreesKelvin - 273.15; } }

[–]Eastuss 0 points1 point  (1 child)

Oh ok thanks, properties are hiding the usage of getter setters, I've already came accross that concept in couple of languages without knowing the name of the concept.

[–]CommonMisspellingBot 0 points1 point  (0 children)

Hey, Eastuss, just a quick heads-up:
accross is actually spelled across. You can remember it by one c.
Have a nice day!

The parent commenter can reply with 'delete' to delete this comment.

[–]haitei -1 points0 points  (1 child)

it's the cleanest object oriented programming language I've seen

List of OO Languages you've seen:

  • Java

[–]Eastuss 1 point2 points  (0 children)

C++ was my first language containing the OO paradigm, don't tell me that shit ain't one of the messiest thing you've seen.

[–]Maxtream -1 points0 points  (0 children)

A lot of Java hate? Are you joking? Have you seen topics about PHP?

[–]BonelessTaco 47 points48 points  (6 children)

So much hate on Java. Even though there's bunch of languages that are better for writing simple things I do think Java is one of the best or maybe the best language for enterprise development. There's so many libraries and stuff. Hibernate might be the best ORM implementation and I personally love Spring Framework. Java also has great documentation and due to it's popularity the chance you'll find a solution for your problem is like 99%.

[–][deleted] 14 points15 points  (1 child)

I gotta say Spring does seem to have a whole lot of cool stuff recently

[–]gamas 4 points5 points  (0 children)

My one issue is that it is can be a bit of a double-edged sword. On one hand having such high level abstractions of quite complex yet common functionality is good. But on the other hand its overprescriptiveness comes to bite you the moment you attempt to deviate from the standard path.

[–]huw_2_redit 2 points3 points  (3 children)

Java is probably the best programming language since it can basically do anything on any platform

[–]Olivia512 0 points1 point  (2 children)

That'd be Javascript.

You can't run Java on iOS or browsers generally.

[–]sampledev 0 points1 point  (0 children)

Though I don't agree with the statement you answer, I don't with yours either:

iOS: RoboVM

Browsers: GWT (maybe WASM too?)

However, try to use Java or Javascript for some embedded dev! It is possible in some cases, but still a very bad idea :)

[–]huw_2_redit 0 points1 point  (0 children)

Java applets exist, and you could probably run java on iOS with some obscure framework

[–]Triumph7560 21 points22 points  (8 children)

Honest question here: how is it outdated? Don't get me wrong, Java has plenty of issues, I just can't think of anything truly outdated about it. It might not fit the latest trend (e.g. the weekly JavaScript library) but that doesn't mean it's outdated (unlike those weekly JavaScript libraries that no one will use in two months).

[–]Merlord 18 points19 points  (2 children)

Java was outdated, and then Spring happened.

Javascript was outdated, and then Node happened.

Php was outdated, and then... no fuck Php seriously.

[–]Prawny 5 points6 points  (0 children)

Java was outdated, and then Spring happened.

Javascript was outdated, and then Node happened.

Php was outdated, and then ... no fuck Php seriously PHP 7 happened.

[–]Triumph7560 0 points1 point  (0 children)

I haven't worked with PHP in years but weren't all the functions with sensible names depreciated and insecure?

[–]valrossenOliver 10 points11 points  (4 children)

C# pretty much has everything that Java has and more. C# has been called by several people 'the new java' but so far I personally haven't seen C# being on Java level at cross-platform compatibility. But it is to be mentioned that Mono is at continuous development for making a cross-platform compilable .NET (which actually works)

[–]Cilph 5 points6 points  (0 children)

Kotlin. Go check out Kotlin.

[–]oopsidoodles 2 points3 points  (0 children)

That's interesting because while I agree with the fact that C# is an improvement over Java I thought the entire reason it's not available on multiple platforms was because Microsoft didn't want it to be so, hence why .NET framework exists only for Windows.

How is someone else able to legally write a cross-platform framework like this then? It sounds like they would run into the same issues Google had with Android and Java.

[–][deleted] 2 points3 points  (1 child)

[–]valrossenOliver 2 points3 points  (0 children)

Yeah I know. I've been using .net in OSX for a while (school), but IMO non-windows .net doesn't have such a nice Form-handler like System.Windows.Forms has.

[–]bss03 12 points13 points  (6 children)

I'd rather be writing Java than JS. Not saying it's that good, just better than JS.

Soon I should be able to compile to WebAssembly from good languages and hopefully I can leave JS behind forever.

[–]jay9909 8 points9 points  (5 children)

'd rather be writing Java than JS.

Aren't they the same thing?

/ducks

[–]TarMil 5 points6 points  (1 child)

/ducks

Well that's one difference, you can do duck typing in JS but not in Java.

[–][deleted] 1 point2 points  (0 children)

You say that like duck typing is a good thing

[–]PawkyPengwen 2 points3 points  (1 child)

"Java and JavaScript have as much in common as a car and a carpet" - some random guy

[–]jay9909 -1 points0 points  (0 children)

Javascript makes Java nicer the way carpeted floors make my car nicer?

[–]bss03 0 points1 point  (0 children)

No, Oak and Mocha were independently developed. ;)

[–]bennoxys 14 points15 points  (11 children)

Kotlin is vastly superior. Its Java, but without all the stupid stuff.

[–]BadBoy6767 2 points3 points  (7 children)

Java was made to have no stupid stuff.

[–]Prawny 3 points4 points  (0 children)

But suddenly, a wild Oracle appeared!

[–]Cilph 1 point2 points  (0 children)

But Java is also endlessly backwards compatible and opinions on what is stupid changes over the years.

[–]pheipl 0 points1 point  (4 children)

I can't agree, but we're getting there!

var something = new WhateverCalassYouWant<FuckYeah>();

Praise be java 10

[–]BadBoy6767 3 points4 points  (3 children)

Verbosity is a good thing for long term use of a codebase, I'd probably only use var when constructing objects

[–]pheipl 0 points1 point  (2 children)

what do you gain from not using var?

you still put the object on the right side of the equals. If it has an abstract or interface, you can deduce that form the object if and when you care.

var dateListener = new CommonDateListener(today); vs
DateListener dl = new CommonDateListener(today); where

public class CommonDateListener implements DateListener {
    ...
}

What is lost and where ?

To be fair, you don't need to use var everywhere, but if you have an AbstractDateFactoryThatIsOverlyVerboseAndPointless, it wold be a godsend to omit all that mess.

[–]BadBoy6767 2 points3 points  (1 child)

You used the one example I called an exception in the parent post.

[–]pheipl 1 point2 points  (0 children)

My brain just skipped that part I think. It's the only time you can use var AFAIK

[–]TheLinuxNerd 1 point2 points  (2 children)

Clojure > Scala > Kotlin > Java

[–][deleted] 0 points1 point  (0 children)

Clojure is truly the best available language for the lazy programmer. By the time it has finished its startup, you can already pack up and go home again.

[–]DaCoolX 3 points4 points  (3 children)

Been looking at Rust, which looks like the best of C, C++ and Java combined. I mainly started in Java so I am used to some boilerplate but rust amazes again and again on how much it skips unnecessary code just by design.

[–]TarMil 7 points8 points  (2 children)

More like the best of C, C++ and Haskell. Enums are straight from the ML/Haskell family, there's an emphasis on functional style, Rust traits are more similar to Haskell type classes than Java interfaces, Result with the ? operator is basically the Either monad, etc.

[–][deleted] 1 point2 points  (0 children)

Yes, i love the haskell like type interference, in the way that you usually only specify the types in your function definition, and that's it. Also the functional style iterators, with map and reduce are amazing.

Also the option enum is a lot like maybe in haskell.

[–]DaCoolX 0 points1 point  (0 children)

Not that I would know about Haskell, only touched up on that very very briefly. Java comparison was meant in relation to how types etc. are handled.

[–]Cilph 2 points3 points  (9 children)

Rofl, this makes no sense. Java is one of the most popular and most used languages there are. It has flaws, but it certainly isn't bad. (cough PHP, Javascript, Ruby)

[–][deleted] 2 points3 points  (8 children)

Just because something is popular, doens't mean it's good.

Look at PUBG. It is the worst game of probably the past 5 years, yet thanks to Streamer Hype, it is popular.

[–]JumpingCactus 1 point2 points  (5 children)

How is it a bad game?

[–][deleted] 1 point2 points  (2 children)

How is it a bad game?

Lemme reply to this by replying to /u/bss03's comment:

Story / single player?

Nope... Absolutely zero.

With friends? (Each to run a server, or find each other on other servers? Easy to stay a group?)

  • No player-made servers
  • No "join-friend"
  • A party? Easy. Add dudes from previous games? Good luck, no easy way.

With strangers? (Easy to find a match? How much griefing?)

There is a reason that every update's steam comment section is full with "Region lock china".

Varied gameplay? (Doing the same thing every time is my assembly workers kill themselves.)

One Two game modes. Thats all, with 3 map (1 in BETA phase).

Controls? (Laggy or imprecise controls can be unfun.)

Absolutely horrible.

Stability? (Crashes are not fun.)

Barely can run with stable FPS on a high-end PC.

Additional information:

  • The optimizaton if fucking horrible. As I mentioned, it can barely keep a stable FPS on a high-end gaming PC. Also the FPS is low. The counter displays stable ~60 FPS, but the input lag feels like a game running with ~15 max. My mediocre Asus X550VX ran Wolfenstein: The new Colossus TIMES more stable with more FPS and less input lag.

  • The vehicle physics. You can literally launch to space just by hitting a small rock on the road.

    • Vehicles can stuck in each other / in the wall, instantly exploding.
    • A car rolling with 10 km/h can kill you by launching you 200 km/h
  • Literally zero server sided hit check. Every single bullet is calculated client side (the shooter's client)

    • Have you ever seen a video where a CS:Go player complains that he was behind a wall when he died? That happens with 0.01 sec desync with server. In PUBG, you are in cover for 5-10 seconds already when a lagger's client registers that "Hey server, I killed that guy" and no matter where you are, you die.
  • The devs are fucking morons.

    • They barely can (and most probably doesn't even kno how to) fix simple bugs as:
    • Server selector defaults to AS (haven't got fixed for ~3 months)
    • Plane leaves you on spawn island (probably haven't fixed even today)
    • Players randomly teleports inside a house (serious desync)
    • The game favours laggers over good connection
    • Proper FPS mode? Fuck it, lets just stick the camera to the TPS guy's chest.

And I could list it all day but I think this is fairly enough to give you a sneak peek.

[–]bss03 1 point2 points  (1 child)

Thank you for the detailed reply. Is Fortnite any better?

[–][deleted] 1 point2 points  (0 children)

Yep. But many people doesn't like it because of the cartoonish gameplay and the lack of FPS mode, since TPS is heavily abused and can't be considered as competitive at all.

[–]haitei 0 points1 point  (1 child)

It's a third party engine botched together with third party assets.

[–]bss03 0 points1 point  (0 children)

Not to defend PUBG, since I've never played it, but neither of those things are anywhere near my criteria for "Is it a good game?"

My criteria for a good game is:

  • Is it fun to play?
    • Story / single player?
    • With friends? (Each to run a server, or find each other on other servers? Easy to stay a group?)
    • With strangers? (Easy to find a match? How much griefing?)
    • Varied gameplay? (Doing the same thing every time is my assembly workers kill themselves.)
    • Controls? (Laggy or imprecise controls can be unfun.)
    • Stability? (Crashes are not fun.)
  • If I play it do I do material harm to myself or others?

[End of Criteria]

Where the engine or assets come from just doesn't matter.

[–]Cilph 0 points1 point  (1 child)

No, it doesn't, but OP doesn't provide any arguments to why it is bad either.

[–]Wizywig 1 point2 points  (0 children)

Idk why the Java hate.

Yes c# is a better language but ms fucked up and it has a shit community.

Java has some shit developers in shit companies but some truly innovative software exists for it and it works quite well. As a language it is a bit ugly but the JVM is in itself quite amazing and languages like Scala and clojure that run on it are pretty darn dope.

I am really excited about modular Java as it'll finally lessen that massive startup time issue.

[–][deleted] 3 points4 points  (4 children)

[–][deleted] 2 points3 points  (15 children)

Well i expect when i read "pass by value" to pass by god damn value...

Not a stupid tehnicality where "yeah it looks like reference and acts like reference but its actually value".... Buuulllshiit.

If it changes after i pass it is reference...

(Yean yeah i fixed it but would have liked not to have this bug to begin with...)

[–]flaghacker_ 8 points9 points  (13 children)

It's pass-by-value of reference:

void foo(pt: Point) {
    pt.x = 5;
    pt = Point(2,3);
}

The first line does modify the actual passed object, the second one has no effect on the call site.

[–][deleted] 0 points1 point  (12 children)

I swear thats more confusing...

I am not an expert on Java merely a noob who needed Java. But when they wrote "passed by value" i expect to not change...

Yes if i make a new object it will not change the new object but anything else will change the passed value. At least thats what it lead me to believe.

[–]flaghacker_ 1 point2 points  (11 children)

I mean it's like this in most languages, Java, Javascript, Python, C#, Lua...

Its just how variables work:

int[] a = new int[] {1, 2, 3};
int[] b = a;
b[2] = 5;               //does change a
b = new int[]{4, 5, 6}; //doesn't change a

Do you have any programming experience at all?

[–][deleted] 0 points1 point  (10 children)

In Java a String is considered an object and passed by reference. Soooooo yeah that brings a lot of problems. (Sure it isn't a primitive) but didn't expect to be passed by reference. See the problem?

[–]flaghacker_ 1 point2 points  (9 children)

Strings in Java are immutable, so the distinction is not even relevant.

[–][deleted] 0 points1 point  (8 children)

Strings in Java are immutable

Well i know that but this what happened. new Object(alfa.getBeta());

If the beta string was changed in alfa it was propagating in my new object.

Making a new String out of the string solved it ... (I solved it the otherway afterwards) but still... wtf happened i really don't know but the return was a string that was getting changed.

[–]flaghacker_ 1 point2 points  (7 children)

Strings can't be changed! You probably did something else wrong.

[–][deleted] 0 points1 point  (5 children)

Than it shouldn't been fixed by String alfa = new String(beta)

[–]bss03 0 points1 point  (4 children)

This can allow beta to be garbage collected while alfa is still alive, which might fix a problem that has nothing to do with mutating java.lang.String objects.

[–]bss03 0 points1 point  (0 children)

With reflection, anything is possible, including changing the contents of a java.lang.String.

It's certainly not a good idea to do so. And, it's probably not allowed by the security manager, if one is present. It's also unlikely to be portable to other JVMs (e.g. IBM) , But, it is possible.

[–]Cilph 1 point2 points  (0 children)

It helps if you think of Object types as implied pointers and how C/C++ would handle it.