r/Backend • • Oct 16 '26

Modern Java for startups

Unfortunately, I see that Java is disappearing from startup companies. Java used to have an image of an obsolete backend language with performance problems, too verbose and unfriendly to deveopers. It was pretty true to older Java versions and I could understand why startups decided to pick other backend languages

If you look at Java 25, it's an absolutely different story.

Performance wise - it has virtual threads, which makes concurrency extremely high. Virtual threads are Java's answer to goroutines in Golang, and they enable to run thousands of I/O requests concurrently. Java's execution speed is pretty fast (more than Python and node.js).

As for container size - it's huge as long as you work with Spring. However, Java has many other much more lightweight frameworks like Micronaut, Quarkus and Javalin which reduces the container size to be on par with node.js and Python.

It's a real static typing which keeps code safety and improve readability. Unlike Golang, Java has inheritance, ploymorphism and explicit interface (let alone speaking about error handling).

It has a huge talent pool (almost everybody learned Java at a certain point).

As for verbosity and developer experience - Java has been improved a lot in this field. It has records (no need for getters setters, equals and hash), unnamed class (no need to write "public static void main" everytime you start a new program) and dozens of libraries and other tools.

If so, why are startups still stay away from Java and stick to Python/node.js/Golang?

72 Upvotes

75 comments sorted by

View all comments

13

u/Known_Tackle7357 Oct 16 '26

Virtual threads changed almost nothing. Shifting thread pool management from the application to the jvm doesn't make apps magically more performant. At the same time Oracle is very keen on introducing breaking changes. So everything what people used to hate c# for is true for java now.

5

u/Sad_Importance_1585 Oct 16 '26

The most idiomatic way Java server handles http requests is thread-per-request. A thread is very expensive, and it limits the number of concurrent http requests it can handle at the same time. Java can also use an event loop (like node.js), which is usually more efficient than thread-per-request (for heavy I/O server), but it's very hard in Java, since most of Java libraries are blocking. If the server is not CPU-intensive, using virtual threads can enable one thread to handle hundreds of requests simultaneously. It's a huge performance gain.

8

u/UnderdogRP Oct 16 '26

This is not true anymore and had not been for a long time. Most (almost ally?) frameworks use netty which do event queues and thread pools internal. And do not use one thread per request.

1

u/EnvironmentalLet9682 Oct 19 '26

That stopped being true a long time ago.

1

u/Known_Tackle7357 Oct 16 '26

If your server is compute heavy, virtual threads will give you no benefit. Probably even hurt, because under the hood you have the same threads moving the context between logical threads. So if you don't park your logic threads, you can't pass the context, so it doesn't matter what you use the good old thread pools or the new fancy virtual threads. The old approach requires you to think about your threads and pools, and the new one abstracts it out for you

2

u/smhs1998 Oct 16 '26

If your server is compute heavy, then more threads won't help you either. A better algorithm or more compute are the only things that can help you

Most of these performance discussions happen in context of I/O heavy code paths, which comprise the majority of code paths you will encounter in your career

2

u/Known_Tackle7357 Oct 17 '26

Well, more threads won't help, it will actually hurt. Thus having fewer threads in an isolated pool is actually better, because it leaves some breathing room for the rest of the app. Using virtual threads for that will hurt you even more, because they will get spread out across all real threads and block everything. For IO heavy stuff the only difference between virtual threads and real threads is who manages them. Virtual threads allow you to not worry about thread pools and stuff as the jvm does it for you. If you've done your due diligence, profiled your threads, and tuned your thread pools, switching to virtual threads will likely hurt you as well. Virtual threads are good if you never thought about all that stuff and always created threads wishy washy.

2

u/smhs1998 Oct 17 '26

I agree that more threads will hurt performance of compute heavy workloads, but in I/O bound workload, context switching is a major overhead and that overhead is much less when virtual threads come into the picture because you don’t need the OS to perform the whole context switch for you in order to switch to a different request while waiting for on a I/O response for some other request

1

u/Sad_Importance_1585 Oct 17 '26

So according to what you say, Go can handle less concurrent requests than Java with without virtual threads. According to the benchmarks, You can see a benchmark comparison here:
https://www.javacodegeeks.com/2026/02/go-vs-java-the-backend-performance-battle.html

Java Spring boot can handle 15,000-25,000 concurrent requests, while Java with virtual threads and Go can handle 35,000-50,000 requests

2

u/PermissionOwn4400 Oct 16 '26

Wait, there have been breaking changes? Can you provide some links so I can read up on this?

0

u/Known_Tackle7357 Oct 16 '26

For example deleting com.sun.* packages. Lots of them where publicly documented, so it doesn't even count as changing the private api. Because they were public from the very beginning. AccessController there as well. Implicit xml schama inheritance that became explicit and broke a lot of stuff. On top of that all the private api stuff that one may say was justifiable. But at the same time broke a butt load of most popular frameworks like spring. Reflection related stuff, when your code continues to compile, but no longer works without special flags. And so on, and so forth.

3

u/dreamsofabetter Oct 16 '26

It’s not that they weren’t telegraphing what the plans were. The strong encapsulation stuff was originally intended for Java 7, before Oracle entered the picture. And while the com.sun.* stuff was well-known, it’s never been part of the documented API without big warnings saying, essentially, use at your own risk

2

u/Known_Tackle7357 Oct 16 '26

https://docs.oracle.com/javase/8/docs/jdk/api/javadoc/doclet/index.html

Looks pretty documented to me without any warnings that it would get deleted. But it did get deleted.

2

u/dreamsofabetter Oct 17 '26

I mean… sure. The doclet API, though, is neither part of the Java language nor its standard library. It’s part of the `javadoc` tool. And arguably the issue here was using the com.sun namespace.

2

u/Known_Tackle7357 Oct 17 '26

It was shipped with the rest of jdk, had public documentation. And oracle deleted it. If it's not a breaking change, idk what is

1

u/Electrical-Pizza-863 Oct 23 '26

That's not how virtual threads work. Virtual threads move thread management from the OS level to the JVM runtime. They absolutely have performance gains and is the same concept of how threads are handled in Go and a lot of the reason Go is so popular as a backend language.

0

u/Obmanuti Oct 17 '26

But it does benefit performance. People are not good at managing concurrency. Not having to have sync vs async apis etc. Now you can use synchronous clients without blocking a thread waiting on IO. Your take reads like you either dont understand or havent actually thought about at all.