Earlier quoted context omitted.
>However Java doesn’t support type union so you can get into some ugly and verbose situations Isn't the "sealed interface" described in the OP blog post a type union? Or you mean anonymous unions?
Definitely referring to anonymous unions too. Without them, there’s still friction sometimes which makes union types unnatural. I haven’t written Java in a while and I can’t remember if you could sometimes fake a type union using a generic type on a method, but if you can, it’s definitely super ugly and would raise eyebrows during any code review.
Java 21 makes me like Java again
181–190 of 777 posts
Re: Java 21 makes me like Java again
#182The problem with Java is not Java. It is Oracle and no amount of new features is going to fix that.
Re: Java 21 makes me like Java again
#183Earlier quoted context omitted.
> 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…
Sure, value types are a good thing, but they are no panacea in and of itself. Also, any non-toy GC won't be using malloc, e.g. in Java's case allocating objects is barely more expensive than allocating them on the stack: they use a so-called thread-local allocation buffer, which can be used to allocate new objects in, without expensive synchronization, and the GC can quickly scan it, moving still alive objects out of…
yeah, all these logics still have significant overhead, especially memory wise, it is hard to reason when JVM decides to kick that or another optimization or not kick anything at all.
With value objects you have full control and bare-metal-native performance without compromises.
Re: Java 21 makes me like Java again
#184Earlier quoted context omitted.
> I rarely see inheritance used in practice in java code bases. Without some specific call-out, it can be assumed that this is a very niche viewpoint that has no bearing on modern development. The vast majority of projects use inheritance, today. Does it use Spring? extends SpringBootServletInitializer Meaningful responses using values from a request? extends OncePerRequestFilter Formatting exception handling respons…
You need to inherit to create anything that is a class. But the focus is on composition. You inherit from useful classes so you can build the solution using composition. I don’t like modern Java because there’s too much non-Java magic code. Layers of stuff that “helps” but removes me from the language. Entire programs written in config and special text wrapping classes and methods. How it works requires understanding…
That's true of the Java compiler, for which the documentation is strewn around the intenet...but an example is here: https://medium.com/javarevisited/compiler-generated-classes-...
The Java syntax doe not require extending Object explicitly.eg This is a valid, useless, class:
public class App {}
> I don’t like modern Java because there’s too much non-Java magic codeIt seems like this is the common path for popular languages. They develop their own library-backed DSL's for the most common use cases, which are often little more than macros (@data @getter, @notnull, etc). I am biased by what I've seen in the last 30 years though.
Re: Java 21 makes me like Java again
#185Earlier 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++ Every time I see something like this I roll my eyes... C++ doesn't have any "memory problems". There are sometimes human problems, such as thinking one is capable of coding without understanding the (basic programming) concept of a pointer. But that's because the human's dumb, not a language problem. (This argument also sometimes comes from those who do understand basic programmin…
Well, every time I see someone claim this, I roll my eyes.
Re: Java 21 makes me like Java again
#186Is there an Ocaml vatiant for the JVM (similar to F# for dotnet)?
You could say Kotlin to some extent..
[0]: https://arrow-kt.io
Re: Java 21 makes me like Java again
#187The biggest feature in Java 21 is the release of Virtual Threads: https://openjdk.org/jeps/444 For some reason, this is missing from the article. If there was any feature that would sway existing Golang developers to switch to Java, it would be this. It would perhaps also convince the haters of the reactive-style concurrency patterns.
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 computer in single folders. The tooling is built into the language. You don't need a IDE like IntelliJ just to make it feel reasonable to work with.
Maybe all of this has changed, but most of the libraries I see in Java today still look like this.
Re: Java 21 makes me like Java again
#188[flagged]
Do you feel good about yourself, talking down on people that made a perfectly valid choice by developing software in Java? Let's look at the alternatives you mentioned: Rust and Golang. Java compared to Golang is a much more expressive language. Java compared to Rust is a much easier language because you have a garbage collector for the majority of the cases you don't need the manual memory controls that Rust offers…
Netflix uses Java and Rust and Go.
Twitter used to use Scala.
GitHub uses Ruby on Rails.
EpicGames uses C++.
Instagram uses Python.
Everybody uses something.
Now, if you have building on top of your organizations previous 10 years of engineering, you’re probably going to be writing Java and it’s probably going to be complicated. I’ve been there. I wrote Java for 15 years. I won’t anymore. I’m in love with the simplicity and speed of Golang. I’m in love with the robustness and correctness of Rust. I’m in love with docker pull scratch:latest and putting your binary inside to run on an empty metal container. No need to waste 250MB of ram on a JVM. Use nano size instances and it’s just as fast as c5’s (async based workloads).
Re: Java 21 makes me like Java again
#189Earlier 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…
Re: Java 21 makes me like Java again
#190Earlier quoted context omitted.
Sure, value types are a good thing, but they are no panacea in and of itself. Also, any non-toy GC won't be using malloc, e.g. in Java's case allocating objects is barely more expensive than allocating them on the stack: they use a so-called thread-local allocation buffer, which can be used to allocate new objects in, without expensive synchronization, and the GC can quickly scan it, moving still alive objects out of…
> they use a so-called thread-local allocation buffer, which can be used to allocate new objects in, without expensive synchronization, and the GC can quickly scan it, moving still alive objects out of it yeah, all these logics still have significant overhead, especially memory wise, it is hard to reason when JVM decides to kick that or another optimization or not kick anything at all. With value objects you have ful…
Not even you believe that, right? Especially with regards to Go.. Go is closer to JS than to Rust/C++.