r/learnjava • • Dec 29 '23

I don’t like Java. Change my mind.

Hi all! I don’t mean for this to be a shitpost or anything like that, truly. Lately, for some reason, posts from this sub have been entering my email. I’m primarily a C# dev, and I love Typescript as well. I’ve always hated Java. Don’t ask me why…I don’t know. When I was in school, I was more or less taught that Java is super slow because the JVM is bad.

I’d love to know what’s been up with Java, partly because a lot of banks seem to use it and partly because I don’t wanna be that guy that just discounts a whole language because of flaws it had over a decade ago.

So change my mind! I’d love to find out what’s been up with Java, and any resources y’all can provide for learning Java (bear in mind I’m a very experienced software engineer) that aren’t LinkedIn Learning (I get access through my local library but that access is down right now) would be super appreciated.

Again, this is not a shitpost. I just hate Java. Change my mind!

0 Upvotes

86 comments sorted by

•

u/AutoModerator Dec 29 '23

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions

  • You include any and all error messages in full - best also formatted as code block

  • You ask clear questions

  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

42

u/[deleted] Dec 29 '23

Lol you don't know why you hate java and you want us to change your mind?

Nah.

-26

u/capm_diealone Dec 29 '23

Exactly.

No haha my main complaint is the slowness; and I understand that my last experience with Java is pretty old, so I’d like to know what’s been up lately. I’ve Heard the JVM has improved, but I’d like to know how. I guess my question is: why Java?

18

u/[deleted] Dec 29 '23

And I'm saying that this isn't a marketing/sales subreddit where you ask someone to pitch you something lol. Java has made a lot of noise this year. A quick Google search will show you what you want.

-8

u/capm_diealone Dec 29 '23

I don’t think a quick google search WILL show me what I want. I want to hear from people who wrote Java regularly. Maybe I phrased my question in a confrontational way, but I’m genuinely open to opinions. Java is massive these days, and I want to be the best engineer I can, so I’d really just like to know what sets Java apart.

Again, I’m not trying to be a dick here. Just wanna start a conversation :-)

2

u/toasohcah Dec 29 '23

I don't know if you ever played much Minecraft, but I firmly believe over the last 10 years it has shaped an entire generation's opinion of Java somewhat poorly...

If you look at any post about troubleshooting poor performance, especially for heavily modded games, it's common to see a comment about how bad and slow Java is.

People don't seem to factor in, it's a single threaded game, with a messy code base, that can be computationally very heavy.

-3

u/capm_diealone Dec 29 '23

I’ve only played Minecraft on the PS4

2

u/wisdom_power_courage Dec 29 '23

I'm not sure why people are being asses to you. It's a fair question.

2

u/parachute50 Dec 30 '23

So you hate Java just because it's slow??? Cry me a river smh. Btw it is not slow.

10

u/Stack_Canary Dec 29 '23

Java is pretty fast these days. Fairly certain it outperforms C#

1

u/capm_diealone Dec 29 '23

Anything I can read about this? I’d love to see some numbers

3

u/Stack_Canary Dec 29 '23

https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/csharp.html

This compares different languages based on execution speed, binary size, memory usage etc. Seems C# has the general edge still, but for some type of algorithms java is faster.

Though, note that it's tricky to say language X is faster than language Y, as it depends on implementation and use cases. Even though C# may be faster in solving a fannkuch-redux problem, it doesn't mean that an API made in C# is faster than an API made in Java when you take into consideration DB operations, architecture, deployment and startup-times, architecture etc. Java has become very modernized in the last 10 years, and you see performance improvements for nearly every new version. The "myth" that java is slow comes from ancient versions of java way before version 8 and simply is not the case anymore.

6

u/capm_diealone Dec 29 '23

So in summary, I have nothing to lose by becoming as good at Java as I am at C#?

To be honest, most of my professors taught us algorithms and data structures in Java…C# wasn’t really a thing back then…I just always preferred C and C++. Even Python haha. But based on the responses I’ve received in this thread, I’m gonna learn Java. If it’s as modernized as you said, I have nothing to lose aside from my decades old prejudices.

Thanks Reddit! Stack_Canary specifically

1

u/Stack_Canary Dec 29 '23

No problem, you've asked a good question here. And to comment on your summary you're absolutely correct, Java is one of the most widely used backend languages, and it's not going anywhere anytime soon. It's performant and versatile, and has become less verbose and more shorthand than it was before. I would check out java 17 as it's the current LTS version.

Another note is that you can check out Kotlin as well, which is also a JVM language. You can even write Kotlin and Java interchangably in the same project. I personally prefer Kotlin, and if you're serious about entering the Java sphere it's worth checking out, as you'll see most JVM code bases using both.

And as a final note, you can check out the results of the stackoverflow survey for 2023 which gives a good overview of what's used and what's popular across all languages: https://survey.stackoverflow.co/2023/#most-popular-technologies-language-prof

3

u/capm_diealone Dec 29 '23

Oof, I don’t like that SQL is called a ‘programming language’…makes the survey seem dubious at best. But that aside, thanks! I don’t know how to add friends on Reddit (yes I’m a software engineer and I don’t know how to use Reddit) but let’s be friends. Cheers, dude! And when I say ‘dude’ it’s non gender specific, though statistically you’re probably a dude.

2

u/Stack_Canary Dec 29 '23

Well it's a developer survey, and considering a lot of developers use SQL, and the fact that there are DB-specialists, it makes sense to include it as a "language technology" so to speak, if they're trying to map what people are working with. It's a fairly renowned survey, one of the biggest of its kind :)

1

u/capm_diealone Dec 29 '23

Fair enough. But it’s not a programming language haha…I guess I’m fairly old school, despite being only 35 years old 😛

3

u/LTFGamut Dec 29 '23

Of course it's a programming language (a logical one). Why wouldn't it be?

-1

u/capm_diealone Dec 29 '23

I don’t have the mental capacity to dispute your assertion that SQL is a programming language, but it’s not even close to Turing-Complete

→ More replies (0)

8

u/4r73m190r0s Dec 29 '23

Yes, here you go:

MetricJavaC#
Speed87.362.9

1

u/MadBroCowDisease Dec 30 '23

C# outperforms Java across the board.

0

u/Miserable_Ad7246 Dec 29 '23

I would not make such a bold statement. I'm a C# dev. Java has some things going for it, but usually, to get that perf advantage you need to tweak things out. Dotnet just tends to work well out of the box.

For me, the biggest advantage Java has is and ability to use different GCs (like zgc). DotNet in this regard is still lagging. Other than that, I feel that both environments are very close and should trade blow in the hand of a typical developer. Modern dotnet jit and runtime are very well optimized and dotnet is pulling away when it comes to native AOT.

1

u/Stack_Canary Dec 29 '23

True, I guess it was a bit bold/simplified to say it outperforms C#, they're quite similar. Either way, I don't think the reason for choosing one over the other is speed. If you're actually looking for performance and speed in a system where that's necessary, you should consider languages like rust, go or elixir.

1

u/capm_diealone Dec 29 '23

Okay I’ve never even seen a single line of rust, but I’ve heard about it. What’s the benefit there? Why use rust over something like C# or Java where the community is mind-bogglingly massive?

1

u/wisdom_power_courage Dec 29 '23

Performance and speed.

1

u/capm_diealone Dec 29 '23

Elaborate?

1

u/wisdom_power_courage Dec 29 '23

0

u/capm_diealone Dec 29 '23

I’m gonna be honest right now…I’m pretty drunk and on the edge of sleep. So I’ll read this in the morning. But thank you <3

4

u/BannockBnok Dec 29 '23

You'd have better luck asking in another subreddit. I mean, this one is full of people who are just starting out.

I've done java for 4 or 5 years now and love it, but it's no more than another language choice.

I will say that it's not slow anymore. I've heard stories from my dad of programs freezing and crashing because of the gc, but have never really encountered something like that.

I also really enjoy not having to deal with memory in general. Most I have to think about are io stream resource leaks, but I'm also usually alert when working with them so no issues. Though, I am a bit jealous when I see c/c++ bros doing all sorts of funny wizardry with memory...

For application integrity, if that's something you need, it's a pain in the ass. You need to both secure the JVM as well as the jvm bytecodes contained in your built jar. "Write once, run anywhere" is also dead because of this. It's just a pain to deal with in general. If you don't want reverse engineers touching your program then just know it'll be a pain.

We do have Spring though, which is battle tested and well-established, so if a webapp is something you're building then you're good to go!

The whole platform itself is also very built from years of use. Many libraries to pick from for nearly every task.

Oh and there's no linker so no linker errors. You only have to deal with the compiler.

1

u/capm_diealone Dec 29 '23

This is the exact response I was looking for! And technically I am just starting out in Java. I’ve been unemployed for a few months (the dev job market up here in Toronto is pretty brutal) and I can’t even count how many jobs I haven’t applied to because of ‘Java experience required’.

What exactly is Spring? I’ve seen it on postings and I’ve been asked about it in interviews, but I don’t know what it is. Web framework?

1

u/Academic_Put2971 Dec 29 '23

😳

2

u/capm_diealone Dec 29 '23

Don’t be coy. Help me haha

1

u/Academic_Put2971 Dec 29 '23

Spring is actually a web framework (you can find is grand son called spring boot )

1

u/Academic_Put2971 Dec 29 '23

I was surprised because when companies post a job their mentions the framework their used most of the time 🕰️

4

u/Money-Calligrapher85 Dec 29 '23

Java dont like you

0

u/capm_diealone Dec 29 '23

Don’t be that guy.

3

u/Money-Calligrapher85 Dec 29 '23

Fine. You heard bad things about it earlier in your life but never tried it yourself. Youre biased. Hate it or not. Its there. People use it and it has a value for specific things. Just like every other language. Might be good for one project might be bad for another.

Compare it to languages in normal life. You probably like english and would like to learn another language but you dont want to learn lets say Afrikaans as youd never have to use it.

-2

u/capm_diealone Dec 29 '23

Everyone is biased, it’s a fact of life. If we’re comparing programming languages to languages, I’ve learned enough German to know that German offers expression beyond what English can provide. I’m just looking for what Java can provide beyond what C# or C++ or Python can

2

u/Money-Calligrapher85 Dec 29 '23

Lets say Java is german. So Java offers expressions beyond what english can. Might be perfect to describe things in a particular way and most likely be useful in Germany. Now lets use C++ as english. English would be waaaay better suiting in a english speaking country. You could also achieve it somehow with Java but it wouldnt be as perfect. So now use C++ / English in Germany, it might work pretty well as a lot of people speak English, but it wouldnt be as perfect as Java / German in Germany.

1

u/capm_diealone Dec 29 '23

So what’s Germany in this analogy? I love the analogy, but where is German/Java more useful than English/C++? Obviously Germany. So what’s Germany? Haha

2

u/Money-Calligrapher85 Dec 29 '23

Germany is just a „project“ where the language fits better then others do. Thats about it. C++ might work, Java works better. Java might work, C++ works better. Project to project, country to country.

3

u/nekokattt Dec 29 '23 edited Dec 29 '23

it feels like you posted here with a message that sounded like

"i like c sharp, i know i am right because someone taught me this without explaining why but tell me i am wrong"

which basically is flame bait, as evidenced by the other comments here.

Perhaps reword your question to be diplomatic, or press the magic unsubscribe button at the base of the emails you are getting.

Regardless, my points as to why Java is a good language and platform to work with:

  1. The JVM isn't slow. Maybe 30 years ago, but not now. You have JIT just like you do in C#.

  2. Classloading is often considered superior to other mechanisms that rely on the host OS to load binaries into memory

  3. Truely platform agnostic and able to interop into several languages (.NET can to a lesser extent)

  4. Agent support is incredibly useful (see AWS XRay, AppDynamics, etc)

  5. Much more vast range of libraries than C#

  6. Backwards compatibility out of the box. Try running a C# app compiled with .NET 1 in .NET 8 out of the box.

  7. JMX for monitoring out of the box.

  8. Continuous stream of new features since Java 8 including:

    • modules

    • sealed classes and interfaces

    • switch expressions

    • virtual threads that allow blocking code to get the same benefits as async await

    • new FFI to side load native binaries without writing C++ bindings

    • vector APIs

    • HTTP clients in the standard library

    • record types

  9. Limited but consistent language syntax features rather than developing for every paradigm that developers can think of, making it easier to maintain a consistent codebase.

1

u/capm_diealone Dec 29 '23

This is exactly the response I was looking for. I tried my best to be diplomatic, and I genuinely apologize if I wasn’t, but either way thank you for this.

5

u/[deleted] Dec 29 '23

Couldn't care less about changing your mind, but I'm going to correct you on the JVM. It was bad in the 90s performance-wise, but that is long gone and I bet that even when you studied it was already old info. That being said, I don't believe you have ever written an app where the reason for bad performance was caused by the JVM and not suboptimal code/design.

-2

u/capm_diealone Dec 29 '23

Hurtful, but fair. But for what it’s worth, I’m very good at what I do. And what I do is write code. I couldn’t care less about you not being able to care less about changing my mind. I posted here in order to grow as an engineer. My hope was to spark a discussion about Java, preferably on a very low level, so while I don’t really give a shit about your opinions of ME, I’d love to hear your opinions about Java.

5

u/bart007345 Dec 29 '23

Tip - if you want to grow as an engineer don't have faulty assumptions and learn to find out yourself.

1

u/SignificanceOdd986 Dec 30 '23

This is a really good point

OP in the post was already aware they had a bias. Given that they were already aware of that, couldn't they have just done the research themselves?

11

u/[deleted] Dec 29 '23

Try and remember that the people who taught you in school likely haven't updated their PowerPoint slides in a decade. Not everything they mentioned has stayed true.

1

u/nealgoogs Dec 30 '23

aren't java and c# similar? wtf is this shit? java is fucking amazing after working with javascript god that shit is hell

1

u/capm_diealone Dec 30 '23

Java and C# are very similar, but that’s not the issue here. JavaScript can be hellish, yes, but that also is not the issue. Please either contribute to the conversation or leave it alone; I’m not interested in any sort of shit-talk

1

u/abbh62 Dec 30 '23

Do you think google would have built their entire android platform on something that was terrible and slow?

Same with oracle

1

u/capm_diealone Dec 30 '23

I mean maybe android itself wouldn’t also be terrible and slow if it wasn’t built on Java?

1

u/abbh62 Dec 31 '23

Most of all of googles core services are also Java.

1

u/ClammyHandedFreak Dec 30 '23

Programming languages are just tools to get a job done. Doesn’t make sense to me to hate any programming language - especially as a contractor. I’d hate myself first.

1

u/capm_diealone Dec 30 '23

That was the entire point of my post!

1

u/raxel42 Dec 29 '23

The only issues are the huge frameworks like Spring and, as a consequence - huge memory consumption. Jvm is optimized on throughput, not latency. C# is running on top of their CLR virtual machine, which makes them roughly similar. CLR was better than JVM at the time Java prior and around 8. Plain core Java is good and fast. P.S. I have more than 30 years of coding experience.

-1

u/capm_diealone Dec 29 '23

I should have clarified…I know that that CLR and the JVM have the same issues RE performance, why wouldn’t they? I just can’t explain why I like C# better than Java haha.

Realistically, im gonna learn Java. I’d just like to know its strengths so I can learn in the best way possible

2

u/randomguy6492 Dec 29 '23

Java is going to be around for a long time. Here are some of the reasons that I could think of,

•	Versatility: Used in web development, mobile apps, enterprise software, and large-scale systems.
•	Readability: Relatively easy syntax, making it accessible for beginners.
•	Platform-Independence: “Write once, run anywhere” (WORA) principle allows Java programs to run on various devices and operating systems.
•	Strong Community: Active community support with abundant resources, libraries, and frameworks.
•	Fundamental Concepts: Teaches object-oriented programming, a fundamental concept in software development.
•	Robust and Secure: Known for its robustness and security features, making it suitable for critical applications.
•	Job Market Demand: High demand in the job market, making it a valuable skill for developers.

2

u/dswpro Dec 30 '23

Perhaps you weren't programming before Java was created. I've always called C# "Java Envy" as Java preceded C# by five years, with its lofty goal of making code portable across operating systems by compiling to an intermediate language with different run times for each OS. Since you now know and use C#, Java would seem significantly different as to be confusing, so you don't have to like it, but you should realize C# was in large part a reaction to Java

2

u/Vilified_D Dec 31 '23

You hate Java but use C#? (which imo c# is just java but from microsoft)

ANYWAYS. I used to hate Java too (it's a whole story on why I did hate java at the time, and my favorite language C++ came in to my picture waaay later), until I was doing a school project with an Arduino and Java literally saved the project. It was a group project, and my partner and I were using an Arduino like I said. Arduino effectively uses C++, and we were making 'smart' devices (the only real requirement was we used code to send stuff from actuators over the internet). The problem came from the main thing that makes a smart device a smart device: the wifi chip. The unit we had was a third party piece of hardware rather than one officially licensed from Arduino, and all the libraries that we found that allegedly supported it just did not work. We tried everything we could to get it to work, but it wouldn't, and writing up client server stuff in C++ isn't very straight forward (along with reading data coming from a serial port).

Enter java. Java has very easy libaries to set up a UDP server, as well as a library called jSerialComm which reads the serial port from a USB connection. Write up a bit of java for a client and a server, hook up the arduino to the PC that is running the client, you press buttons/it could read temperature, couple other things and arduino prints messages to the serial port, which java reads from, and upon getting those messages would send those messages via UDP to another PC that was running the server connection, and then the server PC would send an email. In the end, Java (which at the time I hated with a passion) saved my ass and got me an A.

I still prefer C++ because I want to do game dev, but I will never disrespect Java ever again.

1

u/ElNouB Dec 29 '23

thou hath the GAUL to say change my mind? it is only your loss young master...no one but yours...alas tis day shant be sadder than the rest, for we have lost naught but a heathen

1

u/wjrasmussen Dec 29 '23

Everyone hates java. You can't love it until you hate it. Now that you hate it, it shows you love it.

1

u/[deleted] Dec 29 '23

I only learned Java the past 2 years but, between inner classes , anonymous classes, and lambda expressions, it has become really versatile to the point it almost can feel like an OOP with scripting functionalities.

That being said NetBeans and eclipse still are both ugly as hell. IntelliJ all the way.

ALSO pretty much all of android is java/kotlin based so it's worth learning if you ever want to make web-based apps that will smoothly run on android.

1

u/Ok-Internal-288 Dec 29 '23

So Java's not your tool right tool for the right job.

1

u/DrFloyd5 Dec 30 '23

You like Java. (Waves hand with a twist.)

1

u/MoveInteresting4334 Dec 30 '23

I don’t particularly enjoy Java, but I trust Java. It’s like that one coworker that’s really tedious to hang out with or be in a meeting with but they’re super reliable and predictable once you know them.

1

u/SutoPeter Dec 30 '23

I don't want to change your mind. I hate it either. Objects, inheritance, damn annotations, unreadable code...

It is not for everyone and everything.

I don't wanna use it for simple applications. It's been designed and mostly used for robust and complex applications and solutions.

I am/was working for global corporations, like banks, insurance companies, now for a global container (on ships) delivery company as Java based middleware applications server specialist, and they are use monolithic Java frontend/web applications, MQ, mainframe backends also with Java.

It's not slow, or if it is, it can be easily scaled. I have never seen a scaled application on multiple nodes with PHP or JavaScript /NodeJS, etc, or if yes, it was embedded to a Java solution.

1

u/vuvanhoang11 Dec 31 '23

you should try it...

1

u/[deleted] Jan 01 '24

Since Java 1.8, I’ve been very happy with the speed of the jvm. If it’s the jvm and not the language that you don’t like then look into compiling Java into native code. The llvm was starting to have support and there is a straight to native compiler called gcj.

If you want me to defend the jvm then I think you should look at all of the languages it supports now. Clojure is far superior to F# and jython is pretty cool. Lastly maven as a unifying package manager glue is great and provides a lot of great support for other build systems to pull in dependencies.

1

u/BertRenolds Jan 02 '24

Why do I care what you think? If your employer needs you to use it, you use it.

1

u/Algorhythmicall Jan 02 '24

The JVM has always been state of the art. Look at the newer GC algorithms such as ZGC. Java, the language, is the slowest moving language targeting the JVM. The language rarely has breaking changes, and that means the designers want to slowly add features they are certain are useful. If you want a stable language that will remain stable over time, which can run on multiple battletested VM implementations on all OSes and platforms, and you want assurance of all that being true for the next decade, Java is a good choice. With typescript you will likely have a vulnerable NPM dependency next week (typescript is a great language, npm/node/etc moves too fast). C# and .NET are solid.

Ultimately, you choose Java for services because it’s syntactically simple, has a huge ecosystem, and has a track record of stability and performance.

1

u/parachute50 Dec 30 '23

So you hate Java just because it's slow? Cry me a river smh. Btw it is not slow.

-4

u/thisisjustascreename Dec 29 '23

Why do I care if you don't like Java?

-4

u/capm_diealone Dec 29 '23

The real question is: why would you go out of your way to post this? I don’t care if you care about my feelings on Java…I’m asking for opinions, not to be told about a lack of opinions

2

u/Unable_Request Dec 29 '23

Presumably to demonstrate what an odd question this is and how unlikely you are to find the answers you might want given the question phrasing

0

u/capm_diealone Dec 29 '23

Is it odd? Is this not the best place to find out why people like Java?

-1

u/loyal872 Dec 29 '23

I cannot change your mind. I agree with you. I've learned it for a long time, used to work in it and dropped it like it was nothing to me.

1

u/capm_diealone Dec 29 '23

Haha heartless! But then the question becomes: why did you drop it? And why was it so easy?

0

u/[deleted] Dec 29 '23

[deleted]

-3

u/capm_diealone Dec 29 '23

By no means do I consider typescript a ‘fast’ language. But it fixes a lot of the problems of JavaScript, while not replacing JavaScript. It’s not even a language, it’s a set of tools built around JavaScript. It makes the web better. JavaScript upsets me; I come from a background of strongly typed languages, and JavaScript has always felt like a toy. I know that’s not the case anymore since node and all that shit, but I’d much rather write something that’s going to be compiled rather than interpreted.

That said, JavaScript IS the language of the web, there’s no way around that. But that’s not what this thread is about. I’m entirely full-stack, and I’m entirely just asking about backend shenanigans

3

u/Kango_V Dec 29 '23

Java + HTMX == Great websites with NO Javascript. We are doing this for our internal dashboards. Works brilliantly.