this post was submitted on 13 Nov 2024
789 points (96.1% liked)

Greentext

4383 readers
1946 users here now

This is a place to share greentexts and witness the confounding life of Anon. If you're new to the Greentext community, think of it as a sort of zoo with Anon as the main attraction.

Be warned:

If you find yourself getting angry (or god forbid, agreeing) with something Anon has said, you might be doing it wrong.

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 74 points 1 day ago (17 children)

Can anyone who's actually dealt with Java tell me how much Anon is exaggerating?

[–] [email protected] 132 points 1 day ago (2 children)

I've worked on a corporate project with multiple Java services, anon isn't really exaggerating. Java can be a hell scape at times

[–] [email protected] 47 points 1 day ago (1 children)

They forgot to mention that production Java applications apparently need to log a certain minimum number of completely meaningless stacktraces per hour to work properly. Or at least I assume that is the case from the fact that all of them do that.

[–] [email protected] 26 points 1 day ago (1 children)

Best with an old and vulnerable log4j on a Windows log server.

We don't know what'll happen if we update. And we don't know if the dude who coded it will answer our calls. YOLO!

[–] [email protected] 1 points 13 hours ago

At that point, just kill the VM the app is running on and deal with the fallout.

[–] [email protected] 6 points 1 day ago* (last edited 1 day ago) (1 children)

But none of this is relevant for a hello world program, right?

[–] [email protected] 4 points 1 day ago (1 children)

You would be surprised, errors right out of the box on a freshly initialized project aren't uncommon

[–] [email protected] 13 points 1 day ago (1 children)

As I've been working with Java professionally for years, you're right, I would be surprised, because that would be really uncommon.

[–] [email protected] 1 points 16 hours ago

Don't bother learning something new, this guy already knows it.

[–] [email protected] 79 points 1 day ago* (last edited 1 day ago) (3 children)

I'm pretty sure Java doesn't have pointers, so writing a hello world application isn't gonna fuck up nearly that hard.

The one thing he forgot though is that your source file is probably in the folder

com/companyname/net/classes/factory/factoryfactory/worker/lib/bin/refresh/jdk/model/ui/closebutton/press.java

And spread out among a bunch of other directories, and the java file is like...3 lines. But there are 10k files spread all around directories like this that are all 3 lines a piece with a class definition.

[–] [email protected] 34 points 1 day ago

Everything in Java is a hidden pointer

[–] [email protected] 17 points 1 day ago (1 children)

wait, so when .io gets deregistered, are a load of companies going to have to rename their root directories and rewrite all of their include statements?

[–] [email protected] 40 points 1 day ago* (last edited 1 day ago) (1 children)

Thankfully, despite naming them like that, it doesn't actually seem to have any real purpose. Apparently they just wanted to make sure that different companies making different libraries didn't accidentally use the same name for their project....

[–] [email protected] 9 points 1 day ago

That’s exactly the reason. And also no company is going through the bother to refactor that shit, so everything is named based on some other company 5 mergers and acquisitions ago.

load more comments (1 replies)
[–] [email protected] 27 points 1 day ago* (last edited 1 day ago) (2 children)

95% exaggeration. Here is reality:

  • yeah you need main class coz it’s OO-language. Though, not required anymore, which should’ve been done once Java got scrip language capabilities (jshell) back in JDK 9. But as of today not required anymore
  • imports exist in most if not all languages. Gotta be insane writing them manually in 2010 let alone 2024
  • installing Java runtime (JRE) is as simple as installing any app. Though for installing JDK you need 5 mins for setting PATH. Think about JDK as like TSC or Webpack and JRE as a Browser. I’d argue installing and configuring JDK is simpler than TSC or Webpack
  • Unless you doing some non-trivial multi-threading your stack trace will tell you exactly where is your NPE. You gotta be as blind as my teammates to spend more than 1 minutes to find where it is coz it literally tells you file and line numer where Exception occurred
  • I mean, yeah if you use IDE from 2000 it will look like it. IntelliJ looks modern, though I don’t like the fact latest versions look like VSCode
  • I hardly reach 3G of deps from all 10 projects I have on my workstation.
  • IDK what anon means by ecosystem here, Java ecosystem is quite standard across the board. JDK(std lib), Maven/Gradle(deps, build, publishing), Spring Framework (all sorts of blueprints and solutions to standard app level problems), Hibernate/JPA (ORM), JUnit+Mockito (testing). These are tools and libs used in 90% of projects I worked on. Of course there will be more depending on project needs. Layers? It’s not like language imposes any layers whatsoever. It’s just common practice to have 3-4 layers and some glue in-between.
  • don’t do GUI in Java it sucks and will suck until Java gets string interpolation. Hopefully soon
  • concurrency is actually the only thing which is really bloated in Java. Which will change with next LTS version if I remember correctly. And it’s not that hard if you actually read the f manual and not just “try and hope”. Again it will become much more efficient and easier to follow soon. As of now - yeah, not trivial. But people mostly prematurely optimize, so karma
  • Java is kinda have 20 ways to do same thing but actually no. Java built with idea of providing simple building blocks. Then it provides more specific API built on top of those building blocks. It allows to have API which solves typical problems and provides capability to solve custom problems with those building blocks. People often confuse this as many ways to do one thing but it’s like saying “I can have byte array why I need string data type”. Those are different levels of abstraction

Edit: typos

[–] [email protected] 19 points 1 day ago

95% exaggeration if he is a real programmer.

If he just tried to walk into Java knowing nothing or maybe PHP, and refused to RTFA, he might experience about 30% to 40% of that I just trying to do everything wrong.

[–] [email protected] 5 points 1 day ago

It's possible to get the old InteliJ UI back. Search for the Classic UI plugin.

[–] [email protected] 43 points 1 day ago (2 children)
  • a hello world doesn't need libraries in Java
  • installing JDK takes at most 5 steps, depending on the OS
  • a nullpointerexception is more likely the developper's fault (unassigned value, calling a function on a null object)
  • IntelliJ is easy to install and modern (granted, other IDEs are very ancient)
  • developping GUI apps is a PITA, no matter the ecosystem (generally)

The rest is more or less spot on (no idea about concurrency issues though)

[–] [email protected] 28 points 1 day ago (1 children)

nullpointerexception is more likely the developper's fault

Of course it was the developer's fault. But it's absurd a language without pointers throws an error about pointers.

[–] [email protected] 15 points 1 day ago (1 children)

I guess naming it NullReferenceException will revolutionize industry

[–] [email protected] 7 points 1 day ago

Having error messages that match the language is actually helpful. A reference and a pointer aren't exactly the same.

Like if Rust output "invalid word size" on a type mismatch.

[–] tyler 6 points 1 day ago (1 children)

The date of the post is from this week so it’s not accurate at all. Java does support main outside of a class now, and it doesn’t need to be static, or take args. You wouldn’t use JavaFX in this day and age either. Installing the jdk is absolutely nothing especially if you’re using IntelliJ as it will install it for you and manage everything. No library is even close to 3gb.

This entire post sounds like it was written by someone that last touched Java in 2010.

Source: am a Kotlin dev. Java sucks. None of these are the reasons why.

[–] [email protected] 2 points 1 day ago

Depends on the version of Java you have to use and most places still say to put it in a class because they're outdated too. (Is anything about Java modern?)

[–] [email protected] 26 points 1 day ago (3 children)

I've been programming in Java professionally for 11 years. It's not just embellishment, it's outright lying.

Threads giving you race conditions? All concurrent programming will do that if you're shit at it.

Java has come a long way. I will admit that UI in Java is terrible. I would never do that.

[–] [email protected] 15 points 1 day ago* (last edited 1 day ago) (1 children)

It's not accurate to accuse Anon of "lying," when both their story and yours would point to the race conditions from threads being a symptom of someone who's just learning the language.

It's not that serious though; because it's a greentext, it is both artificial AND homosexual.

load more comments (1 replies)
[–] [email protected] 3 points 1 day ago (2 children)

Threads giving you race conditions? All concurrent programming will do that if you’re shit at it.

Well, if you write Rust then there won't be race conditions.

[–] [email protected] 1 points 18 hours ago (1 children)

Rust is great, and I truly mean that. But saying you can't get race conditions in Rust is just not true.

And also, not everything is going to be written in Rust. When the company you're working for needs a web application quickly, that's better done in other languages.

And also also, Spring has a lot of niceties when it comes to concurrency that make this much less of a point.

[–] [email protected] 2 points 18 hours ago

You can't get data races at least, and in practice it's very difficult to get actual race conditions.

[–] [email protected] 1 points 19 hours ago (1 children)

Only in the context of data within the rust code. If you're writing threaded rust that interfaces with external IO, for example, you can still get bit by a race condition. A person can absolutely be shit enough to hit a race condition in rust.

[–] [email protected] 2 points 19 hours ago

interfaces with external IO

How would you run into a race condition like this with safe Rust? You can't share mutable file handles between threads for example. I'm not sure you're correct in saying its still possible. Even if it is, it doesn't sound easy.

[–] [email protected] 9 points 1 day ago (1 children)

Been coding Java for about 15 years now. Pretty much agree - anon’s primary mistake was using javaFX. From a junior dev perspective I can see why they’d do that, but Java isn’t really meant for building desktop applications, it’s meant to power web apps.

What they should have done instead is create a backend restful web service and wire up a frontend rest client with something suited to web app ui dev such as angular or react. Java has some awesome frameworks built for it over the years, something like spring boot would make building that backend service trivial if you know how to use it. JAX-RS/Jersey or even servlets could be utilized for this instead, if you wanted to.

Spring boot has some nice tooling for thread management, but Java also has pretty good options for this built in as well. As chunky mentioned, if you aren’t already versed in concurrency patterns, don’t try to perform concurrent operations or you’re gonna have a bad time. But do learn how to do this, because exploiting concurrency is one of the golden rules of good computing.

[–] [email protected] 4 points 1 day ago* (last edited 1 day ago)

What they should have done instead is create a backend restful web service and wire up a frontend rest client with something suited to web app ui dev such as angular or react.

If anon's program was designed to work as a client for some external server or if Java had absolutely no GUI frameworks, that would be fine. But if anon's goal was to create a simple desktop application, doing this would be the programming equivalent of a Rube Goldberg machine.

With that approach, you also need to be really careful about how you do it. Fuck that part up and you can end up with the locally-hosted REST server listening on the device's public network interface or vulnerable to CSRF from a web page opened in the user's browser.

[–] [email protected] 27 points 1 day ago (3 children)

Java is religiously backwards compatible. Modern java projects are not as enterprisey and boilerplatey, but, as jdk21 is backwards compatible with jdk1.3, you can still happily write code as if it's 2003.

Additionally, the java space is huge, so just wildly googling will probably not help you that much.

load more comments (3 replies)
[–] [email protected] 24 points 1 day ago (7 children)

It's much better today, but in 2010 that was 100% accurate.

That being said, using Java as a first time programming language is like a 15 year old trying to fly an airliner to get a few blocks away to pick up some after school snacks. Obviously it's way overkill. Sure you could get across town with it, but it's probably 1000x more complicated than just a simple bicycle or even walking.

Java is industrial strength for professionals. There's absolutely no consideration made for educational usage.

load more comments (7 replies)
[–] [email protected] 25 points 1 day ago (1 children)

Only have a beginner perspective, but in school I did really well in intro CS class that used Python. 2nd class was in Java and it almost broke me I was so confused.

load more comments (1 replies)
[–] [email protected] 16 points 1 day ago (3 children)

I have developed in java and C/C++ (many years) and Anon is maybe exaggerating a bit but not lying, we all have been there more or less.

Personally I hate how java forces you into bad architectural choices. Where is the unsigned int? Why isn't an int a class BTW? Why the pass by copy for some, by reference for others? Where is multi inheritance? Lots of things are dumbed down or you have no choice in the matter.

Sure didn't help it was a power hungry beast moving at snail speed back in the day too.

load more comments (3 replies)
[–] [email protected] 18 points 1 day ago

Anon pretty much sums up my experience with Java when I had to learn it in college 20-ish years ago. I'll never get rid of my distaste for the language I'm afraid.

[–] [email protected] 3 points 1 day ago

Concurrency isn't bad, and package management (while maven is absolutely terrible to work generally), the dependency chains aren't exceptionally bad. Getting it installed is easier than python on platforms it's not already there on, not because it's more portable, but because the installers do more for you. Portability is hard, they haven't done it well but they've paved the default use case pretty well (although that works against you when you get to harder cases)

But the rest is pretty close.

The worst is the scaffolding, it's literally superstition for years to gain the understanding as to why you're doing it. I took two years of Java in high school before getting a degree - it was 4 years and halfway through a degree before I understood why I was making a class with a method main(string[] args). It works like that because your entry class calls the main method with a list of string arguments... I didn't understand at all, because even though it's simple it's a special case, and I'd never seen anyone name the string array anything different, so I just copied and pasted it, never understanding it because I'd been told "you just have to have that" for do long

Builds are arcane too - there's still companies that only use netbeans in their build pipeline, Android still requires a specific an old Java version in conjunction with the IDE or a gradle build, at best a project uses maven (the package manager), which is xml based and full of arcane details that are best treated as a magic incantation to be copied exactly from elsewhere

[–] [email protected] 12 points 1 day ago

Anon is absolutely exaggerating for comic effect. That doesn't mean Java doesn't have all of those problems though, it just isn't as ridiculous as they made it out unless you get dragged into enterprise bullshit (then you're in for it).

[–] [email protected] 9 points 1 day ago (1 children)

For the “simple” apps anon is talking about, they are exaggerating a lot. Though, when you get beyond the obligatory “Hello World” and “a window with a button”, the complexity does start to increase exponentially.

Throwing in frameworks like Spring or JavaFX does make things more complicated. But it’s still relatively manageable once you get used to it and know what goes where and when.

Now the whole configuration thing, that’s an art form best left to those hooded “seniors”. It’s good to learn eventually, but not when you first start out; lest you have a fetish for pain.

Java has come a long way. It’s not the languages fault that people create monstrosities like AbstractJavaFinalSerializedFactory or whatever. But if you do want to be “good” at Java, you will want to learn about design patterns. It also doesn’t hurt to have a thick skin too, because you’ll be both criticized and made fun of for your choices. 😊

[–] [email protected] 2 points 19 hours ago

also doesn’t hurt to have a thick skin too, because you’ll be both criticized and made fun of for your choices.

As somebody who started out with PHP I can fully relate to this. 😋

[–] [email protected] 1 points 22 hours ago

After working with somewhat modern Java using IntelliJ for 4 years,, it's alright. Null is the most annoying thing imo; just use Optionals instead

load more comments (2 replies)