Live data from Hacker News

Java 18 / JDK 18: General Availability

mail.openjdk.java.net

241–250 of 304 posts

Re: Java 18 / JDK 18: General Availability

#241
post #49

Earlier quoted context omitted.

But the problem is that checked exceptions create the same “what color is your function” problem for errors.

It isn't? You have a function red that doesn't throws anything you use a function blue that throws checked exceptions you handle the exception and it's all. The red functions doesn't become blue.

if the "red" function isn't successful, than you're mapping that error to what? a RuntimeException? great – you've now escaped the indirection with the original solution – just use RuntimeExceptions.

map it to another checked exception and you now have a "blue" function. and, you also have another layer of abstraction in your errors.

if you can't actually handle the error, skip the circus and just let the exception propagate to a general error boundary (alongside all those RuntimeExceptions you're unaware of).

It's a deep ocean, your defense mechanism of guarding against Checked Exceptions is a small fraction of all exceptions.

To be fair, I did really like the idea of checked functions when I first started using Java. But in practice, it's just too hard to tell what operations should be Checked / Unchecked (sometimes).

Re: Java 18 / JDK 18: General Availability

#242
post #27
post #21

Earlier quoted context omitted.

That’s not an oops. You’re comparing pointers.

Still, coming from other languages, it is all too easy to write this and this silently fails without any warning. This is consistent with the rest of the language, but I'd bet one rarely wants referential equality when comparing strings. People commenting "yeah but that's because you are a newbie / you are comparing references and you should know better" miss the point I think. I can easily see myself making this mis…

I learned this 25 years ago when I got started with the language. It tripped me up once, I learned about how references work in Java, and that was that.

We are expected to learn about our tools.

Re: Java 18 / JDK 18: General Availability

#243

It's legitimately fascinating to see the rise of pattern matching, to the point that even Java will have it [1]! Combined with lambdas, this is a different language than the Java 1.5 that I first learned. If you would have told me that this would be valid Java code: static void testStringOrNull(Object o) { switch (o) { case null, String s -> System.out.println("String: " + s); } } I would never have believed you. And…

Everything since Java 7 has been a pleasure. The language is so much more mature now. The only problem is enterprise companies giving it a bad name, but I guess that's the price you pay for its broad usage.

Do you think Enterprises will ever give up the mountain of "design patterns" that (IMHO) make Java less desirable to work in? The Enterprise FizzBuzz is funny because of how true it is [1].

[1]: https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...

Re: Java 18 / JDK 18: General Availability

#244
post #226
post #90

Earlier quoted context omitted.

We like to give Oracle stick (and rightly so) but this is rolling/LTS done right: you break stuff in the release right after the LTS one, to give people time to adapt.

It was just a coincidence. They do it right: ship when it is ready. LTS is not an openjdk term it is something that vendors might offer for any jdk version.

> LTS is not an openjdk term

It's an Oracle term, and I expect the majority of OpenJDK committers and decision-makers are still from Oracle.

Re: Java 18 / JDK 18: General Availability

#245
post #26

Earlier quoted context omitted.

I think it has a relative speed performance over languages that are interpreted (runtime). It also has an ecosystem of tooling to monitor and profile built both into the JDKs and by teams across Silicon Valley (eg first class bazel support). I’m in one of these companies now, and while I’m certainly productive using Java, it’s also got huge downside in the community which these companies don’t really care about. Neve…

I feel like those crying cargo-cult or enterprise never stopped to look at the alternatives they use. Like Django or Rails. It's in many ways worse than java when it comes to conventions, abstractions doing magic, and weird rules for structuring code.

i've got tons of open source packages on my github with interpreted languages :p

But yeah, I guess i first started using Django ~2008 if I recall correctly, and switched over to Pyramid in 2010. Since then, I've used many other frameworks – in Python, Ruby, JS, C#, Java, and Go. Regardless of the language, I always try and go closer to the metal when I can.

I think your assessment about the others being potentially worse is fair: they're all bad in their own ways. I think it just takes time (and experience across many different teams) to develop good taste.

Re: Java 18 / JDK 18: General Availability

#246

Earlier quoted context omitted.

=== seems almost more dangerous. It's a lot easier to tell == from Objects.equals(a,b) than == from ===.

Seriously?

Yes.

Look, languages are moving away from permitting constructs like "if (x = 1)" because it's difficult to distinguish from "if (x == 1)". Adding "if (x === 1)" into the mix is arguably a step backwards in terms of clarity.

Re: Java 18 / JDK 18: General Availability

#247
post #83

Earlier quoted context omitted.

That wasn't the only reason why I left one job but their Oracle buy-in was a big factor. Things like paying 7 figures a year for support, and then having the Oracle support manager ask if they could redistribute the hot-patch I made to other customers.

Big enterprise vendors are always like that. My first boss wrote the TCP stack for a long defunct mainframe, which was distributed via a “shared source” program that his employer paid for and eventually was licensed to his employer at significant expense.

Early form of PaaS, Plagarism as a Service?

Re: Java 18 / JDK 18: General Availability

#248

This is tangential and possibly too open ended to be productive but worth a shot anyway. Why is Java so popular? I know of a major Silicon Valley company that's migrating their backend to it. Why Java over other languages? Or maybe there's not really other viable options? I'm speaking as someone who spent the last 6 years focused on frontend web technology.

I think it's a combination of four things: 1. GC is an enormous productivity improvement for applications whose performance characteristics can afford it. Seriously, I can't think of a single programming language feature/concept/technology that makes a bigger difference in developer velocity than memory safety and GC. 2. Static types are also a large productivity improvement for developers comfortable using them and…

> I also think it's a pretty decent language. The things people don't criticize about Java are mostly complaints about a certain style of programming in the 90s and less the language itself.

(assuming that's a typo there, the things people don't like/the things people criticize?)

I disagree on that point, I think the language itself was a problem. Java 6 and prior were very very verbose and very very slow. I think that really changed with JDK 7/8, but the java we know today isn't the java of the 90s.

Even then, to some extent that problem hasn't gone away, it's just been papered over with frameworks and library code. Like honestly even as a java dev, I couldn't tell you off the top of my head the exact code to open a file, read each of the lines, and then close everything, or the right way to open a JNP connection to RabbitMQ or something. Anything touching files or sockets is still an absolute nightmare of boilerplate code, inputstreams, filestreams, printwriters, try/catch, and mother. fucking. IOException. thrown everywhere. But you don't care, because you just call Apache commons-io or Spring RestTemplate.

And that has contributed to some criticism of its own. Spring tends to turn into architecture-astronaut crap, like everyone's favorite AbstractSingletonProxyFactoryBean.

> Java was the first heavily engineering and marketed language that featured GC, static types, and OOP, so it got big and continues to stay big.

The other quiet boost that people don't talk about is Android. Tons of libraries get written with the intent of being used in some android app somewhere, but you can use that equally much on desktop/server. It really really helps the rapid-prototyping aspect of Java that ~half the smartphones in the world are running Android.

Re: Java 18 / JDK 18: General Availability

#249

Earlier quoted context omitted.

They removed much bigger things, and broke backwards compatibility in much bigger ways. Finalizers aren't really used much in Java except for safety checks ("you forgot to close this object"), which can go missing without breaking things.

If you are leaking file descriptors in a production service it will absolutely break things. Generally most servers that aren't pushing the FD limit can get away with delayed reclamation of FDs but if you never claim them you will run into problems. Plus most code probably handles this poorly. I suspect it will often result in exceptions opening new files or connection which are just caught and retried forever, resul…

Java has the Cleaner API as a possible solution for this. (Also, try-with-resources is really great generally)

But I agree with you, it is anecdotically a problem for me right now as well: intellij under osx can’t index/import a bigger work project due to getting too many files IO exceptions all around, even though I tried increasing both the system limit, the java vm flag, everything..

Re: Java 18 / JDK 18: General Availability

#250

Earlier quoted context omitted.

They removed much bigger things, and broke backwards compatibility in much bigger ways. Finalizers aren't really used much in Java except for safety checks ("you forgot to close this object"), which can go missing without breaking things.

What bigger things have they removed? I thought Java lived and died on promising forward compatibility.

I really don’t think there are too big things, but perhaps OP means the deprecation and eventual removal of the security manager?
Post reply on HN