Live data from Hacker News

Don’t call it a comeback: Java is still champ

github.com

301–310 of 557 posts

Re: Don’t call it a comeback: Java is still champ

#301
post #179

Earlier quoted context omitted.

It doesn't fully solve the problem, but @lombok.NonNull helps a lot. It makes it clear which properties shouldn't be null, and catches NPEs closer to the source. Incidentally, lombok in general does wonders for boilerplate reduction. https://projectlombok.org/

> but @lombok.NonNull helps a lot Which @NonNull? There's javax.validation.constraints.NotNull, org.springframework.lang.NonNull, org.checkerframework.checker.nullness.qual.NonNull, org.jetbrains.annotations.NotNull, android.support.annotation.NonNull and a bunch of others[1]. The proliferation of Not|NonNull is evidence that I'm right, no matter how hard I get downed on HN. [1] https://stackoverflow.com/questions/35…

While this could be solved by introducing one into the standard lib, it is not that big of a problem in practice as nullability checkers understand all of these annotations.

Re: Don’t call it a comeback: Java is still champ

#302
post #225

Earlier quoted context omitted.

Agree with all of that except readability. Java has some language deficiencies (no first-class functions, "streams" missing for almost twenty years and added too late to be done elegantly) and some cultural norms (mutable everything, overuse of inheritance) that make it a chore to read most of the Java code you encounter in the wild, including the source code of the libraries you depend on. Figuring out the behavior…

Modern Java has first-class functions, pattern matching with structural binding, records/pure immutable data classes, the whole 9 yards: static void main() { BiFunction add = (Integer x, Integer y) -> x + y + 5; Integer result = addTo(10, add); Integer result2 = addTo(10, (x, y) -> x + y + 5); } static Integer addTo(Integer acc, BiFunction addFn) { return addFn.apply(acc, 5); } Integer eval(Expression e) { return swi…

This is destructuring but not pattern matching.

Re: Don’t call it a comeback: Java is still champ

#303
post #275

Earlier quoted context omitted.

Modern Java has first-class functions, pattern matching with structural binding, records/pure immutable data classes, the whole 9 yards: static void main() { BiFunction add = (Integer x, Integer y) -> x + y + 5; Integer result = addTo(10, add); Integer result2 = addTo(10, (x, y) -> x + y + 5); } static Integer addTo(Integer acc, BiFunction addFn) { return addFn.apply(acc, 5); } Integer eval(Expression e) { return swi…

First class functions are as modern as the Iphone 5.

Pedantically, I want to point out that first class functions predate the original iPhone by a large margin ...

Re: Don’t call it a comeback: Java is still champ

#304

Trouble with java is that it does not scale up or down in terms of ram. Minimum RAM for a sever doing something normal over tcp is measured in gigabytes. Big servers > 16gb get difficult to manage at runtime. You have to scale with more VMs. You can write useful C servers that are very small, especially if you compile with musl. And run the same code for 1000kcc (not a typo) When you have big arrays of memory storing…

Minimum RAM for a sever doing something normal over tcp is measured in gigabytes.

wut? do you mean MB? most small web services(jetty, jdbc/pg driver/json) I have work on use below 500MB

Re: Don’t call it a comeback: Java is still champ

#305
post #27

The only problem Java has is experienced C programmers don't build servers from scratch with it yet. Once they take that responsibility, the debate will be over because: "While I'm on the topic of concurrency I should mention my far too brief chat with Doug Lea. He commented that multi-threaded Java these days far outperforms C, due to the memory management and a garbage collector. If I recall correctly he said "only…

Oh, please. I once worked on a Java-based server at Google that had to answer requests with millisecond latency. In order to achieve this, the server had to block garbage collection most of the time. Periodically, each instance of the server would ask the load balancers to stop sending requests to it, so that it could then safely run the garbage collector, and then ask for traffic to return. We likely would not have…

> I once worked on a Java-based server at Google

This is kind of a fair comment, but kind of not, because Java performance and GC internals have really advanced a lot in the last decade. It would really help if you qualified approximately when this was.

> Sadly the garbage collection debate is full of people who want GC to be the answer to everything

Good point. I think more recently, the Java world is very aware of this. Native and off heap memory has been getting more use in performance sensitive stuff for quite a while. You can totally just (essentially) malloc and free in Java, if you really need to for performance.

That said, if you want to be able to make your code accessible to a wider audience, GC is a must. There are tons of junior and midlevel developers who don't really have experience working with non-GC application code (and in many cases are intimidated by it!), and you will be restricted from hiring any of them if you use a non-GC language.

If that's ok, then that's ok, but with Java you can still do a little off heap stuff in the critical part you need to, encapsulate it behind a safe API, while letting the juniors run amok in the rest of the codebase.

Re: Don’t call it a comeback: Java is still champ

#306
post #127

Earlier quoted context omitted.

Maybe I’m taking your comment wrong, why is this a bad thing? What other GC’d language just lets you turn it off?

It's not about turning it off. You just don't allocate on the hot path.

Some people choose to do neither! https://medium.com/@jadsarmo/why-we-chose-java-for-our-high-...

Re: Don’t call it a comeback: Java is still champ

#307
The CDI specification is what takes Java from "good" to "incredible". The dependency injection pattern makes Java a hybrid functional language, where all the state can be stored in the CDI container. This eliminates a whole class of bugs and simplifies a codebase allowing for pervasive use of composition.

Stuff like Microprofile, Quarkus, ActiveMq, Tomcat, and even JakartaEE are gravy on the cake.

Re: Don’t call it a comeback: Java is still champ

#308

Earlier quoted context omitted.

Low pause collectors exist explicitly for this purpose. ZGC and Shenandoah both trade throughput (more concurrent collections) for extremely low pause times: https://malloc.se/blog/zgc-jdk16

Does that mean they also trade _memory_ for low pause times? Because, in our application, the memory required for avoiding significant GC pauses is at least 4x the amount of memory we actually need at any given time. This can be significant too.

It's all about compromises. Only Rust is uncompromised.

Re: Don’t call it a comeback: Java is still champ

#309

Earlier quoted context omitted.

I'm with you, even as a Java developer I can immediately recognize when something was written in Java: it's ugly and slow. When it crashes, you know they missed a NPE or tried to use multiple threads.

> I'm with you, even as a Java developer I can immediately recognize when something was written in Java Sure, if we are talking about desktop applications and we ignore the exceptions (Intellij / Minecraft).

Minecraft's menus absolutely have that hacky terribleness feeling. It's still much better than Minecraft Bedrock (the C++ reimplementation), but it's also noticeably behind everything else

Re: Don’t call it a comeback: Java is still champ

#310
post #2

I've ditched Spring, am using Vert.x with Java 17, reactive & functional styles, records. Seems like a completely different language. If only project Loom will get out there so I wont be coding everything like Javascript I'd be happy. :)

Weird Spring is the reason why i am sticking to Java

Try CDI! much cleaner, faster, and without the Factory Factory Factories.
Post reply on HN