Live data from Hacker News

New Features in Java 14

blogs.oracle.com

21–30 of 188 posts

Re: New Features in Java 14

#21
post #5

"Helpful NullPointerExceptions": One of the biggest pain points of Java, probably the biggest. Good that it's being finally solved;

Java is quite far away from finally solving NullPointerException issues. Kotlin, C# or TypeScript with their compile time null checks solved it mostly. Common to these three languages is that they need null to be interoperable with older language versions (C#) or with related languages (Java, JavaScript). Languages like Rust that don't even know null (or nil as in Go), have finally solved the problem.

> Languages like Rust that don't even know null (or nil as in Go), have finally solved the problem.

I wouldn't quite phrase it that way, since it's nothing new. OCaml from the 1990s has no null value (you need to represent potentially missing values with Option). I suspect there are older examples than that.

Re: New Features in Java 14

#22
post #16
post #9

Earlier quoted context omitted.

> Languages like Rust that don't even know null (or nil as in Go), have finally solved the problem. I'm in no way a Rust expert, but I see a lot of code with Optionals, something like match sth { Some(v) => do_something None => nothing_to_do } This looks awfully a lot like if (something == null) { nothing_to_do } else { do_something } It might look more pleasant, but it doesn't "solve" anything, only shifts it in a d…

I can't speak for Rust, but in Go accessing properties of nil objects and dealing with 0-values for non-pointer values can cause bugs in certain contexts where you "let your guard down". func getFoo() (*Foo, error) func main(){ foo, err := getFoo() if err != nil { // be an adult and handle your error } foo.Work() // panic because whoever implemented getFoo returned a nil object } Also worth noting dealing with boolea…

Rust does not have nil objects nor zero values.

The equivalent rust code would fail to compile.

Re: New Features in Java 14

#23

"switch expressions", "text blocks". I haven't used Java for 15 years but it's one of the most mature languages out there. I'm surprised it's only just getting these pretty standard features now.

it's always moved slow on purpose... one of the language's greatest features is backwards compatibility and stability

it's purposefully dead simple. this is why many of us switched to alternative JVM langs ... Java can't keep up with the innovation other Langs have without breaking its philosophy of slowmoving/backwards compat

Re: New Features in Java 14

#25

Who cares about the new features? The new license makes it almost impossible to use Java without some form of payment to Oracle.

> The new license makes it almost impossible to use Java without some form of payment to Oracle.

Do you have a source for this claim? It sounds a bit extreme, to say the least, and I had the impression OpenJDK was licensed using fairly standard terms.

Re: New Features in Java 14

#28

Who cares about the new features? The new license makes it almost impossible to use Java without some form of payment to Oracle.

> The new license makes it almost impossible to use Java without some form of payment to Oracle. Do you have a source for this claim? It sounds a bit extreme, to say the least, and I had the impression OpenJDK was licensed using fairly standard terms.

It's mostly FUD: it's only relevant for the Oracle JDK; it doesn't apply to OpenJDK (or the other open distributions by other orgs).

Re: New Features in Java 14

#29
With switch, records, and (soon?) sealed interfaces, Java will be more pleasant than ever.

Would I ever choose it if I were in charge of a project? Probably not. But it is nice that the language is incorporating these proven features that make a huge difference. It'll make working in Java when I'm not in charge much nicer.

Re: New Features in Java 14

#30
post #23

"switch expressions", "text blocks". I haven't used Java for 15 years but it's one of the most mature languages out there. I'm surprised it's only just getting these pretty standard features now.

it's always moved slow on purpose... one of the language's greatest features is backwards compatibility and stability it's purposefully dead simple. this is why many of us switched to alternative JVM langs ... Java can't keep up with the innovation other Langs have without breaking its philosophy of slowmoving/backwards compat

To be fair, it moved much faster after the Oracle acquisition.

The Java 6 era of no changes whatsoever was slow as molasses. The joke back then was that even C++ got lambdas before Java.

Post reply on HN