380
Anon tries programming in Java
(lemmy.world)
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.
Can anyone who's actually dealt with Java tell me how much Anon is exaggerating?
I've worked on a corporate project with multiple Java services, anon isn't really exaggerating. Java can be a hell scape at times
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.
Best with an old and vulnerable log4j on a Windows log server.
But none of this is relevant for a hello world program, right?
You would be surprised, errors right out of the box on a freshly initialized project aren't uncommon
As I've been working with Java professionally for years, you're right, I would be surprised, because that would be really uncommon.
Don't bother learning something new, this guy already knows it.
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.
Everything in Java is a hidden pointer
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?
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....
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.
They have sort of pointers, like references, that can be null...
You just "new" stuff to it and let the "garbage" collector deal with freeing stuff up. When it feels like it.
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.
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.
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.
It's not someone who is learning, because "how to avoid race conditions" is like java concurrency 101. The entire thing is made to prevent that shit from happening. And it is incredibly easy to setup a "happens before" relationship.
Well, if you write Rust then there won't be race conditions.
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.
95% exaggeration. Here is reality:
Edit: typos
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.
It's possible to get the old InteliJ UI back. Search for the Classic UI plugin.
The rest is more or less spot on (no idea about concurrency issues though)
Of course it was the developer's fault. But it's absurd a language without pointers throws an error about pointers.
I guess naming it NullReferenceException will revolutionize industry
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.
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.
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.
I mean they are lying because Java does support main as a top level function now. If this was written last year, sure. Also IntelliJ will literally install the jdk and manage it for you. Using asdf I haven’t had to touch the PATH for Java in probably over a decade (used sdkman before that).
This entire post sounds like someone that last touched Java in 2010 and wanted to complain about it again. Java is shit, but for none of the reasons in the post.
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.
Is that why every single application will only work with some ancient version of Java?(usually 8, sometimes 1.6 or 11)
I can’t think of many cases where Java 21 is a drop in replacement, and I don’t think I anyone actually used 17.
That's entirely the fault of applications (or more likely their libraries) using internal APIs or JNI. As long as it isn't doing anything screwy with reflection and class loading or using the
sun.*
packages that aren't part of the language specification, Java bytecode compiled for ancient Java versions will still work on modern versions.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.
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.
Disagree. It's an outdated tool today. Professionals would not choose it for new projects.
There is also absolutely no consideration in Java for production usage.
Which other eco system has more stable libraries, which are easy to install and redistribute and deploy?
I would choose always choose the most boring language for the task. That the good thing about java that it is very boring and most likely won't run into a obscure problem if you stay away from reflection and unsafe.
Pretty much any compiled language is easier to install and distribute. Java applications are an absolute pain to get to run to the point that most need specialized wrapper scripts (usually in shell on unix platforms) and need to tinker with memory management parameters on almost all of them.
Do you mean something like c or c++ where you have to deal with big little edian, libc, utf8, platform specific threads, various compilers feature sets and a lot of undefined behaviour. Also if you want to distribute a library it is much harder because you a have to package it yourself or what for a distro to package your library or build a header only library which has to be manually updated every time a new version comes out. With maven you just have to upload it and you can use it in another project
How often do thinker with the memory management in Java? Just use the g1 garbage collector, which will be fine most of the time if you have a problem just use another one.
You can also compile the program with GraalVM to a native binary, also most Java programs are servers where it make sense to have a systemd service to configure the server
As a sysadmin unfortunately every single one of those shitty Java projects forces me into dealing with that sooner or later.
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.
Hated Java in school
But before Java I learned a bit of Pascal and C/C++, and I'm so fucking happy that I'm currently working with C++ in my job and not with fucking Java
I still hate it with everything I've got ...
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
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).
If you've never used Eclipse, which I assume it was referencing, it does feel old, clunky, and ugly out-of-the-box (to me at least). I tried to use IntelliJ wherever possible, but a previous company had a project that really didn't like to run from it but would with a very specific setup in Eclipse (I don't recall any details now more than 10 years later).
There is a fair bit of boilerplate and bloat.
I don't remember UI stuff being so bad, but most of what I worked with was old Swing/AWT stuff. I did have to use JavaFX (I think it was?) once and remember something about it being frustrating, but it was for some existing thing I had to modify.
I don't mind Java so much, but it's certainly not my favorite language.
I don't know how one gets a nullPointer when doing a hello world, though. I'm guessing this is embellishment or mashing together something later with their initial printing of hello since I think you'd come up with some other error in that process to getting something to print before nullPointer.
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
It certainly can be that bad.
https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition