Live data from Hacker News

Java 21 makes me like Java again

wscp.dev

201–210 of 777 posts

Re: Java 21 makes me like Java again

#201
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 ta…

C# def brought a lot to the table vs Java but I feel like it has also kind of stagnated and not realized the potential of F#. Scala likewise is very powerful but def overly complicated and difficult. Kotlin + Arrow hits the sweet spot, at least for me.

Re: Java 21 makes me like Java again

#202
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 ID…

> Also the null thing hasn’t been an issue for over 10 years.

I don't think I've ever seen a Java codebase that doesn't experience NPEs in prod, and that includes modern greenfield ones that make use of all the tools to combat it.

> Just use null annotations and both your static checker and your IDE will catch every NPE.

Yeah, or just catch it in code review, or just xyz...

Or, just switch to a compiler that doesn't allow it in the first place, out of the box?

Re: Java 21 makes me like Java again

#203

Earlier quoted context omitted.

`Executor.newVirtualThreadPerTaskExecutor` versus `go` really gets to the heart of why I think that Go developers aren't going to be switching. edit: Sorry, it's actually: try (var executor = Executors.newVirtualThreadPerTaskExecutor()) { executor.submit(...) ) instead of `go`

You’re likely to need a lot of boilerplate that “go” statement won’t generate: pass and wait for completed results, report errors, timeouts, cancellation, bounded parallelism, pushback, service monitoring.

[deleted]

Re: Java 21 makes me like Java again

#204
post #197

Earlier quoted context omitted.

I don't think any existing Go developer is going back to Java. I worked with Java for 10 years and switched to Go and I will never go back. This is mostly because applications and libraries are so hard to reason about and understand due to inheritance, packaging, OOP, build tools ect compared to Go. Go is simple. It's easy to understand, read, and maintain. The packaging is like how you would package files on your co…

Exception handling and generics are missing key pieces from go. But adding them will make go look like java. I just wish java would add null safety in the type system in a first citizen way. For enterprise use java has no competitors. You have c# which is microsoft trying to estabilish nash equilibrium fu*ing the developers. I am a bit worried about ever increasing complexity and a steep learning curve, but seems lik…

What is “enterprise” use? Plenty of enterprises use Go.

Re: Java 21 makes me like Java again

#205
post #61

[flagged]

As a Kotlin dev you should still be excited by virtual threads in Java 21. You'll never have to use coroutines again.

I'm very curious to see how this works out in the Kotlin ecosystem, given the amount of async code out there (and the associated function coloring issues).

Re: Java 21 makes me like Java again

#206

Earlier quoted context omitted.

I just picked up Java (via Kotlin) for the first time in four years, during which I've been doing Rails dev. I needed an AWS Lambda for zipping files into and out of S3. I banged my head against broken/unsuitable Node packages for doing so before finally giving up, since it is the lingua franca of Lambda. I was able to rewrite and deploy the function in Kotlin in two days' time. It was easy to set up and run, and wor…

AWS Lambda is the once place where you should never use Java. You have specific thresholds for how fast your function responds, jvm prevents that and requires more memory. AWS Lambda’s documentation shows how to accept a Request and send a response. You don’t need a package for that. For making zips from s3, again, AWS’s sdk. It’s one of the most commonly asked questions on SO. Here’s one implementation for you that…

Trust me, I looked up dozens of references. All would mysteriously halt after several files - known issues with how the Archiver library works, and none with any kind of fix, basically a data race within the library itself. Node's streams and promises are far too complex for far too little added benefit, and leads to broken concurrency in a multitude of libraries, and I'd had enough.

As for startup time - the latency isn't that important and would be an order of magnitude less than the ZIP construction, so the JVM warmup delay is actually just fine. The cost will be slightly higher, but it's not an operation I expect to run with high regularity - it's only on-demand for a reasonably small userbase.

As for complexity - which I am able to weigh due to the above constraints - Java's streams are not only simpler in design, but vastly more stable, and far more straightforward to glue together, and with highly stable implementations of ZIP stream wrappers and output-input pipes. A couple of additional stream wrappers for chunking into multipart upload segments and forwarding streams (introduced in JVM 9 when I'm on 8), and I was ready to go.

All that to say: don't create universal rules, though I agree that all of what you mention are good rules of thumb for certain. My given constraints work just fine with Java, here.

Re: Java 21 makes me like Java again

#207
post #163

Earlier quoted context omitted.

Huh. Guess I'm heterodox, then. I mean, don't get me wrong. It's quite useful once in a while, especially when working with containers, but I don't think of it as essential. But I'm fine with it as long as people don't overdo it.

Rolling your own containers really really sucks. Sucks enough to the point that it is essential, in my books.

Maybe I should be more clear.

This thread was in the context of go generics, which generally means go 1.18, when user defined generics were added to the language. Go always had support for a minimal number of containers, I've never rolled my own when working in the language.

Go had special compiler support for slices, maps, and channels before then, and they got used as the default containers for everything.

Using those was annoying when you needed to do the same thing to, say, a slice of strings and a slice of ints, but if you aren't using a generic heavy style, it actually comes up surprisingly rarely. And, if I'm being honest, I'd consider most of the uses of generics I've seen the average enterprise dev use to be mistakes.

Re: Java 21 makes me like Java again

#208
post #204
post #197

Earlier quoted context omitted.

Exception handling and generics are missing key pieces from go. But adding them will make go look like java. I just wish java would add null safety in the type system in a first citizen way. For enterprise use java has no competitors. You have c# which is microsoft trying to estabilish nash equilibrium fu*ing the developers. I am a bit worried about ever increasing complexity and a steep learning curve, but seems lik…

What is “enterprise” use? Plenty of enterprises use Go.

By enterprise I mean a lot of features related to data consistency, scalability and integrations.

I do not know about go ecosystem, but java and spring have mature solutions that cover the most advanced use cases.

Re: Java 21 makes me like Java again

#209

Earlier quoted context omitted.

This can never be as effective as changing the default reference type to be not nullable, which would break backwards compatibility, so you can never really relax. I know Kotlin is basically supposed to be that, it has a lot of other stuff though, and I haven't used it much.

That's basically what c# has done. But it's implemented as a warning which can be upgraded to an error. I think it might even be an error by default in new projects now.

Holy shit, how didn't I know they'd taken it this far? This is great! https://learn.microsoft.com/en-us/dotnet/csharp/nullable-ref...

They actually fixed the billion dollar mistake...

Re: Java 21 makes me like Java again

#210
post #29

Earlier quoted context omitted.

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 ?

I’ve been writing OOP code and reading about it for a decade or two, and inheritance was identified as problematic pretty quickly. The problem today, imo, is more underuse now.

>inheritance was identified as problematic pretty quickly

Exactly what I referred to here:

https://news.ycombinator.com/item?id=37539443

Post reply on HN