Live data from Hacker News

Java 21 makes me like Java again

wscp.dev

151–160 of 777 posts

Re: Java 21 makes me like Java again

#151
post #54
post #22

Earlier quoted context omitted.

do/i/still/need/to/create/sub/directories/for/the/things/i/want/namespace?

Only if you're using vim like someone from the 70s, otherwise any sane IDE handles those things for you But, yes, namespaces are still mapped to paths, it's not like they rewrote the JVM to use blockchain or something

>Only if you're using vim like someone from the 70s, otherwise any sane IDE handles those things for you

I don't think that's quite it when Ruby is also from the 90s and figured out not to tie namespace resolution to the directory tree

Re: Java 21 makes me like Java again

#152
post #34

Earlier quoted context omitted.

Nullable is a huge issue in Java, but annotation-based nullability frameworks are both effective and pervasive in the ecosystem (and almost mandatory, IMO). I'm really excited about https://jspecify.dev/ , which is an effort by Google, Meta, Microsoft, etc to standardize annotations, starting with @Nullable.

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.

Re: Java 21 makes me like Java again

#153
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.

var list = [];

while (true) { list.add(1); }

Here you are, which language won't leak memory here?

Also, which language will let you connect to a prod instance without a performance hit to get some stats on the heap and its allocated objects? Hell, you can even list every instance of a type as I've recently learned.

Re: Java 21 makes me like Java again

#154
post #143

Earlier quoted context omitted.

> Golang golang is probably a good contender for business logic code where Java is widely used, but I feel ecosystem (libs, integrations) is not comparable to Java, so you take some risks while choosing golang.

And it is much more verbose, it is not even comparable in observability and on real world big applications (especially enterprise) you can't get away with value types and slowing down the threads to let the GC keep up with them -- Java definitely shines in these kind of conditions (GC-wise the only competition Java has is different Java GCs, really).

> you can't get away with value types and slowing down the threads to let the GC keep up with them

I am not Go expert, but to me this is Go's big advantage: you can chose you want to have object GC controlled or be on stack and copied everywhere. GC controlled objects add lots of overhead, because malloc is expensive, and require lots of memory per object to track state and synchronize between thread, and that's why JVM tries to adapt something similar: https://openjdk.org/jeps/8277163

Re: Java 21 makes me like Java again

#155
post #113

Earlier quoted context omitted.

No, there's a lot wrong with inheritance. It leads to all sorts of issues and while theoretically one can keep the tree 1 level deep, in practice it's too tempting to expand the hierarchy. This is one of Java's big issues. The other is reference equality as a default, pretty horrible. Records help but records are also limited in when they can be used.

You don't like code reuse?

Inheritance is not necessary for code reuse.

All you really need for that is named procedures. A way to combine modules and different files certainly helps too.

Type hierarchies can even hinder code reuse, because you can’t just pick the stuff you actually need.

Re: Java 21 makes me like Java again

#156

Can you convince me to use Java? I’ve never used it (only C++, Python, CL) but it feels bloated and dirty.

I work on a Python codebase now after years of JVM and here's what I miss, static typing taken as read.

* Threads that can use more than one core.

* The best approach to package management I've ever seen, no-one worries about typosquatting or "someone already registered all the cool crate names" because every package has at least two coördinates - a group id based on a DNS entry you must be able to prove you have access to, then the package name. So I can publish my malicious package gauva, but as I can't register it with the group id "com.google.guava" or even "com.google.gauva", no-one is going to mistakenly use my package.

* No fucking dance of the C libs. Or Rust these days. I want to use a Python package that wraps a C lib, but there's no binary wheel built for my version of Python and/or platform arch, so build from source it is. Which I'll figure out when pip install -r breaks, and then I get to a) apt-get/brew/etc. install the lib and/or headers b) install any compiler toolchain needed buy not yet present c) export compiler flags and header locations d) all of the above, and then run my pip install again. Until the next library breaks.

* Intersection types for generic bounds. I don't need it that often but when I do, I really miss being to say that for `def foo(ex: T) -> Z`, T must implement interfaces A and B.

* Logging. Occasional horrible security holes aside, Java's logging story is one of the best I've ever worked with, compared to it, Go's sucks, Python sucks more, like how you can't set your preferred timestamp format AND include millis without writing a custom formatter (seriously, go look at the source code of logging.Formatter.formatTime...)

* JMX and MBeans. Having detailed VM performance metrics and the ability to change exposed values or execute an exposed method at runtime built into the VM is amazing. Want to have a quick look at what's happening with the GC? JConsole in. Want to set one logger in particular to DEBUG to see what's going on in prod without having to restart anything? JConsole or jmxterm and away you go. Want to experiment with your batching parameters under prod load to find the sweet spot for throughput? Expose them via an MBean.

* No need for pyenv, virtualenv, etc. Although being fair, if you're working with different incompatible JDK versions, you'll usually end up using SDKMan like Python uses pyenv, and Maven needs a little bit of additional configuration to locate your toolchains, but Gradle is smarter about finding your available JDKs.

* Libraries with type signatures, makes for far easier code reading, and if you pass **kwargs 5 levels down, I hate you. Yes you, sentry-sdk...

* Libraries with correct type signatures, looking at you confluent-kafka, either publish type stubs to typeshed, or update your goddamn doc-string type hints so my IDE doesn't think that confluent_kafka.Message.value() is missing a parameter.

* The ecosystem. I really really really miss the ecosystem of JVM FOSS packages.

* The speed, in general.

I'm sure there's more, but these are the pain points I've been having of late.

Re: Java 21 makes me like Java again

#157
post #148
post #121

Earlier quoted context omitted.

I have not used Go generics, but it's viability as a business logic language would depend on that.

Wait, what? Generic programming is a perfectly valid style, but are you saying it's essential to implement business logic? Because, like, the last 3 languages that got adopted as the default business logic language didn't have them (Java pre 1.5, C, and Cobol).

and during last 20 years consensus has converged to the view point that generics are essential.

Re: Java 21 makes me like Java again

#158
post #61

[flagged]

As someone writing code on Java since v1.0 and making tech strategy decisions on the C-level, I consider myself sane and experienced enough to say that Java is something that will do the job well and can be the primary choice for startups and new projects. Kotlin as a platform is not mature enough to deserve the same qualification.

Re: Java 21 makes me like Java again

#159
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.

You can. But you have to try rather hard.

Re: Java 21 makes me like Java again

#160

Earlier quoted context omitted.

Throughput in Java can be quite high, and latency can be quite low. You still occasionally get latency spikes from the GC, but these days that's not so bad. (If you are extremely latency sensitive, stick to C++). Dependency injection frameworks are your bread-and-butter in server-side Java, and some can take a while to grok, but Java can be very productive after the chosen framework "clicks" for you. Typically, this…

Yes, I agree that Python can feel “dirty”, although not necessarily “bloated.”

urllib... getopts...

There's as much useless junk in Python's standard library as there is in Java's.

Post reply on HN