Hacker News new | ask | show | jobs
by Xeoncross 1005 days ago
> Java is easily faster and more reliable than Go

I work in Java for my day job and I disagree.

1. Cold starts for Java serverless (lambda) are worse than scripting languages

2. For everything else, Java uses 5-10x more memory than Go. The memory overhead difference is really noticeable while the CPU difference is often similar.

4 comments

1. Ever thought about using class caches, AOT compilation e.g. OpenJ9, GraalVM,...?

2. Most of the time, a signal that the wrong algorithms and data structures are being used

Amazon isn't rushing to rewrite their infrastrure from Java into Go.

Why would they rush? Customer will ultimately pay for infrastructure not Amazon.
Hardly different from what many Go folks are paying as well.
> Cold starts for Java serverless (lambda) are worse than scripting languages

Id be hesitant to use any VM dependant language in serverless... I mean I love elixir and built my startup on it but I'd never consider trying to run it as a lambda function for the same reason. You're fighting against the grain.

> Cold starts for Java serverless (lambda) are worse than scripting languages

I've run plenty of Java applications in Lambda and they are pretty fast (like done in a few minutes fast). I've yet to try SnapStart which can make those workloads even faster.

I have successfully written entirely serverless APIs in Go. It’s not a great fit for everyone, but was for our use-case. Cold-starts became a non-issue compared to Java.
1. Yeah but serverless is completely unnecessary. JVM rewards you for long running processes. CRaC etc are there if you really care about that though.

2. If your Java code is using 5-10x more memory for the same task you are doing it wrong. Java objects do have higher overhead vs Go structs but not an order of magnitude. You could also be tuning the heap wrong, Java will use all the memory you give it and it won't be quick to give it back unless you tell it that it should.

> serverless is completely unnecessary

I don't care for lambda either, but you can't just hand-wave away a huge portion of the current web. Devs use lambda, tens of thousands of them in fact. Java has an expensive startup and it affects them.

> you are doing it wrong

Perhaps, but I've seen it over-and-over again. Maybe you're extra talented, but regardless all us regular people seem to keep producing systems that are much more expensive to run with Java.

I didn't handwave it away. I alluded to there being existing solutions CRaC, AoT, GraalVM, etc. There are ways to entirely eliminate cold-start as a concern if it's important to you

My point was you don't ever -need- serverless. You might like it for whatever reason but it's completely unnecessary when long-lived processes can get the job done and have so many benefits. JIT of course but also connection pools, memory-local caches etc that all much much more important than "being on serverless" which is mostly a net-negative once you look at the picture more wholistically.

I also think it's wrong to go "hey I want to use serverless, what works well with serverless?" insted of going "what is the best tool to solve my problem? Ok now what is the best environment for that to run?".