Live data from Hacker News

Java 21 makes me like Java again

wscp.dev

101–110 of 777 posts

Re: Java 21 makes me like Java again

#101
post #40

The problems with Java can't be fixed by adding new things, you can't undo decades of ecosystem development, training, and ideology built on top of the idea that inheritance is really good idea and belongs everywhere. edit: I will say that as a Java developer I am grateful every day for the improvements to the language. Java is a very impressive language and I have a lot of respect for the people working on it.

Please ELI5 what is wrong with inheritance and/or how Java have it wrong. Do we need to go back to a new object oriented undegraduate course? Genuinely asking.

With compositions A uses B but B can never use A. With inheritance Child can use the Parent, but Parent will also call the Child (virtual methods) which in turn can call the Parent again etc.., so the code can become difficult to follow. It can become very complicated with multiple inheritance and multiple levels.

Re: Java 21 makes me like Java again

#102

Earlier quoted context omitted.

>” None of the memory problems of C++” I’m sorry, I’m calling BS here. You can still leak memory in Java.

You can leak memory in any language. That’s an impossible bar. The problems op is referring to is obviously about memory safety. Java obviously isn’t thread safe like Rust is, but it’s typically safer than C++ on that front too.

Rust isn’t thread safe either. It’s borrow checker will attempt to correct you but you can still run Rust unsafely.

Re: Java 21 makes me like Java again

#103
post #61

[flagged]

Let's not forget that the JVM still does not have reasonable generics & value types. The .NET CLR introduced this in 2005, bettering the JVM. Java was in a sleepy slow release mode back then. We've been waiting 18 years for value types and proper generics - Valhalla has been just about ready for a very long time. Some of us moved on a long time ago.

Agree that Kotlin is a bright spot in terms JVM languages. For my taste has adopted some of the best concept of Scala, but without the burgeoning complexity.

Re: Java 21 makes me like Java again

#104
post #14

Earlier quoted context omitted.

None of the memory problems of C++, the speed of C++ most of the time. Thousands of high quality libraries, a JVM that is a marvel of engineering after 20 years, tooling for development, monitoring and introspection of exceptional quality. Many of the internal tools at the largest Cloud developed in Java. Most enterprise level software. NASA extensive use of Java. A team behind the development who has stunning common…

>” None of the memory problems of C++” I’m sorry, I’m calling BS here. You can still leak memory in Java.

Shitty code is shit in any language. What's your point?

Re: Java 21 makes me like Java again

#105

The problems with Java can't be fixed by adding new things, you can't undo decades of ecosystem development, training, and ideology built on top of the idea that inheritance is really good idea and belongs everywhere. edit: I will say that as a Java developer I am grateful every day for the improvements to the language. Java is a very impressive language and I have a lot of respect for the people working on it.

Prefer composition over inheritance has been a common mantra for at least a decade, if not more. Maybe you should undergo the last decade of development and training.

There will always be shitty devs, and since java is one of the biggest languages, it definitely has more than some ultra niche academic language no one uses. I don't think it is the fault of the language though, or if that somehow were a reason to choose a different language. Should a decent BMW driver sell their car, because plenty assholes buy that car also?

Re: Java 21 makes me like Java again

#106
post #61

[flagged]

Well when Sun imploded and Oracle stepped in, Java stopped getting regular releases for 10 years. Java versions literally came out every 2 years before Oracle happened.

So that’s why they’re 10 years behind. But now they come out like 2+ times a year so they’re on track making major progress.

Also the null thing hasn’t been an issue for over 10 years. Just use null annotations and both your static checker and your IDE will catch every NPE.

Re: Java 21 makes me like Java again

#107
post #3

In other news, we have an upgrade path at work to go from Java 8 to Java 11 pretty soon.

We (finally) upgraded last year from 8 to 17. Lots of nice things, I’m so glad we were finally able to. But it was a big project due to some dependencies and how some things were done internally.

I can’t wait for 21, but I’m not sure when we’ll switch. At least it will be trivial compared to leaving 8.

Re: Java 21 makes me like Java again

#108
post #29

Earlier quoted context omitted.

I rarely see inheritance used in practice in java code bases. Except where I would use a union type or sealed class in other languages anyways. I don't feel what youre describing is a real issue.

Sorry, what? Is not java toghether with Ruby maybe the most hardcore OOP enthusiasts that uses inheritance for "most stuff". Has the java culture move so far the last decade ?

Funnily enough, it actually started from C++. And, Java is so large that it is simply meaningless to talk about a unified style -- sure, some Java EE behemoth will continue to run on a complicated Application Server for decades still, churning on its workload, but so will someone write a Micronaut microservice, or something for robotics, and these will all have distinct styles.

With that said, even the Java EE/Spring complicated word has been moving towards a less inheritance-based future.

Re: Java 21 makes me like Java again

#110
> Why do we call them product types anyway?

Answer in the piece is not wrong, but put more intuitively and succinctly: the total number of possible value (inhabitants) in a product type is the product of the quantity of inhabitants of the constituent types.

Replace the “product”s with “sum”s and it works too.

Interestingly, the total number of unique functions (judged only in terms of input and output) from a -> b can be found by exponentiation, (inhabitants of b) ^ (inhabitants of a).

Post reply on HN