795
(page 3) 50 comments
sorted by: hot top controversial new old
[-] Ilovethebomb@lemm.ee 74 points 1 day ago

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

[-] kitnaht@lemmy.world 79 points 1 day ago* (last edited 1 day ago)

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.

[-] SpaceNoodle@lemmy.world 34 points 1 day ago

Everything in Java is a hidden pointer

load more comments (4 replies)
[-] Lysergid@lemmy.ml 27 points 1 day ago* (last edited 1 day ago)

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

[-] rumba@lemmy.zip 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.

load more comments (1 replies)
[-] bluelion@sh.itjust.works 43 points 1 day ago
  • 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)

[-] Blue_Morpho@lemmy.world 28 points 1 day ago

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.

load more comments (2 replies)
load more comments (2 replies)
[-] chunkystyles@sopuli.xyz 26 points 1 day ago

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.

load more comments (9 replies)
[-] schteph@lemmy.world 27 points 1 day ago

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)
[-] Pencilnoob@lemmy.world 24 points 1 day ago

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)
[-] darthelmet@lemmy.world 25 points 1 day ago

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)
[-] Valmond@lemmy.world 16 points 1 day ago

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)
load more comments (17 replies)
[-] WormFood@lemmy.world 17 points 1 day ago

object orientated programming is the wrong idiom for almost all problems, and even in the few cases where it makes sense, you have to be very careful or it'll hurt you

[-] sum_yung_gai@lemm.ee 8 points 1 day ago

I have been trying to be more functional but I still use classes for things like loading/modeling configs. What are some common situations where using an object is a good solution?

I use python if that helps at all.

[-] pivot_root@lemmy.world 11 points 1 day ago* (last edited 1 day ago)

What are some common situations where using an object is a good solution?

It depends on what you mean by "object"

  • Some kind of structured data?
  • Some named type which fulfills an interface?

When you have some kind of structured data, having a class to represent it is fine. If you're able to give it type annotations, that's much better than passing around random dictionaries.

When you need polymorphism and have an interface where some method on an object needs to exist (e.g. car.honk()), that's also fine as long as you avoid creating subclasses and using inheritance. If you need some car that can honk like a truck and drive like a racecar, use composition.

What I would consider a good use of classes (more specifically, nominal types) is dependent types. The idea is that you use the type system to enforce invariants for data.

For example, suppose you have a string for a user email. It might be a valid email string, or it might be garbage like "z#%@("=))??". You have a function for updating the user email in a database, and it requires the email string to be valid.

One approach is to validate the email string after receiving it from the user. That works, but what if your coworker creates a new form and forgets to validate the email string there? Bad data gets passed downstream to functions that expect well-formed data.

Another approach is to validate the email string at the top of every function that expects well-formed data. That also works, but now you're validating the same string multiple times and pasting validate_email(email) everywhere.

With a dependent type, you have a ValidatedEmail type and a constructor for it. The constructor will return an instance of the ValidatedEmail if and only if the email string is valid. Any function that expects a valid email will only accept a ValidatedEmail, and not a string. If your coworker creates a new form and forgets to validate the email, the type system will complain about a string being passed instead of a ValidatedEmail. You also shift the responsibility of validating the email to wherever there is a boundary between validated and unvalidated data, avoiding unnecessary validation since you know a ValidatedEmail is already valid.

It's an extremely useful paradigm for avoiding logic errors, but it's unfortunately not as common as it should be.

[-] anyhow2503@lemmy.world 1 points 18 hours ago

That's good advice but I would add that Java really sucks at using "the type system to enforce invariants for data" and that this approach doesn't have much to do with what most (especially Java programmers) would consider OOP. I die inside a little bit every time I need to use code generators or runtime reflection to solve a problem that really should not require it.

load more comments (1 replies)
load more comments (1 replies)
load more comments (3 replies)
[-] Ab_intra@lemmy.world 30 points 1 day ago

Just imagine how it must have been to code Minecraft 🤣

[-] joyjoy@lemm.ee 34 points 1 day ago* (last edited 1 day ago)

They only had to deal with LWJGL. The corporate java world has to use Spring.

Edit: They also had to deal with all the fans saying they should've written it in C#.

[-] dev_null@lemmy.ml 6 points 1 day ago

And much of the confusion and frustration at "Java" is actually because of Spring, or the "enterprise" nonsense making everything unnecessarily complex. You can just... write Java without any of that.

You shouldn't though, because Kotlin exists, which fixes everything that's wrong with Java while still being 100% compatible, so even in legacy projects you can mix and match and write new code in Kotlin without needing to rewrite any of the existing Java.

load more comments (2 replies)
load more comments (1 replies)
load more comments
view more: ‹ prev next ›
this post was submitted on 13 Nov 2024
795 points (96.2% liked)

Greentext

4384 readers
1344 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